/* ═══════════════════════════════════════════════════════════════
   ACBIZ CORE v1 — Mobile Responsive Styles
   Covers: Navbar, all pages, cards, tables, forms
═══════════════════════════════════════════════════════════════ */

/* ── Navbar Reset ─────────────────────────────────────────── */
.navbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    position: sticky;
    top: 0;
    z-index: 200;
}

.navbar .container {
    padding: 0 16px;
}

.nav-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

/* Desktop: links inline */
.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-bottom: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    color: #475569;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: background .15s, color .15s;
}

.nav-item:hover { background: #f1f5f9; color: #0f172a; }
.nav-item-admin { color: #1a56db; font-weight: 700; }
.nav-item-admin:hover { background: #eff6ff; }
.nav-item-logout { color: #dc2626; }
.nav-item-logout:hover { background: #fee2e2; color: #991b1b; }
.nav-item-cta { background: var(--primary); color: #fff !important; }
.nav-item-cta:hover { background: #1648c0; }

.nav-icon { font-size: 14px; }

.nav-user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: #f8fafc;
    border-radius: 20px;
    border: 1px solid var(--border);
    margin-right: 4px;
}

.nav-avatar {
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.nav-username { font-size: 13px; font-weight: 600; color: #334155; }

.nav-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}

/* Hide hamburger on desktop */
.hamburger { display: none; }

/* Hide overlay on desktop */
.nav-overlay { display: none; }

/* ── Mobile: ≤768px ───────────────────────────────────────── */
@media (max-width: 768px) {

    /* Show hamburger */
    .hamburger {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 28px;
        height: 20px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0;
        z-index: 300;
    }

    .hamburger span {
        display: block;
        height: 2px;
        width: 100%;
        background: #334155;
        border-radius: 2px;
        transition: transform .3s, opacity .3s;
    }

    .hamburger.open span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
    .hamburger.open span:nth-child(2) { opacity: 0; }
    .hamburger.open span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }

    /* Slide-in drawer */
    .nav-links {
        position: fixed;
        top: 0;
        right: -280px;
        width: 280px;
        height: 100vh;
        background: #fff;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        padding: 72px 12px 24px;
        box-shadow: -4px 0 24px rgba(0,0,0,.12);
        transition: right .3s ease;
        overflow-y: auto;
        z-index: 250;
    }

    .nav-links.open { right: 0; }

    .nav-item {
        padding: 12px 14px;
        font-size: 15px;
        border-radius: 10px;
    }

    .nav-user-badge {
        margin: 0 0 4px;
        border-radius: 10px;
        padding: 10px 14px;
        justify-content: flex-start;
    }

    .nav-username { font-size: 14px; }

    .nav-divider {
        width: 100%;
        height: 1px;
        margin: 6px 0;
    }

    /* Overlay */
    .nav-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.4);
        z-index: 240;
        opacity: 0;
        pointer-events: none;
        transition: opacity .3s;
    }

    .nav-overlay.open {
        opacity: 1;
        pointer-events: all;
    }

    /* ── Page layouts ─────────────────────────────────── */
    .container { padding: 0 14px; }
    main.container { padding-top: 20px; padding-bottom: 40px; }

    /* Stats grid */
    .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 12px; }

    /* Admin grid */
    .admin-grid-2 { grid-template-columns: 1fr !important; }

    /* Page header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .page-header h2 { font-size: 20px; }

    .action-btns { flex-wrap: wrap; }

    /* Tables — horizontal scroll */
    .table-wrap,
    .admin-card .card-body.no-pad {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .admin-table { min-width: 600px; }
    .data-table  { min-width: 560px; }

    /* Cards */
    .admin-card { margin-bottom: 16px; }
    .card-body  { padding: 14px; }

    /* Forms */
    .form-row { flex-direction: column !important; }
    .form-row > * { width: 100% !important; flex: none !important; }

    /* Invoice form grid */
    .invoice-form-grid { grid-template-columns: 1fr !important; }

    /* Plans grid */
    .plans-grid { grid-template-columns: 1fr !important; }

    /* Clients grid */
    .clients-grid { grid-template-columns: 1fr !important; }

    /* Links grid */
    .links-grid { grid-template-columns: 1fr !important; }

    /* Pay wrap */
    .pay-wrap { grid-template-columns: 1fr !important; }

    /* Export grid */
    .export-grid { grid-template-columns: 1fr !important; }

    /* Auth card */
    .auth-card { padding: 24px 18px; margin: 20px auto; }

    /* Hero */
    .hero h1 { font-size: 28px; }
    .hero p  { font-size: 15px; }

    /* Features grid */
    .features { grid-template-columns: 1fr 1fr; gap: 12px; }
    .feature-card { padding: 16px; }
    .feature-card h3 { font-size: 15px; }

    /* Invoice preview */
    .invoice-preview { padding: 20px; }
    .inv-header { flex-direction: column; gap: 16px; }
    .inv-meta   { text-align: left; }
    .inv-parties { flex-direction: column; gap: 16px; }
    .inv-dates  { text-align: left; }
    .inv-date-row { justify-content: flex-start; gap: 12px; }
    .inv-totals { max-width: 100%; }
    .inv-items  { min-width: 480px; }
    .inv-items-wrap { overflow-x: auto; }

    /* Portal */
    .portal-stats { grid-template-columns: repeat(2,1fr) !important; }
    .portal-invoice-row { flex-wrap: wrap; gap: 8px; }
    .inv-row-right { width: 100%; }

    /* Comparison */
    .comparison-row { gap: 8px; }
    .comp-value { font-size: 18px; }
    .comp-arrow { font-size: 16px; padding: 8px 10px; }

    /* Today stats */
    .today-stats { grid-template-columns: repeat(2,1fr) !important; }

    /* Scope grid */
    .scope-grid { grid-template-columns: 1fr !important; }

    /* Report export */
    .export-item { padding: 14px; }

    /* Subscription plan picker */
    .plan-picker { gap: 8px; }

    /* Modal */
    .modal { margin: 0 12px; }

    /* Buttons */
    .btn-group { flex-direction: column; align-items: center; }
    .btn-group .btn { width: 100%; max-width: 300px; text-align: center; }

    /* Admin panel */
    .admin-main { margin-left: 0 !important; }

    /* Admin stats */
    .stats-grid.stats-grid-4 { grid-template-columns: repeat(2,1fr) !important; }
}

/* ── Very small phones: ≤400px ────────────────────────────── */
@media (max-width: 400px) {
    .stats-grid { grid-template-columns: 1fr !important; }
    .features   { grid-template-columns: 1fr !important; }
    .today-stats{ grid-template-columns: 1fr !important; }
    .portal-stats { grid-template-columns: 1fr !important; }
    .stat-value { font-size: 20px; }
}

/* ── Tablet: 769px–1024px ─────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
    .nav-item { padding: 5px 7px; font-size: 12px; }
    .nav-icon { display: none; }
    .stats-grid { grid-template-columns: repeat(2,1fr); }
    .invoice-form-grid { grid-template-columns: 1fr; }
    .admin-grid-2 { grid-template-columns: 1fr; }
}

/* ── Touch improvements ───────────────────────────────────── */
@media (hover: none) {
    .btn   { min-height: 44px; }
    .nav-item { min-height: 44px; }
    .form-group input,
    .form-group select,
    .form-group textarea { font-size: 16px; } /* prevent iOS zoom */
}
