/* ==========================================================
   FamAPI — shared design system (v2)
   Clean, light, card-based UI. Included by every page.
   Palette inspired by common clean SaaS dashboards:
   navy sidebar + white content + blue accent + soft shadows.
   ========================================================== */

:root {
    --navy: #0f172a;
    --navy-soft: #1a2540;
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --blue-soft: #eff4ff;
    --green: #16a34a;
    --green-soft: #ecfdf3;
    --amber: #d97706;
    --amber-soft: #fffaeb;
    --red: #dc2626;
    --red-soft: #fef2f2;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-700: #334155;
    --gray-900: #0f172a;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
    --shadow-md: 0 4px 14px rgba(15,23,42,0.08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; }

/* ---------- App shell: sidebar + content ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: var(--navy);
    color: #cbd5e1;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 40;
}
.sidebar-logo {
    display: flex; align-items: center; gap: 8px;
    padding: 20px 22px; font-size: 18px; font-weight: 800; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-logo .accent { color: #60a5fa; }
.sidebar-close {
    display: none;
    margin-left: auto;
    background: rgba(255,255,255,0.08);
    border: none; color: #fff; width: 30px; height: 30px; border-radius: 8px;
    font-size: 16px; cursor: pointer;
}
.sidebar-section-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
    color: #64748b; padding: 18px 22px 6px;
}
.sidebar-link {
    display: flex; align-items: center; gap: 11px;
    padding: 11px 22px; margin: 2px 10px; border-radius: 10px;
    color: #cbd5e1; font-size: 14px; font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-link.active { background: var(--blue); color: #fff; }
.sidebar-link .ico { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer {
    margin-top: auto; padding: 16px 22px; border-top: 1px solid rgba(255,255,255,0.06);
    display: flex; align-items: center; gap: 10px;
}
.sidebar-avatar {
    width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
    background: #334155; flex-shrink: 0; display:flex; align-items:center; justify-content:center;
    color:#fff; font-weight:700; font-size:14px;
}
.sidebar-user-name { font-size: 13px; font-weight: 700; color: #fff; }
.sidebar-user-email { font-size: 11px; color: #64748b; max-width:140px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sidebar-signout { display:block; margin-top: 10px; font-size: 12px; color: #f87171; font-weight: 600; }

/* Mobile topbar (hamburger) */
.mobile-topbar {
    display: none;
    align-items: center; justify-content: space-between;
    background: var(--navy); color: #fff;
    padding: 14px 18px; position: sticky; top: 0; z-index: 30;
}
.mobile-topbar .sidebar-logo { padding: 0; border: none; }
.hamburger-btn {
    background: rgba(255,255,255,0.08); border: none; color: #fff;
    width: 38px; height: 38px; border-radius: 10px; font-size: 18px; cursor: pointer;
}
.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 35;
}
.sidebar-overlay.active { display: block; }

@media (max-width: 900px) {
    .mobile-topbar { display: flex; }
    .sidebar {
        position: fixed; left: 0; top: 0; height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: 260px;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: block; }
}

.main-content { flex: 1; min-width: 0; padding: 30px 32px; max-width: 1200px; }
@media (max-width: 700px) { .main-content { padding: 18px 16px 40px; } }

.page-title { font-size: 22px; font-weight: 800; margin: 0 0 4px; }
.page-sub { font-size: 13.5px; color: var(--gray-500); margin: 0 0 24px; }

/* ---------- Cards & stat tiles ---------- */
.card {
    background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 18px;
}
.card-title { font-size: 15.5px; font-weight: 700; margin: 0 0 4px; display:flex; align-items:center; gap:8px; }
.card-sub { font-size: 13px; color: var(--gray-500); margin: 0 0 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
    background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
    padding: 18px 20px; box-shadow: var(--shadow); position: relative;
}
.stat-card.highlight {
    background: linear-gradient(135deg, var(--blue), var(--blue-dark)); color: #fff; border: none;
}
.stat-card.highlight .stat-label { color: rgba(255,255,255,0.75); }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--gray-500); font-weight: 700; }
.stat-value { font-size: 26px; font-weight: 800; margin-top: 8px; }
.stat-icon-badge {
    position: absolute; top: 16px; right: 16px;
    width: 34px; height: 34px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: 15px;
    background: var(--blue-soft); color: var(--blue);
}
.stat-card.highlight .stat-icon-badge { background: rgba(255,255,255,0.15); color: #fff; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 11px 18px; border-radius: 10px; border: none; cursor: pointer;
    font-weight: 700; font-size: 13.5px; text-decoration: none; transition: all 0.15s;
    font-family: inherit;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-outline { background: #fff; border: 1px solid var(--gray-200); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-50); }
.btn-danger { background: #fff; border: 1px solid #fecaca; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin: 14px 0 6px; }
label:first-child { margin-top: 0; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
    width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--gray-200);
    background: #fff; font-size: 14px; color: var(--gray-900); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
input::placeholder { color: var(--gray-400); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th {
    text-align: left; padding: 10px 14px; color: var(--gray-500);
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid var(--gray-200); white-space: nowrap;
}
table.data-table td { padding: 13px 14px; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: var(--gray-50); }

/* ---------- Badges / pills ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 11px; border-radius: 20px; font-size: 11.5px; font-weight: 700;
}
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }

/* ---------- Alerts / messages ---------- */
.alert { padding: 13px 16px; border-radius: 10px; font-size: 13.5px; margin-bottom: 18px; font-weight: 500; }
.alert-success { background: var(--green-soft); color: var(--green); }
.alert-error { background: var(--red-soft); color: var(--red); }
.alert-info { background: var(--blue-soft); color: var(--blue); }

/* ---------- Misc utility ---------- */
.text-muted { color: var(--gray-500); }
.mono { font-family: 'SF Mono', 'Consolas', monospace; font-size: 13px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
