/* ============================================================
   HRMS Transfer Allocation System — Design System (style.css)
   Premium, Compact, Government-Grade Dashboard
   ============================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
    /* Primary Palette */
    --primary-900: #1e1b4b;
    --primary-800: #272467;
    --primary-700: #312e81;
    --primary-600: #4338ca;
    --primary-500: #6366f1;
    --primary-400: #818cf8;
    --primary-300: #a5b4fc;
    --primary-200: #c7d2fe;
    --primary-100: #e0e7ff;
    --primary-50:  #eef2ff;

    /* Neutral Palette */
    --slate-950: #020617;
    --slate-900: #0f172a;
    --slate-800: #1e293b;
    --slate-700: #334155;
    --slate-600: #475569;
    --slate-500: #64748b;
    --slate-400: #94a3b8;
    --slate-300: #cbd5e1;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --slate-50:  #f8fafc;

    /* Accent Colours */
    --emerald-600: #059669;
    --emerald-100: #d1fae5;
    --emerald-50:  #ecfdf5;
    --amber-700:   #b45309;
    --amber-100:   #fef3c7;
    --amber-50:    #fffbeb;
    --rose-600:    #e11d48;
    --rose-100:    #ffe4e6;
    --teal-700:    #0f766e;
    --teal-100:    #ccfbf1;
    --teal-50:     #f0fdfa;

    /* Layout */
    --header-height: 60px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.08), 0 8px 10px -6px rgba(0,0,0,.04);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--slate-100);
    color: var(--slate-800);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

.ml-text {
    font-family: 'Manjari', 'Noto Sans Malayalam', sans-serif;
}

/* ---------- Gradient Background ---------- */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99,102,241,.08), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(139,92,246,.06), transparent),
        var(--slate-100);
}

/* ---------- Top Navigation ---------- */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 24px;
    background: rgba(255,255,255,.72);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--slate-200);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-brand-icon {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary-600), var(--primary-800));
    color: #fff;
    flex-shrink: 0;
}

.nav-brand-icon svg { width: 16px; height: 16px; }

.nav-brand h1 {
    font-size: .9rem;
    font-weight: 700;
    color: var(--slate-900);
    letter-spacing: -.02em;
}

.nav-brand small {
    display: block;
    font-size: .65rem;
    font-weight: 500;
    color: var(--slate-400);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-top: 1px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    font-size: .75rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all .2s cubic-bezier(.4,0,.2,1);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
    color: #fff;
    box-shadow: 0 1px 3px rgba(67,56,202,.3), 0 1px 2px rgba(67,56,202,.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
    box-shadow: 0 4px 12px rgba(67,56,202,.35);
    transform: translateY(-1px);
}

.btn-ghost {
    background: rgba(255,255,255,.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,.2);
    backdrop-filter: blur(8px);
}

.btn-ghost:hover {
    background: rgba(255,255,255,.25);
}

/* ---------- Main Content ---------- */
.main-content {
    padding: 20px 24px 32px;
    max-width: 100%;
}

/* ---------- Card ---------- */
.card {
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--slate-200);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

/* ---------- Results Header Banner ---------- */
.results-banner {
    background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-900) 60%, #1a103d 100%);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.results-banner h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
}

.results-banner p {
    font-size: .7rem;
    color: var(--primary-300);
    margin-top: 2px;
    font-weight: 500;
}

/* ---------- Summary Stat Cards ---------- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--slate-100);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid;
}

.stat-card.green  { background: var(--emerald-50); border-color: #bbf7d0; }
.stat-card.orange { background: var(--amber-50);   border-color: #fde68a; }
.stat-card.blue   { background: var(--primary-50); border-color: var(--primary-200); }

.stat-icon {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.stat-card.green  .stat-icon { background: #bbf7d0; color: var(--emerald-600); }
.stat-card.orange .stat-icon { background: #fde68a; color: var(--amber-700); }
.stat-card.blue   .stat-icon { background: var(--primary-200); color: var(--primary-600); }

.stat-icon svg { width: 16px; height: 16px; }

.stat-label {
    font-size: .65rem;
    color: var(--slate-500);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--slate-800);
    line-height: 1.2;
}

/* ---------- Table Wrapper ---------- */
.table-wrap {
    overflow: auto;
    max-height: calc(100vh - 140px);
}

.table-wrap-results {
    overflow: auto;
    max-height: 60vh;
}

/* Custom Scrollbar */
.table-wrap::-webkit-scrollbar,
.table-wrap-results::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.table-wrap::-webkit-scrollbar-thumb,
.table-wrap-results::-webkit-scrollbar-thumb {
    background: var(--slate-300);
    border-radius: 3px;
}
.table-wrap::-webkit-scrollbar-thumb:hover,
.table-wrap-results::-webkit-scrollbar-thumb:hover {
    background: var(--slate-400);
}
.table-wrap::-webkit-scrollbar-track,
.table-wrap-results::-webkit-scrollbar-track {
    background: var(--slate-50);
}

/* ---------- Data Table ---------- */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .95rem;
}

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--slate-50);
    padding: 12px 14px;
    text-align: left;
    font-size: .8rem;
    font-weight: 700;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 2px solid var(--slate-200);
    user-select: none;
}

.data-table thead th.center { text-align: center; }

.data-table tbody tr {
    transition: background .15s ease;
}

.data-table tbody tr:hover {
    background: var(--primary-50);
}

.data-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--slate-100);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Row variants */
.data-table tbody tr.row-election { background: rgba(251,191,36,.04); }
.data-table tbody tr.row-election:hover { background: rgba(251,191,36,.09); }
.data-table tbody tr.row-realloc { background: rgba(100,116,139,.03); }
.data-table tbody tr.row-realloc:hover { background: rgba(100,116,139,.07); }
.data-table tbody tr.row-success { background: rgba(5,150,105,.03); }
.data-table tbody tr.row-success:hover { background: rgba(5,150,105,.07); }
.data-table tbody tr.row-waiting { background: rgba(245,158,11,.03); }
.data-table tbody tr.row-waiting:hover { background: rgba(245,158,11,.07); }

/* ---------- Cell Helpers ---------- */
.cell-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: var(--slate-100);
    color: var(--slate-500);
    font-size: .8rem;
    font-weight: 700;
}

.cell-name {
    font-weight: 700;
    color: var(--slate-900);
    font-size: 1rem;
}

.cell-sub {
    display: block;
    font-size: .8rem;
    color: var(--slate-500);
    font-weight: 500;
    margin-top: 2px;
}

.cell-district {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: .85rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: var(--primary-50);
    color: var(--primary-700);
    border: 1px solid var(--primary-100);
    white-space: nowrap;
}

.cell-district-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary-500);
    flex-shrink: 0;
}

.cell-seniority {
    text-align: center;
    font-weight: 800;
    color: var(--primary-600);
    font-size: 1rem;
}

.cell-posn {
    display: block;
    text-align: center;
    font-size: .75rem;
    font-weight: 600;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-top: 2px;
}

.cell-muted { color: var(--slate-500); }

.cell-bold { font-weight: 700; color: var(--slate-800); }

.cell-allocated {
    font-weight: 700;
    color: var(--primary-600);
}

.cell-waiting {
    color: var(--slate-400);
    font-style: italic;
}

.cell-from {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--slate-500);
}

.cell-from-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--slate-300);
    flex-shrink: 0;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: .75rem;
    font-weight: 700;
    border-radius: 4px;
    letter-spacing: .02em;
    white-space: nowrap;
    border: 1px solid transparent;
    line-height: 1.5;
}

.badge svg { width: 12px; height: 12px; flex-shrink: 0; }

.badge-election {
    background: var(--amber-100);
    color: var(--amber-700);
    border-color: #fde68a;
}

.badge-realloc {
    background: var(--slate-100);
    color: var(--slate-600);
    border-color: var(--slate-200);
}

.badge-general {
    background: var(--emerald-100);
    color: var(--emerald-600);
    border-color: #bbf7d0;
}

.badge-success {
    background: var(--emerald-100);
    color: var(--emerald-600);
    border-color: #bbf7d0;
}

.badge-waiting {
    background: var(--amber-100);
    color: var(--amber-700);
    border-color: #fde68a;
}

.badge-hold {
    background: var(--slate-100);
    color: var(--slate-600);
    border-color: var(--slate-200);
}

/* ---------- Options Tags ---------- */
.options-group {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    max-width: 260px;
}

.opt-tag {
    padding: 2px 8px;
    font-size: .75rem;
    font-weight: 500;
    border-radius: 4px;
    border: 1px solid var(--slate-200);
    background: #fff;
    color: var(--slate-700);
    white-space: nowrap;
}

.opt-tag.first {
    background: var(--teal-50);
    color: var(--teal-700);
    border-color: #99f6e4;
    font-weight: 700;
}

/* ---------- Election detail ---------- */
.election-detail {
    display: block;
    font-size: .75rem;
    color: var(--slate-500);
    margin-top: 4px;
    font-weight: 500;
}

/* ---------- Empty State ---------- */
.empty-state {
    padding: 48px 16px;
    text-align: center;
    color: var(--slate-400);
}

.empty-state svg {
    width: 40px;
    height: 40px;
    margin: 0 auto 8px;
    opacity: .25;
}

.empty-state p {
    font-size: .85rem;
    font-weight: 500;
}

/* ---------- Status Remark Pill (Result Table) ---------- */
.remark-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: .75rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    line-height: 1.4;
}

.remark-pill svg { width: 13px; height: 13px; flex-shrink: 0; }

.remark-pill.success {
    background: var(--emerald-50);
    color: var(--emerald-600);
    border-color: #a7f3d0;
}

.remark-pill.waiting {
    background: var(--amber-50);
    color: var(--amber-700);
    border-color: #fde68a;
}

.remark-pill.hold {
    background: var(--slate-50);
    color: var(--slate-500);
    border-color: var(--slate-200);
}

/* ---------- Fade-in animation ---------- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.card { animation: fadeUp .35s ease-out both; }
.stat-card:nth-child(1) { animation: fadeUp .3s ease-out .05s both; }
.stat-card:nth-child(2) { animation: fadeUp .3s ease-out .1s both; }
.stat-card:nth-child(3) { animation: fadeUp .3s ease-out .15s both; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    html { font-size: 13px; }
    .top-nav { padding: 0 16px; flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px; }
    .main-content { padding: 12px; }
    .results-banner { flex-direction: column; align-items: flex-start; }
    .stats-row { grid-template-columns: 1fr; }
}
