/* ==========================================================================
   HCIC Portal — Elite Design System & Visual Language
   Modern Institutional SaaS • Glassmorphism • Micro-interactions
   ========================================================================== */

/* ── Design Tokens & System Variables ────────────────────────────────────── */
:root {
    color-scheme: light;
    --color-primary: #4f46e5;
    --color-primary-light: #eef2ff;
    --color-primary-dark: #3730a3;
    --color-primary-hover: #4338ca;
    --color-primary-glow: rgba(99, 102, 241, 0.35);

    --color-sidebar: #0b1120;
    --color-sidebar-hover: #151e2e;
    --color-sidebar-active: rgba(99, 102, 241, 0.18);
    --color-sidebar-border: #6366f1;

    --color-text-primary: #0f172a;
    --color-text-secondary: #475569;
    --color-text-muted: #94a3b8;

    --color-border: #e2e8f0;
    --color-border-subtle: rgba(226, 232, 240, 0.7);
    --color-card-bg: #ffffff;
    --color-body-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-background: #f8fafc;

    --radius-xs: 0.25rem;
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.25rem;
    --radius-3xl: 1.5rem;

    --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -2px rgba(15, 23, 42, 0.04);
    --shadow-card: 0 1px 3px 0 rgba(15, 23, 42, 0.04), 0 4px 16px -4px rgba(15, 23, 42, 0.06);
    --shadow-float: 0 20px 40px -15px rgba(15, 23, 42, 0.18);
    --shadow-glow: 0 0 25px -4px rgba(99, 102, 241, 0.25);
}

/* ── Dark Theme Tokens ────────────────────────────────────────────────────── */
.dark {
    color-scheme: dark;
    --color-primary: #6366f1;
    --color-primary-light: #1e1b4b;
    --color-primary-dark: #4f46e5;
    --color-primary-hover: #818cf8;
    --color-primary-glow: rgba(99, 102, 241, 0.45);

    --color-sidebar: #060911;
    --color-sidebar-hover: #0f172a;
    --color-sidebar-active: rgba(99, 102, 241, 0.24);
    --color-sidebar-border: #818cf8;

    --color-text-primary: #f8fafc;
    --color-text-secondary: #94a3b8;
    --color-text-muted: #64748b;

    --color-border: #334155;
    --color-border-subtle: rgba(255, 255, 255, 0.07);
    --color-card-bg: #0f172a;
    --color-body-bg: #070a13;
    --color-surface: #0f172a;
    --color-background: #0b1120;

    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.5), 0 1px 2px -1px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 16px -2px rgba(0, 0, 0, 0.6), 0 2px 6px -2px rgba(0, 0, 0, 0.4);
    --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.05);
    --shadow-float: 0 25px 50px -12px rgba(0, 0, 0, 0.85);
    --shadow-glow: 0 0 30px -4px rgba(99, 102, 241, 0.35);
}

/* ── Foundational Typography & Rendering ─────────────────────────────────── */
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    min-height: 100vh;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    background-color: var(--color-body-bg);
    background-image:
        radial-gradient(circle at 95% 5%, rgba(99, 102, 241, 0.07), transparent 32rem),
        radial-gradient(circle at 5% 95%, rgba(14, 165, 233, 0.05), transparent 30rem);
    background-attachment: fixed;
}

.dark body {
    background-color: var(--color-body-bg);
    background-image:
        radial-gradient(circle at 95% 5%, rgba(99, 102, 241, 0.12), transparent 36rem),
        radial-gradient(circle at 5% 95%, rgba(14, 165, 233, 0.06), transparent 32rem);
}

::selection {
    color: #ffffff;
    background: #4f46e5;
}

.dark ::selection {
    color: #ffffff;
    background: #6366f1;
}

:focus-visible {
    outline: 2px solid rgba(99, 102, 241, 0.6);
    outline-offset: 2px;
}

.skip-link {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 100;
    padding: 0.75rem 1.25rem;
    font-weight: 700;
    font-size: 0.875rem;
    color: #fff;
    background: var(--color-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-float);
    transform: translateY(-200%);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.skip-link:focus {
    transform: translateY(0);
}

/* ── Modern Glassmorphism Surfaces ───────────────────────────────────────── */
.glass-panel {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.dark .glass-panel {
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.glass-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(226, 232, 240, 0.75);
    box-shadow: var(--shadow-card);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.dark .glass-card {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow-card);
}

.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(99, 102, 241, 0.35);
}

/* ── App Navigation Layout (Sidebar & Topbar) ────────────────────────────── */
.app-sidebar {
    background: linear-gradient(180deg, #090e1a 0%, #070b14 55%, #04060b 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 4px 0 24px -4px rgba(0, 0, 0, 0.35);
}

.sidebar-link {
    position: relative;
    isolation: isolate;
    transition: all 0.15s ease;
}

.sidebar-link::before {
    position: absolute;
    inset: 0;
    z-index: -1;
    content: '';
    border-radius: inherit;
    opacity: 0;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0.04) 100%);
    transition: opacity 0.18s ease;
}

.sidebar-link:hover::before {
    opacity: 1;
}

.sidebar-link.is-active,
.sidebar-link.active {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
    color: #ffffff !important;
    font-weight: 600;
    box-shadow: 0 8px 20px -6px rgba(99, 102, 241, 0.6);
}

.sidebar-link.is-active svg,
.sidebar-link.active svg {
    color: #ffffff !important;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.app-topbar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 4px 20px -8px rgba(15, 23, 42, 0.05);
}

.dark .app-topbar {
    background: rgba(11, 17, 32, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 4px 24px -8px rgba(0, 0, 0, 0.4);
}

.topbar-action {
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.topbar-action:hover {
    transform: translateY(-1px);
}

.topbar-action:active {
    transform: translateY(0) scale(0.96);
}

/* ── Cards & Surfaces ─────────────────────────────────────────────────────── */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-2xl);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.22s ease, transform 0.22s ease, border-color 0.22s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card:focus-within {
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12), var(--shadow-card);
}

/* ── Interactive Buttons ──────────────────────────────────────────────────── */
.btn,
.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger,
.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem 1.15rem;
    border-radius: var(--radius-xl);
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid transparent;
    text-decoration: none;
    user-select: none;
    white-space: nowrap;
}

.btn:active,
.btn-primary:active,
.btn-secondary:active,
.btn-success:active,
.btn-danger:active {
    transform: translateY(0) scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 14px -2px rgba(79, 70, 229, 0.4);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    box-shadow: 0 8px 20px -4px rgba(79, 70, 229, 0.55);
    transform: translateY(-1.5px);
    color: #ffffff;
}

.btn-secondary {
    background-color: var(--color-surface);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
    background-color: var(--color-background);
    border-color: rgba(99, 102, 241, 0.3);
    color: var(--color-primary);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px -2px rgba(16, 185, 129, 0.4);
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 8px 20px -4px rgba(16, 185, 129, 0.55);
    transform: translateY(-1.5px);
}

.btn-danger {
    background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px -2px rgba(244, 63, 94, 0.4);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
    box-shadow: 0 8px 20px -4px rgba(244, 63, 94, 0.55);
    transform: translateY(-1.5px);
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.775rem;
    border-radius: var(--radius-lg);
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: var(--radius-2xl);
}

/* ── Form Inputs & Controls ──────────────────────────────────────────────── */
.form-input {
    width: 100%;
    padding: 0.65rem 0.95rem;
    border: 1px solid var(--color-border);
    background-color: var(--color-surface);
    color: var(--color-text-primary);
    border-radius: var(--radius-xl);
    font-size: 0.875rem;
    outline: none;
    box-shadow: var(--shadow-xs);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.dark .form-input {
    background-color: #0c1220;
    border-color: #273449;
    color: #f8fafc;
}

.form-input::placeholder {
    color: #94a3b8;
}

.dark .form-input::placeholder {
    color: #64748b;
}

select option {
    background-color: #ffffff;
    color: #0f172a;
}

.dark select option {
    background-color: #0f172a;
    color: #f8fafc;
}

.form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.22);
    background-color: var(--color-surface);
}

.dark .form-input:focus {
    background-color: #0c1220;
    border-color: var(--color-primary);
}

.form-label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
}

/* ── Modern Badges & Pills ───────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.725rem;
    font-weight: 700;
    letter-spacing: 0.025em;
    border: 1px solid transparent;
}

.badge-success {
    background-color: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}
.dark .badge-success {
    background-color: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.3);
}

.badge-warning {
    background-color: #fffbeb;
    color: #b45309;
    border-color: #fde68a;
}
.dark .badge-warning {
    background-color: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.3);
}

.badge-danger {
    background-color: #fff1f2;
    color: #be123c;
    border-color: #fecdd3;
}
.dark .badge-danger {
    background-color: rgba(244, 63, 94, 0.15);
    color: #fb7185;
    border-color: rgba(244, 63, 94, 0.3);
}

.badge-info,
.badge-brand {
    background-color: #eef2ff;
    color: #4338ca;
    border-color: #c7d2fe;
}
.dark .badge-info,
.dark .badge-brand {
    background-color: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border-color: rgba(99, 102, 241, 0.3);
}

.badge-neutral {
    background-color: #f1f5f9;
    color: #475569;
    border-color: #e2e8f0;
}
.dark .badge-neutral {
    background-color: #1e293b;
    color: #cbd5e1;
    border-color: #334155;
}

/* ── Modern Data Tables ──────────────────────────────────────────────────── */
.data-table-container {
    overflow-x: auto;
    border-radius: var(--radius-2xl);
    border: 1px solid var(--color-border);
    background-color: var(--color-surface);
    box-shadow: var(--shadow-card);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    text-align: left;
    padding: 0.85rem 1.15rem;
    font-size: 0.725rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    background-color: rgba(248, 250, 252, 0.85);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.dark .data-table th {
    background-color: rgba(15, 23, 42, 0.9);
}

.data-table td {
    padding: 0.95rem 1.15rem;
    font-size: 0.875rem;
    color: var(--color-text-primary);
    border-bottom: 1px solid var(--color-border-subtle);
    transition: background-color 0.15s ease;
}

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

.data-table tbody tr:hover td {
    background-color: rgba(99, 102, 241, 0.04);
}

.dark .data-table tbody tr:hover td {
    background-color: rgba(99, 102, 241, 0.08);
}

/* ── Progress Indicators ─────────────────────────────────────────────────── */
.progress-bar {
    width: 100%;
    height: 0.5rem;
    background-color: var(--color-border);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 9999px;
    background: linear-gradient(90deg, #6366f1 0%, #4f46e5 100%);
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Status Dots ─────────────────────────────────────────────────────────── */
.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 9999px;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot-active {
    background-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.status-dot-pending {
    background-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

/* ── Custom Sleek Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 9999px;
}

.dark ::-webkit-scrollbar-thumb {
    background-color: #334155;
}

::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background-color: #475569;
}

/* ── Modals & Overlays ───────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(7, 10, 19, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 50;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease-out;
}

.modal-overlay.active {
    display: flex;
}

/* ── Responsive Polish ───────────────────────────────────────────────────── */
@media (max-width: 639px) {
    .data-table th,
    .data-table td {
        padding: 0.75rem 0.85rem;
        white-space: nowrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
