/* SocialFlow CMS UI hardening layer.
   Kept separate from the existing compiled stylesheet so future asset builds
   cannot silently remove the CMS-specific layout rules. */

html {
    min-width: 320px;
    -webkit-text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img,
video,
canvas,
svg {
    max-width: 100%;
}

img,
video {
    display: block;
}

a,
button,
input,
textarea,
select {
    -webkit-tap-highlight-color: transparent;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(108, 92, 231, .28);
    outline-offset: 2px;
}

.main {
    min-width: 0;
    overflow: hidden;
}

.sidebar {
    z-index: 30;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
}

.nav a {
    min-height: 42px;
    align-items: center;
    line-height: 1.25;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
}

.content {
    width: 100%;
}

.page-head {
    gap: 18px;
}

.page-head > div:first-child {
    min-width: 0;
}

.page-head h1,
.page-head h2,
.card h3 {
    line-height: 1.25;
}

.page-head h1 {
    overflow-wrap: anywhere;
}

.card {
    min-width: 0;
}

.card h3 {
    margin-top: 0;
}

.btn {
    min-height: 40px;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: .55;
    transform: none;
}

.input {
    min-height: 42px;
    min-width: 0;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, .12);
    outline: 0;
}

textarea.input {
    line-height: 1.55;
}

input[type="file"].input {
    padding: 7px 9px;
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--brand);
}

.actions {
    align-items: center;
}

.actions form {
    margin: 0;
}

.media-item {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.media-item img,
.media-item video {
    display: block;
}

.media-item p {
    overflow-wrap: anywhere;
    margin: 12px 0;
}

.media-source-meta {
    margin: 0 0 14px;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fafaff;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.media-hashtags {
    margin-top: 5px;
    color: var(--brand);
    line-height: 1.45;
}

.media-source-meta details {
    margin-top: 8px;
}

.media-source-meta summary {
    cursor: pointer;
    color: var(--muted);
    font-weight: 650;
}

.media-source-meta details p {
    margin: 7px 0 0;
    color: var(--muted);
    white-space: pre-wrap;
}

.media-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr);
    gap: 18px;
    align-items: start;
}

.media-detail-preview {
    min-width: 0;
}

.media-detail-preview > img,
.media-detail-preview > video {
    display: block;
    width: min(100%, 760px);
    height: auto;
    max-height: min(68vh, 640px);
    object-fit: contain;
    border-radius: 12px;
    background: #101522;
    margin: 0 auto;
}

.editor-stage {
    width: 100%;
    max-width: 680px;
    max-height: min(62vh, 600px);
    margin-left: auto;
    margin-right: auto;
}

.editor-stage video {
    max-height: min(62vh, 600px);
}

.media-detail-preview > .actions {
    margin-top: 16px;
}

.media-detail-info h3 {
    margin-bottom: 18px;
}

.media-detail-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.media-detail-heading h3 {
    margin: 0;
}

.media-meta-form {
    min-width: 0;
}

.media-meta-form textarea {
    min-height: 190px;
}

.media-readonly-note {
    display: grid;
    gap: 3px;
    margin-top: 16px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--muted);
    font-size: 12px;
}

.media-readonly-note strong {
    color: var(--ink);
}

.media-detail-field {
    display: grid;
    gap: 5px;
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
}

.media-detail-field:last-of-type {
    border-bottom: 0;
}

.media-detail-field > span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.media-detail-field small {
    display: block;
}

.media-caption {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
    white-space: pre-wrap;
}

.source-link {
    color: var(--brand);
    font-weight: 650;
}

.media-clean-note {
    margin: 18px 0 0;
    font-size: 12px;
}

.media-item > .actions {
    margin-top: auto;
}

.media-check,
.platform {
    cursor: pointer;
}

.platform input {
    flex: 0 0 auto;
}

.table-wrap {
    -webkit-overflow-scrolling: touch;
}

.table-wrap table {
    min-width: 680px;
}

table td {
    vertical-align: top;
    overflow-wrap: anywhere;
}

code {
    padding: 2px 5px;
    border-radius: 5px;
    background: #f0f1f6;
    color: #4f5870;
    font-size: .9em;
}

.calendar-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.calendar {
    min-width: 700px;
}

.calendar-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin: -8px 0 14px;
    color: var(--muted);
    font-size: 12px;
}

.calendar-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.calendar-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #9aa3b8;
}

.calendar-dot-scheduled {
    background: #e7a72c;
}

.calendar-dot-published {
    background: #18a874;
}

.calendar-dot-failed {
    background: #e25563;
}

.calendar-dot-pending {
    background: #4b8bd8;
}

.event-scheduled {
    background: #fff4da;
    color: #91600c;
}

.event-published {
    background: #e7f9f2;
    color: #087956;
}

.event-failed {
    background: #ffebed;
    color: #b72d3c;
}

.event-pending,
.event-processing {
    background: #e9f2ff;
    color: #2763ad;
}

.event-draft,
.event-cancelled {
    background: #edf0f7;
    color: #59627a;
}

.event {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Laravel's default pagination markup uses utility classes that are not part
   of the compact CMS stylesheet. These rules keep it readable and usable. */
nav[aria-label="Pagination Navigation"] {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

nav[aria-label="Pagination Navigation"] > div {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

nav[aria-label="Pagination Navigation"] a,
nav[aria-label="Pagination Navigation"] span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    min-height: 38px;
    padding: 7px 11px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    color: var(--ink);
    font-size: 13px;
}

nav[aria-label="Pagination Navigation"] a:hover {
    border-color: var(--brand);
    color: var(--brand);
}

nav[aria-label="Pagination Navigation"] span[aria-current="page"] {
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
}

nav[aria-label="Pagination Navigation"] svg {
    width: 18px;
    height: 18px;
}

nav[aria-label="Pagination Navigation"] .hidden {
    display: none;
}

@media (max-width: 900px) {
    .sidebar {
        left: 0;
        box-shadow: 10px 0 30px rgba(18, 24, 45, .25);
    }

    .sidebar.open {
        display: block;
    }

    .page-head {
        align-items: flex-start;
    }

    .media-detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .page-head {
        flex-direction: column;
        align-items: stretch;
    }

    .page-head > .btn,
    .page-head > .actions {
        width: 100%;
    }

    .page-head > .actions .btn {
        flex: 1 1 auto;
    }

    .topbar .actions > span {
        max-width: 34vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar .actions form,
    .topbar .actions form .btn {
        width: auto;
    }

    .card {
        padding: 16px;
        border-radius: 14px;
    }

    .actions .btn {
        min-width: 0;
    }

    nav[aria-label="Pagination Navigation"] {
        align-items: flex-start;
    }

nav[aria-label="Pagination Navigation"] > div {
        width: 100%;
    }
}

.media-upload-card {
    margin-bottom: 18px;
}

.media-filter-bar {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(140px, 1fr)) auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
}

.media-filter-bar label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted, #64748b);
}

.media-filter-actions {
    display: flex;
    gap: 8px;
}

.media-library-summary {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 0 0 12px;
    font-size: 13px;
}

.media-engagement {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 10px 0;
}

.media-engagement span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 9px;
    border: 1px solid #dbe4ef;
    border-radius: 999px;
    background: #f8fafc;
    color: #334155;
    font-size: 12px;
    font-weight: 700;
}

.form-errors {
    margin-bottom: 18px;
    border-color: #fecaca;
    background: #fff7f7;
    color: #991b1b;
}

.form-errors ul {
    margin: 8px 0 0 18px;
}

.form-help {
    margin: -2px 0 10px;
    font-size: 12px;
}

.media-picker-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 0 10px;
}

.media-picker-tools .muted {
    font-size: 12px;
}

@media (max-width: 980px) {
    .media-filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .media-filter-search {
        grid-column: 1 / -1;
    }
}

@media (max-width: 600px) {
    .media-filter-bar {
        grid-template-columns: 1fr;
    }

    .media-filter-search {
        grid-column: auto;
    }

    .media-filter-actions {
        width: 100%;
    }

    .media-filter-actions .btn {
        flex: 1;
    }

    .media-library-summary {
        align-items: flex-start;
        flex-direction: column;
        gap: 3px;
    }
}

@media (max-width: 380px) {
    .content {
        padding-left: 12px;
        padding-right: 12px;
    }

    .topbar {
        padding-left: 12px;
        padding-right: 12px;
    }

    .topbar .muted {
        display: none;
    }

    .actions .btn {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* Media playback fallback: keep unsupported files understandable instead of a blank card. */
.media-video-shell {
    position: relative;
    width: 100%;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 12px;
    background: #101828;
}

.media-video-shell .media-video {
    display: block;
    width: 100%;
    max-width: 100%;
}

.media-video-fallback {
    display: none;
    padding: 18px;
    color: #d0d5dd;
    text-align: center;
    font-size: .88rem;
}

.media-video-error .media-video {
    display: none;
}

.media-video-error .media-video-fallback {
    display: block;
}

/* Keep the complete navigation reachable on short desktop and mobile
   viewports instead of letting the lower links disappear below the fold. */
.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
}

.sidebar .brand {
    flex: 0 0 auto;
}

.sidebar .nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding-bottom: 48px;
    scrollbar-width: thin;
    scrollbar-color: rgba(217, 220, 237, .45) transparent;
}

.sidebar .nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar .nav::-webkit-scrollbar-thumb {
    border-radius: 99px;
    background: rgba(217, 220, 237, .45);
}

.sidebar .nav a:last-of-type {
    margin-bottom: 8px;
}

@media (max-width: 900px) {
    .sidebar {
        display: none;
    }

    .sidebar.open {
        display: flex;
    }
}

.sidebar-footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 8px 0 0;
    padding: 12px 10px 0;
    border-top: 1px solid rgba(217, 220, 237, .14);
    color: #d9dced;
}

.sidebar-footer-dot {
    width: 9px;
    height: 9px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #22c7a9;
    box-shadow: 0 0 0 4px rgba(34, 199, 169, .12);
}

.sidebar-footer strong,
.sidebar-footer small {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-footer strong {
    font-size: 12px;
}

.sidebar-footer small {
    margin-top: 2px;
    color: #858eaa;
    font-size: 10px;
}

/* Desktop sidebars should wrap their navigation instead of painting a large
   empty 100vh block below the last link. On mobile the drawer remains full
   height so every link can still be scrolled into view. */
@media (min-width: 901px) {
    .sidebar {
        align-self: start;
        height: fit-content;
        min-height: 0;
        max-height: 100vh;
    }

    .sidebar .nav {
        flex: 0 1 auto;
        max-height: calc(100vh - 126px);
    }
}

@media (max-width: 900px) {
    .sidebar {
        min-height: 0;
        height: 100dvh;
        max-height: 100dvh;
    }
}

/* Responsive system layer. Keep every page inside the viewport, including
   pages that have their own inline editor/filter styles. */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

body {
    margin: 0;
}

.app,
.main,
.content,
.card,
.grid,
.stats,
.two,
.composer,
.account-grid,
.media-grid,
.platforms,
.page-head,
.topbar,
.actions,
.form-group,
.editor-layout,
.editor-stage-wrap,
.media-detail-grid {
    min-width: 0;
}

.app {
    width: 100%;
    max-width: 100vw;
}

.main,
.content {
    width: 100%;
    max-width: 100%;
}

.content > *,
.page-head > *,
.topbar > *,
.card > *,
.grid > *,
.actions > *,
.form-group > * {
    min-width: 0;
    max-width: 100%;
}

.page-head > div:first-child,
.page-head h1,
.page-head p,
.card h1,
.card h2,
.card h3,
.card h4,
.muted,
.error,
.alert,
.media-file-name,
.download-url,
.source-link {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.topbar .actions,
.page-head .actions {
    max-width: 100%;
}

.topbar .actions > *,
.page-head .actions > *,
.actions form,
.actions form button {
    min-width: 0;
    max-width: 100%;
}

img,
video,
canvas,
svg,
iframe,
embed,
object {
    max-width: 100%;
}

button,
.btn,
input,
select,
textarea {
    max-width: 100%;
}

input,
select,
textarea {
    font-size: 16px;
}

.table-wrap,
.calendar-wrap,
.download-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
}

.table-wrap table,
.download-table-wrap table {
    max-width: none;
}

.editor-layout {
    width: 100%;
}

.editor-stage-wrap,
.editor-stage,
.media-detail-preview,
.media-detail-info {
    max-width: 100%;
}

.editor-stage video,
.media-detail-preview video,
.media-detail-preview img {
    max-width: 100%;
}

.mobile-toggle {
    flex: 0 0 auto;
}

@media (max-width: 900px) {
    .app {
        display: block;
    }

    .sidebar {
        width: min(280px, 86vw);
        height: 100dvh;
        max-height: 100dvh;
        overflow-y: auto;
    }

    .topbar {
        padding-left: 20px;
        padding-right: 20px;
    }

    .content {
        padding: 22px 20px;
    }

    .stats,
    .analytics-grid,
    .scheduler-summary,
    .download-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .two,
    .composer,
    .media-detail-grid,
    .editor-layout,
    .grid[style*="grid-template-columns"] {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .account-grid,
    .media-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .platforms {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .page-head h1 {
        font-size: 23px;
    }

    .editor-stage-wrap {
        padding: 12px;
    }
}

@media (max-width: 600px) {
    .content {
        padding: 16px 12px;
    }

    .topbar {
        min-height: 62px;
        height: auto;
        padding: 10px 12px;
        gap: 8px;
        flex-wrap: wrap;
    }

    .topbar > .muted {
        flex: 1 1 auto;
        min-width: 0;
    }

    .topbar .actions {
        flex: 0 1 auto;
        margin-left: auto;
        gap: 6px;
    }

    .topbar .actions > span {
        max-width: 120px;
    }

    .page-head {
        align-items: flex-start;
        margin-bottom: 16px;
    }

    .page-head h1 {
        font-size: 20px;
        line-height: 1.2;
    }

    .page-head p {
        font-size: 13px;
    }

    .page-head > .btn,
    .page-head > .actions,
    .page-head .actions {
        width: 100%;
    }

    .page-head .actions .btn {
        flex: 1 1 auto;
    }

    .stats,
    .two,
    .composer,
    .account-grid,
    .media-grid,
    .platforms,
    .analytics-grid,
    .scheduler-summary,
    .download-stats,
    .grid[style*="grid-template-columns"] {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .card {
        padding: 14px;
        border-radius: 13px;
    }

    .actions {
        gap: 7px;
    }

    .actions .btn {
        min-width: 0;
    }

    .btn {
        min-height: 42px;
        padding: 10px 12px;
    }

    .table-wrap,
    .download-table-wrap {
        margin-left: -14px;
        margin-right: -14px;
        width: calc(100% + 28px);
        border-left: 0;
        border-right: 0;
        border-radius: 0;
    }

    .table-wrap table,
    .download-table-wrap table {
        min-width: 700px;
    }

    .calendar-wrap {
        margin-left: -12px;
        margin-right: -12px;
        width: calc(100% + 24px);
        border-radius: 0;
    }

    .calendar {
        min-width: 700px;
    }

    .media-item img,
    .media-item video {
        height: auto;
        aspect-ratio: 9 / 16;
        object-fit: cover;
    }

    .editor-stage-wrap {
        padding: 8px;
        border-radius: 12px;
    }

    .editor-stage {
        border-radius: 9px;
    }

    .editor-tools,
    .preset-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .editor-tools .btn,
    .preset-row .btn {
        width: 100%;
    }

    .editor-section {
        padding-top: 14px;
        margin-top: 14px;
    }

    .editor-section .actions {
        align-items: stretch;
    }

    .editor-section .actions .input,
    .editor-section .actions .btn {
        flex: 1 1 150px;
    }

    .post-media-state {
        white-space: normal !important;
    }

    .download-url {
        max-width: 180px;
    }

    .chart-row {
        grid-template-columns: minmax(74px, .7fr) minmax(0, 1fr) 34px;
        gap: 7px;
    }

    .daily-chart {
        gap: 3px;
    }

    .legend {
        gap: 9px;
        flex-wrap: wrap;
    }
}

@media (max-width: 380px) {
    .content {
        padding-left: 10px;
        padding-right: 10px;
    }

    .topbar {
        padding-left: 10px;
        padding-right: 10px;
    }

    .topbar > .muted {
        display: none;
    }

    .editor-tools,
    .preset-row {
        grid-template-columns: minmax(0, 1fr);
    }
}
