/* ============================================================
   AMBIKA IMS — Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
    --primary:        #2563eb;
    --primary-dark:   #1d4ed8;
    --primary-light:  #eff6ff;
    --secondary:      #7c3aed;
    --accent:         #059669;
    --accent-light:   #ecfdf5;
    --danger:         #dc2626;
    --danger-light:   #fef2f2;
    --warning:        #d97706;
    --warning-light:  #fffbeb;
    --info:           #0891b2;
    --info-light:     #ecfeff;

    --bg:             #f1f5f9;
    --surface:        #ffffff;
    --surface-2:      #f8fafc;
    --border:         #e2e8f0;
    --border-2:       #cbd5e1;

    --text:           #0f172a;
    --text-2:         #475569;
    --text-3:         #94a3b8;
    --text-inv:       #ffffff;

    --sidebar-w:      260px;
    --header-h:       64px;
    --radius:         12px;
    --radius-sm:      8px;
    --radius-lg:      16px;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow:         0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg:      0 10px 25px rgba(0,0,0,.10), 0 4px 10px rgba(0,0,0,.07);
    --transition:     all .2s cubic-bezier(.4,0,.2,1);
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; display: block; }
input, select, textarea, button { font-family: inherit; }

/* ── Layout ────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ───────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 100;
    transition: var(--transition);
    overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

.sidebar-logo {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo img { width: 36px; height: 36px; border-radius: 8px; }
.sidebar-logo-text { line-height: 1.2; }
.sidebar-logo-text strong { display: block; font-size: 15px; font-weight: 700; color: #fff; }
.sidebar-logo-text span { font-size: 11px; color: #94a3b8; }

.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 20px;
    margin: 10px 12px;
    background: rgba(255,255,255,.05);
    border-radius: var(--radius-sm);
}
.sidebar-user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0;
}
.sidebar-user-info strong { display: block; font-size: 13px; font-weight: 600; color: #fff; }
.sidebar-user-info span { font-size: 11px; color: #64748b; text-transform: capitalize; }

.sidebar-section-title {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .08em;
    color: #475569;
    padding: 10px 20px 4px;
}

.sidebar-nav { flex: 1; padding: 8px 12px; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    color: #94a3b8;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-nav a.active { background: rgba(37,99,235,.25); color: #60a5fa; }
.sidebar-nav a svg, .sidebar-nav a i { width: 17px; height: 17px; flex-shrink: 0; }
.sidebar-nav .badge {
    margin-left: auto;
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-footer a {
    display: flex; align-items: center; gap: 10px;
    color: #64748b; padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: var(--transition);
}
.sidebar-footer a:hover { background: rgba(220,38,38,.15); color: #f87171; }

/* ── MAIN AREA ─────────────────────────────────────────────── */
.main-area {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── TOPBAR ────────────────────────────────────────────────── */
.topbar {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 18px; font-weight: 700; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-icon-btn {
    width: 38px; height: 38px;
    border: none; background: var(--bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-2);
    transition: var(--transition);
}
.topbar-icon-btn:hover { background: var(--border); color: var(--text); }

/* ── PAGE CONTENT ──────────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 800; }
.page-header p { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.breadcrumb { display: flex; gap: 6px; font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.breadcrumb span { color: var(--text-2); }

/* ── STAT CARDS ────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.blue::before  { background: linear-gradient(90deg, #2563eb, #60a5fa); }
.stat-card.green::before { background: linear-gradient(90deg, #059669, #34d399); }
.stat-card.purple::before{ background: linear-gradient(90deg, #7c3aed, #a78bfa); }
.stat-card.orange::before{ background: linear-gradient(90deg, #d97706, #fbbf24); }
.stat-card.red::before   { background: linear-gradient(90deg, #dc2626, #f87171); }
.stat-card.cyan::before  { background: linear-gradient(90deg, #0891b2, #22d3ee); }

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 14px;
    font-size: 20px;
}
.stat-card.blue   .stat-card-icon { background: #eff6ff; color: var(--primary); }
.stat-card.green  .stat-card-icon { background: #ecfdf5; color: var(--accent); }
.stat-card.purple .stat-card-icon { background: #f5f3ff; color: var(--secondary); }
.stat-card.orange .stat-card-icon { background: #fffbeb; color: var(--warning); }
.stat-card.red    .stat-card-icon { background: #fef2f2; color: var(--danger); }
.stat-card.cyan   .stat-card-icon { background: #ecfeff; color: var(--info); }

.stat-card-value  { font-size: 28px; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.stat-card-label  { font-size: 12px; font-weight: 500; color: var(--text-2); }
.stat-card-trend  { font-size: 11px; margin-top: 8px; font-weight: 600; }
.stat-card-trend.up   { color: var(--accent); }
.stat-card-trend.down { color: var(--danger); }

/* ── CARD ──────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 700; }
.card-body { padding: 20px; }
.card-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ── TABLE ─────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.table th {
    text-align: left;
    padding: 11px 16px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-2);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-2); }
.table-striped tr:nth-child(even) td { background: var(--surface-2); }

/* ── BADGES / STATUS ───────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-purple  { background: #f3e8ff; color: #6b21a8; }

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600; font-size: 13.5px;
    border: none; cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg, .btn i { width: 16px; height: 16px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.btn-success { background: var(--accent); color: #fff; }
.btn-success:hover { background: #047857; color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #b91c1c; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-outline-primary { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }

/* ── FORMS ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: 13px; font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
    width: 100%;
    padding: 9px 13px;
    border: 1.5px solid var(--border-2);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    transition: var(--transition);
    outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.form-control::placeholder { color: var(--text-3); }
.form-control:disabled { background: var(--surface-2); color: var(--text-2); }
select.form-control { cursor: pointer; }
textarea.form-control { min-height: 90px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-text { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* ── ALERTS ────────────────────────────────────────────────── */
.alert {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    margin-bottom: 16px;
    font-weight: 500;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── AVATAR ────────────────────────────────────────────────── */
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; color: #fff; font-size: 13px;
}
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.avatar-xl { width: 96px; height: 96px; font-size: 34px; }

/* ── MODAL ─────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
    z-index: 200;
    display: none; align-items: center; justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%; max-width: 560px;
    max-height: 90vh; overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn .2s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(-16px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex; gap: 10px; justify-content: flex-end;
    background: var(--surface-2);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.btn-close {
    background: none; border: none; cursor: pointer;
    color: var(--text-2); padding: 4px; border-radius: 4px;
    transition: var(--transition);
}
.btn-close:hover { background: var(--bg); color: var(--text); }

/* ── TABS ──────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
    padding: 10px 18px; border: none; background: none;
    font-size: 13.5px; font-weight: 600; color: var(--text-2);
    cursor: pointer; border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: var(--transition);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab-btn:hover { color: var(--primary); background: var(--primary-light); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── SEARCH BAR ────────────────────────────────────────────── */
.search-bar {
    position: relative; max-width: 320px;
}
.search-bar input {
    padding-left: 38px;
    background: var(--bg);
    border: 1.5px solid var(--border);
}
.search-icon {
    position: absolute; left: 11px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-3); width: 16px; height: 16px;
}

/* ── FILTER ROW ────────────────────────────────────────────── */
.filter-row {
    display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap; margin-bottom: 16px;
}
.filter-row select.form-control { width: auto; min-width: 150px; }

/* ── PAGINATION ────────────────────────────────────────────── */
.pagination {
    display: flex; align-items: center; gap: 4px;
    justify-content: center; padding-top: 16px;
}
.page-btn {
    width: 36px; height: 36px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-sm);
    cursor: pointer; font-size: 13px; font-weight: 600;
    transition: var(--transition);
    display: flex; align-items: center; justify-content: center;
}
.page-btn:hover, .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── PROGRESS BAR ──────────────────────────────────────────── */
.progress { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px; transition: width .6s ease; }
.progress-bar.green  { background: linear-gradient(90deg, #059669, #34d399); }
.progress-bar.blue   { background: linear-gradient(90deg, #2563eb, #60a5fa); }
.progress-bar.red    { background: linear-gradient(90deg, #dc2626, #f87171); }
.progress-bar.orange { background: linear-gradient(90deg, #d97706, #fbbf24); }

/* ── EMPTY STATE ───────────────────────────────────────────── */
.empty-state {
    text-align: center; padding: 60px 20px;
    color: var(--text-3);
}
.empty-state svg { width: 64px; height: 64px; margin: 0 auto 16px; opacity: .4; }
.empty-state h4 { font-size: 16px; color: var(--text-2); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ── PRINT SLIP ────────────────────────────────────────────── */
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-area { margin-left: 0; }
    .page-content { padding: 0; }
}

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
}

/* ── UTILITIES ─────────────────────────────────────────────── */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-2); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.rounded { border-radius: var(--radius-sm); }
.hidden { display: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
