/* ==========================================================================
   YUVIXDIGITAL — Mobile Responsiveness & Adaptive Stylesheet
   ========================================================================== */

/* ── Global Touch & Viewport Utilities ─────────────────────────────────── */
html, body {
    overflow-x: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

img, video, iframe, svg {
    max-width: 100%;
    height: auto;
}

/* ── Tablet & Small Screens (<= 991.98px) ──────────────────────────────── */
@media (max-width: 991.98px) {

    .navbar-collapse {
        background: #ffffff;
        padding: 1.25rem;
        border-radius: 16px;
        margin-top: 0.75rem;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
        border: 1px solid rgba(0, 0, 0, 0.05);
    }

    .navbar-nav { align-items: stretch !important; gap: 0.5rem !important; }

    .navbar-nav .nav-link {
        padding: 0.65rem 1rem !important;
        border-radius: 8px;
    }

    .navbar-nav .nav-link:hover,
    .navbar-nav .nav-link.active {
        background-color: rgba(24, 119, 242, 0.08);
    }

    .nav-support-pill {
        width: 100%;
        justify-content: center;
        padding: 0.6rem 1rem !important;
        border-radius: 10px !important;
        margin-top: 0.25rem;
    }

    .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ── Mobile (<= 767.98px) ───────────────────────────────────────────────── */
@media (max-width: 767.98px) {

    /* ── Page banner ──────────────────────────────────────────────── */
    .active-page-banner {
        flex-direction: column;
        align-items:    flex-start;
        gap:            .7rem;
        padding:        .9rem 1rem;
    }

    .active-page-banner .d-flex.align-items-center.gap-2 {
        width:     100%;
        flex-wrap: wrap;
        gap:       .4rem !important;
    }

    /* ── Stat cards — fix "Auto-Deleted" text overflow ──────────── */
    #dashboard-stats-grid .stat-card {
        padding:     .7rem .75rem;
        gap:         .55rem;
        min-height:  64px;
        align-items: flex-start;
    }

    .stat-card__icon {
        width:       34px;
        height:      34px;
        font-size:   .95rem;
        flex-shrink: 0;
        margin-top:  2px;
    }

    .stat-card__value {
        font-size:   .95rem;
        font-weight: 800;
        line-height: 1.2;
        word-break:  break-word;   /* prevents "Auto-Deleted" overflow */
        white-space: normal;
    }

    .stat-card__label {
        font-size:   .65rem;
        line-height: 1.3;
        margin-top:  .1rem;
    }

    /* ── Section headings ────────────────────────────────────────── */
    .section-heading__title { font-size: .95rem; }

    /* ── Upload form — full-width submit button ───────────────────── */
    #form-actions {
        flex-direction: column;
        align-items:    stretch;
        gap:            .65rem;
    }
    #form-actions #btn-submit-posts { width: 100%; }

    /* ── Posts card header ───────────────────────────────────────── */
    #posts-card .card-header { flex-wrap: nowrap; gap: .4rem; }
    #posts-card .card-header .section-heading__title {
        font-size:   .9rem;
        white-space: nowrap;
    }

    /* ══════════════════════════════════════════════════════════════
       POSTS TABLE → MOBILE CARD LAYOUT
       Each <tr> becomes a standalone rounded card with a full-width
       image banner at the top and label:value rows below it.
       ══════════════════════════════════════════════════════════════ */

    .posts-table,
    .posts-table thead,
    .posts-table tbody,
    .posts-table tr,
    .posts-table td,
    .posts-table th {
        display:        block !important;
        width:          100% !important;
        border-spacing: 0 !important;
    }

    /* Hide desktop thead */
    .posts-table thead { display: none !important; }

    /* Each row = a card */
    .posts-table tbody tr {
        background:    #ffffff;
        border:        1px solid #e2e8f0 !important;
        border-radius: 16px !important;
        box-shadow:    0 3px 12px rgba(0, 0, 0, 0.06) !important;
        margin-bottom: 1rem !important;
        padding:       0 !important;
        overflow:      hidden !important;
    }

    /* Thumbnail → full-width banner */
    .posts-table tbody td.td-thumbnail {
        padding:       0 !important;
        border-bottom: 1px solid #e2e8f0 !important;
        background:    #f0f6ff;
    }

    .posts-table tbody td.td-thumbnail .post-thumb {
        width:         100% !important;
        height:        160px !important;
        object-fit:    cover !important;
        border-radius: 0 !important;
        border:        none !important;
        display:       block !important;
    }

    /* Data cells: label left | value right */
    .posts-table tbody td[data-label] {
        display:         flex !important;
        justify-content: space-between !important;
        align-items:     center !important;
        padding:         .55rem 1rem !important;
        border-bottom:   1px solid #f1f5f9 !important;
        font-size:       .875rem !important;
        gap:             .5rem;
        min-height:      40px;
    }

    /* Auto-inject column label */
    .posts-table tbody td[data-label]::before {
        content:        attr(data-label);
        font-size:      .68rem;
        font-weight:    700;
        text-transform: uppercase;
        letter-spacing: .5px;
        color:          #64748b;
        white-space:    nowrap;
        flex-shrink:    0;
    }

    /* Caption: allow wrapping */
    .posts-table tbody td.post-caption-cell {
        white-space: normal !important;
        max-width:   none !important;
        overflow:    visible !important;
        text-align:  right;
    }

    /* FB Post ID: clip the long number */
    .posts-table tbody td[data-label="FB Post ID"] a,
    .posts-table tbody td[data-label="FB Post ID"] span {
        max-width:     155px !important;
        overflow:      hidden !important;
        text-overflow: ellipsis !important;
        white-space:   nowrap !important;
        display:       inline-block !important;
    }

    /* Actions row: buttons only, right-aligned */
    .posts-table tbody td.td-actions {
        justify-content: flex-end !important;
        border-bottom:   none !important;
        padding:         .65rem 1rem !important;
    }
    .posts-table tbody td.td-actions::before { display: none !important; }

    /* Bigger touch targets */
    .btn-action-view,
    .btn-action-reschedule,
    .btn-action-delete {
        width:           42px !important;
        height:          42px !important;
        border-radius:   10px !important;
        font-size:       1rem !important;
        display:         inline-flex !important;
        align-items:     center !important;
        justify-content: center !important;
        padding:         0 !important;
    }

    /* ── Modals ─────────────────────────────────────────────────── */
    .modal-dialog  { margin: .75rem; }
    .modal-content { border-radius: 20px !important; }

    /* ── FilePond ────────────────────────────────────────────────── */
    .filepond--drop-label { min-height: 140px !important; }

    /* ── Auth & Setup ────────────────────────────────────────────── */
    .setup-hero        { padding: 1.5rem 1rem !important; }
    .setup-hero__title { font-size: 1.35rem !important; }

    .auth-card, .social-login-card {
        padding:       1.75rem 1.25rem !important;
        border-radius: 20px !important;
    }
}

/* ── Extra Small (<= 575.98px) ─────────────────────────────────────────── */
@media (max-width: 575.98px) {

    /* 1 stat card per row on very small phones */
    #dashboard-stats-grid .col-6 {
        width:     100%;
        flex:      0 0 100%;
        max-width: 100%;
    }

    .support-floating-widget { bottom: 16px; right: 16px; }

    .support-trigger-btn {
        padding:       .55rem 1rem;
        font-size:     .825rem;
        border-radius: 40px;
    }
}
