/* =====================================================================
   Responsive adjustments: phones, tablets, desktop + print
   ===================================================================== */

/* Tablets & phones: sidebar becomes an off-canvas drawer */
@media (max-width: 991.98px) {
    .app-sidebar { --bs-offcanvas-width: 286px; }
    .app-sidebar.offcanvas-lg { background: linear-gradient(180deg, var(--navy) 0%, #0e1830 100%); }
    .app-content { padding: 18px 16px 100px; }
    .app-topbar { padding: 10px 14px; }
    .app-footer { padding: 14px 16px 90px; }
    .wa-actions { grid-template-columns: 1fr; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-hero { padding: 34px 28px 26px; border-right: 0; border-bottom: 1px solid rgba(255, 255, 255, .08); }
    .auth-card { padding: 32px 26px; }

    /* Bottom navigation bar */
    .bottom-nav {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
        display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
        background: #fff; border-top: 1px solid var(--line);
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
        box-shadow: 0 -6px 24px rgba(20, 33, 61, .08);
    }
    .bottom-nav a, .bottom-nav button {
        display: flex; flex-direction: column; align-items: center; gap: 2px;
        background: none; border: 0; color: var(--muted); font-size: .68rem; text-decoration: none; padding: 4px 0;
    }
    .bottom-nav i { font-size: 1.15rem; }
    .bottom-nav a.active { color: var(--navy); }
    .bottom-nav a.active i { color: var(--gold); }
    .bottom-nav .bottom-nav-add {
        width: 56px; height: 56px; margin: -26px auto 0; border-radius: 50%;
        background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #1b1405;
        justify-content: center; box-shadow: 0 8px 20px rgba(201, 162, 39, .45); border: 4px solid #fff;
    }
    .bottom-nav .bottom-nav-add i { font-size: 1.35rem; }
    .toast-container { top: auto !important; bottom: 80px; left: 0; right: 0 !important; display: flex; flex-direction: column; align-items: center; }
}

/* Phones */
@media (max-width: 767.98px) {
    body { font-size: .93rem; }
    .page-title { font-size: 1.4rem; }
    .brand-title { font-size: .98rem; }
    .brand-tagline { font-size: .72rem; }
    .progress-hero { padding: 22px 18px; border-radius: 18px; }
    .big-progress { height: 20px; }
    .stat-card { padding: 13px; }
    .stat-value { font-size: 1.08rem; }
    .stat-icon { width: 32px; height: 32px; margin-bottom: 6px; }
    .panel { padding: 16px; border-radius: 14px; }
    .chart-box { height: 230px; }
    .wa-textarea { min-height: 360px; font-size: .82rem; }
    .report-tabs { flex-direction: column; align-items: stretch; }
    .sticky-save .btn { flex: 1; }

    /* Stack table rows into cards */
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td, .table-stack tfoot, .table-stack tfoot tr, .table-stack tfoot th { display: block; width: 100%; }
    .table-stack tbody tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
    .table-stack td { border: 0; padding: 3px 0; text-align: right !important; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
    .table-stack td::before { content: attr(data-label); color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .4px; font-weight: 600; text-align: left; flex-shrink: 0; }
    .table-stack td > div { text-align: right; }
    .table-stack td[data-label="Actions"], .table-stack td[data-label="History"] { justify-content: flex-end; padding-top: 8px; }
    .table-stack td[data-label="Actions"]::before, .table-stack td[data-label="History"]::before { display: none; }
    .table-stack tfoot tr { display: flex; justify-content: space-between; padding: 12px 14px; }
    .table-stack tfoot th { width: auto; padding: 0; border: 0; }
    .table-stack tfoot th:empty { display: none; }
}

/* Very small phones */
@media (max-width: 380px) {
    .hero-percent { font-size: 1.5rem; padding: 4px 12px; }
    .topbar-user .avatar { width: 28px; height: 28px; }
}

/* Large desktops */
@media (min-width: 1600px) {
    .app-content { padding: 28px 40px 48px; max-width: 1500px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Print */
@media print {
    .app-sidebar, .app-topbar, .bottom-nav, .app-footer, .quick-actions, .filter-bar, .report-export, .btn, .toast-container { display: none !important; }
    .app-content { padding: 0; }
    .panel, .stat-card { box-shadow: none; border: 1px solid #ddd; }
    .progress-hero { color: #000; background: #fff !important; border: 1px solid #ddd; box-shadow: none; }
    body { background: #fff; }
}
