/* ═══════════════════════════════════════════════════════
   APIZAP — Premium Enterprise Design System
   Sidebar layout • Inter font • Dark nav • Neutral tones
   ═══════════════════════════════════════════════════════ */

/* ── Reset ────────────────────────────────────────────── */
*,*::before,*::after { margin:0; padding:0; box-sizing:border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f5f6fa;
    color: #1e2330;
    min-height: 100vh;
    line-height: 1.55;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 260px; z-index: 1100;
    background: #0f1524;
    display: flex; flex-direction: column;
    transition: transform 0.28s cubic-bezier(.4,0,.2,1);
    border-right: 1px solid rgba(255,255,255,0.06);
}

.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.4rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}

.sidebar-logo {
    display: flex; align-items: center; gap: 0.7rem;
}
.sidebar-logo-icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}
.sidebar-logo-text {
    font-size: 1.2rem; font-weight: 700; color: #fff;
    letter-spacing: -0.3px;
}

.sidebar-close { display: none; background: none; border: none; color: #64748b; cursor: pointer; padding: 4px; border-radius: 6px; }
.sidebar-close:hover { color: #fff; background: rgba(255,255,255,0.08); }

/* Nav */
.sidebar-nav {
    flex: 1; overflow-y: auto; padding: 0.75rem 0;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-divider {
    padding: 1.1rem 1.25rem 0.45rem;
    font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 1.2px; color: #475569;
}

.sidebar-link {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 1.25rem; margin: 1px 0.6rem;
    border-radius: 8px; font-size: 0.88rem; font-weight: 500;
    color: #94a3b8; transition: all 0.18s ease;
}
.sidebar-link:hover {
    background: rgba(255,255,255,0.06); color: #e2e8f0;
}
.sidebar-link.active {
    background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(139,92,246,0.12));
    color: #a5b4fc; font-weight: 600;
}
.sidebar-link.active .sidebar-link-icon { color: #818cf8; }
.sidebar-link-icon { display: flex; align-items: center; flex-shrink: 0; }

/* Footer */
.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.07);
    padding: 1rem 1.25rem;
}
.sidebar-user {
    display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.75rem;
}
.sidebar-avatar {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.85rem;
}
.sidebar-user-info { display: flex; flex-direction: column; overflow: hidden; }
.sidebar-user-name { color: #e2e8f0; font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { color: #64748b; font-size: 0.72rem; }

.sidebar-footer-actions { display: flex; gap: 0.5rem; }
.sidebar-footer-link {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 0.45rem; border-radius: 7px; font-size: 0.78rem; font-weight: 500;
    color: #94a3b8; background: rgba(255,255,255,0.04); transition: all 0.18s;
}
.sidebar-footer-link:hover { background: rgba(255,255,255,0.08); color: #e2e8f0; }
.sidebar-footer-link.logout:hover { background: rgba(239,68,68,0.12); color: #fca5a5; }

/* ── Mobile Header ────────────────────────────────────── */
.mobile-header {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; z-index: 1050;
    height: 56px; background: #0f1524;
    align-items: center; padding: 0 1rem; gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.mobile-menu-btn { background: none; border: none; color: #94a3b8; cursor: pointer; padding: 4px; border-radius: 6px; }
.mobile-menu-btn:hover { color: #fff; }
.mobile-header-title { color: #fff; font-weight: 700; font-size: 1.1rem; }

.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 1090; opacity: 0; transition: opacity 0.28s;
}
.sidebar-overlay.active { display: block; opacity: 1; }

/* ── Main Content ─────────────────────────────────────── */
.main-content {
    margin-left: 260px; min-height: 100vh;
    padding: 2rem 2.5rem;
    transition: margin-left 0.28s;
}

.container { max-width: 1400px; margin: 0 auto; padding: 0; }

/* ── Page Header ──────────────────────────────────────── */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.75rem; flex-wrap: wrap; gap: 1rem;
}
.page-header h2 {
    font-size: 1.65rem; font-weight: 700; color: #1e2330;
    letter-spacing: -0.5px;
}
.page-header-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ── Cards ────────────────────────────────────────────── */
.card {
    background: #fff;
    border: 1px solid #e8ecf2;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s;
}
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.06); }

.card-header {
    border-bottom: 1px solid #eef1f6;
    padding-bottom: 1rem; margin-bottom: 1.25rem;
}
.card-title {
    font-size: 1.15rem; font-weight: 700; color: #1e2330;
}

/* ── Buttons ──────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 0.55rem 1.15rem; border: none; border-radius: 8px;
    font-size: 0.88rem; font-weight: 600; cursor: pointer;
    transition: all 0.2s ease; text-decoration: none; line-height: 1.4;
    font-family: inherit;
}

.btn-primary {
    background: #6366f1; color: #fff;
}
.btn-primary:hover { background: #4f46e5; box-shadow: 0 4px 14px rgba(99,102,241,0.35); }

.btn-success { background: #10b981; color: #fff; }
.btn-success:hover { background: #059669; }

.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }

.btn-secondary { background: #64748b; color: #fff; }
.btn-secondary:hover { background: #475569; }

.btn-outline {
    background: transparent; color: #64748b;
    border: 1.5px solid #d1d5db;
}
.btn-outline:hover { background: #f8fafc; border-color: #94a3b8; color: #334155; }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn-xs { padding: 0.3rem 0.6rem; font-size: 0.72rem; border-radius: 6px; }

/* ── Forms ────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-label {
    display: block; margin-bottom: 0.35rem;
    font-size: 0.82rem; font-weight: 600; color: #475569;
}
.form-control, .form-select {
    width: 100%; padding: 0.6rem 0.85rem;
    border: 1.5px solid #d1d5db; border-radius: 8px;
    font-size: 0.88rem; font-family: inherit;
    background: #fff; color: #1e2330;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus, .form-select:focus {
    outline: none; border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.form-select { cursor: pointer; }

/* ── Tables ───────────────────────────────────────────── */
.table {
    width: 100%; border-collapse: collapse;
}
.table th, .table td {
    padding: 0.7rem 0.85rem;
    text-align: left; font-size: 0.88rem;
    border-bottom: 1px solid #eef1f6;
}
.table th {
    font-weight: 600; color: #475569;
    font-size: 0.78rem; text-transform: uppercase;
    letter-spacing: 0.5px; background: #f8fafc;
}
.table th:first-child { border-radius: 8px 0 0 0; }
.table th:last-child { border-radius: 0 8px 0 0; }
.table tbody tr { transition: background 0.15s; }
.table tbody tr:hover { background: #f8fafc; }

/* ── Badges ───────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center;
    padding: 0.2rem 0.55rem; font-size: 0.72rem;
    font-weight: 600; border-radius: 6px; letter-spacing: 0.2px;
}
.badge-success { background: #ecfdf5; color: #065f46; }
.badge-danger  { background: #fef2f2; color: #991b1b; }
.badge-warning { background: #fffbeb; color: #92400e; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-info    { background: #eff6ff; color: #1e40af; }

/* ── Alerts ───────────────────────────────────────────── */
.alert {
    padding: 0.85rem 1rem; margin-bottom: 1rem;
    border-radius: 8px; font-size: 0.88rem; font-weight: 500;
    border-left: 4px solid transparent;
}
.alert-success { background: #ecfdf5; border-color: #10b981; color: #065f46; }
.alert-danger  { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
.alert-info    { background: #eff6ff; border-color: #3b82f6; color: #1e40af; }

/* ── Stats & Grids ────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
    background: #fff; border: 1px solid #e8ecf2; border-radius: 12px;
    padding: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s, transform 0.2s;
}
.stat-card:hover { box-shadow: 0 6px 16px rgba(0,0,0,0.06); transform: translateY(-2px); }
.stat-number {
    font-size: 1.75rem; font-weight: 800; color: #6366f1; margin-bottom: 0.25rem; line-height: 1.2;
}
.stat-label {
    font-size: 0.78rem; color: #64748b; text-transform: uppercase;
    letter-spacing: 0.5px; font-weight: 600;
}

/* Grid helpers */
.row { display: flex; flex-wrap: wrap; margin: -8px; }
.col { flex: 1; padding: 8px; }
.col-md-6 { flex: 0 0 50%; max-width: 50%; padding: 8px; }
.col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; padding: 8px; }
.col-md-3 { flex: 0 0 25%; max-width: 25%; padding: 8px; }

/* ── Modal ────────────────────────────────────────────── */
.modal {
    display: none; position: fixed; z-index: 2000;
    inset: 0; background: rgba(15,21,36,0.5);
    backdrop-filter: blur(4px);
}
.modal-content {
    background: #fff; margin: 4vh auto; padding: 1.8rem;
    border-radius: 14px; width: 92%; max-width: 520px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.modal-title { font-size: 1.15rem; font-weight: 700; color: #1e2330; }
.close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #94a3b8; line-height: 1; padding: 2px; }
.close:hover { color: #1e2330; }

/* ── QR Code ──────────────────────────────────────────── */
.qr-container { text-align: center; padding: 1.5rem; }
.qr-code { max-width: 280px; margin: 0 auto; border: 1px solid #e8ecf2; border-radius: 10px; }

/* ── Loading ──────────────────────────────────────────── */
.loading {
    display: inline-block; width: 20px; height: 20px;
    border: 2.5px solid #e8ecf2; border-top-color: #6366f1;
    border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Animations ───────────────────────────────────────── */
@keyframes fadeIn { from { opacity:0; transform: translateY(12px); } to { opacity:1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.35s ease-out; }

/* ── Utilities ────────────────────────────────────────── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.d-none   { display: none; }
.d-block  { display: block; }
.d-flex   { display: flex; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.w-100    { width: 100%; }
.gap-1    { gap: 0.5rem; }
.gap-2    { gap: 1rem; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.2); }
    .sidebar-close { display: flex; }
    .mobile-header { display: flex; }
    .main-content { margin-left: 0; padding: 1.25rem; padding-top: calc(56px + 1.25rem); }

    .col-md-6, .col-md-4, .col-md-3 { flex: 0 0 100%; max-width: 100%; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .modal-content { width: 96%; margin: 2vh auto; }
}

@media (max-width: 640px) {
    html { font-size: 14px; }
    .main-content { padding: 1rem; padding-top: calc(56px + 1rem); }
    .stats-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header-actions { width: 100%; }
}

/* ── Legacy compat — remove old header ────────────────── */
.header { display: none !important; }
.nav-container, .nav-menu, .user-menu, .menu-toggle-checkbox, .menu-toggle-label,
.btn-logout { /* Hidden by sidebar - won't break old markup */ }