/* 
 * ATS Cloud Platform - Modern SaaS Design System (Light Theme)
 * Typography: Space Grotesk (Headings) & Inter (Body)
 * Palette: Slate-50 base, Crisp White Cards, Indigo & Sky Blue Accents, Emerald & Amber Semantics
 */

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

/* ============== Design Tokens & CSS Variables ============== */
:root {
    /* Base & Surfaces */
    --white: #ffffff;
    --bg-page: #f8fafc;
    --bg-soft: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-subtle: #f8fafc;
    --surface-glass: rgba(255, 255, 255, 0.94);
    
    /* Slate Grays */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Brand Accents */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --primary-glow: rgba(79, 70, 229, 0.2);

    --accent-sky: #0284c7;
    --accent-sky-light: #e0f2fe;

    --violet: #7c3aed;
    --violet-light: #f5f3ff;

    /* Semantic States */
    --green: #10b981;
    --green-dark: #059669;
    --green-light: #d1fae5;
    --green-text: #065f46;

    --yellow: #f59e0b;
    --yellow-dark: #d97706;
    --yellow-light: #fef3c7;
    --yellow-text: #92400e;

    --red: #ef4444;
    --red-dark: #dc2626;
    --red-light: #fee2e2;
    --red-text: #991b1b;

    --blue: #3b82f6;
    --blue-dark: #2563eb;
    --blue-light: #dbeafe;
    --blue-text: #1e40af;

    --success: var(--green);
    --warning: var(--yellow);
    --danger: var(--red);

    /* Gradients */
    --gradient-brand: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #0284c7 100%);
    --gradient-sky: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
    --gradient-card: linear-gradient(180deg, #ffffff 0%, #fcfdfe 100%);

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Radii & Borders */
    --border-radius-sm: 8px;
    --border-radius: 14px;
    --border-radius-lg: 20px;
    --border-radius-full: 9999px;
    --border-color: #e2e8f0;
    --border-color-hover: #cbd5e1;
    --border-width: 1px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 20px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
    --shadow-hover: 0 14px 32px rgba(15, 23, 42, 0.09), 0 2px 6px rgba(15, 23, 42, 0.04);
    --shadow-modal: 0 25px 70px rgba(15, 23, 42, 0.2), 0 4px 14px rgba(15, 23, 42, 0.06);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-page);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-soft);
}
::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* ============== Typography ============== */
h1, h2, h3, h4, h5, h6, .brand-font {
    font-family: 'Space Grotesk', -apple-system, sans-serif;
    font-weight: 700;
    line-height: 1.25;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

h1 { font-size: 1.85rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }

p {
    margin-bottom: var(--space-md);
    color: var(--gray-600);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}
a:hover {
    color: var(--primary-hover);
    text-decoration: none;
}

/* ============== Layout Structure ============== */
.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.layout-with-sidebar {
    display: flex;
    flex: 1;
    margin-top: 76px; /* Navbar height */
}

.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.main-content {
    flex: 1;
    padding: var(--space-xl);
    margin-left: 260px; /* Sidebar width */
    max-width: calc(100vw - 260px);
    transition: all 0.3s ease;
}

@media (max-width: 900px) {
    .main-content {
        margin-left: 0;
        max-width: 100%;
        padding: var(--space-md);
    }
}

/* ============== Top Navigation Bar ============== */
.navbar {
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    padding: 0 var(--space-xl);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 76px;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.03);
}

.navbar-brand {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-brand img {
    height: 42px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(79, 70, 229, 0.15));
}

.navbar-nav {
    display: flex;
    gap: var(--space-md);
    align-items: center;
}

.nav-link {
    color: var(--gray-600);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 16px;
    border-radius: var(--border-radius-full);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.nav-link:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.nav-link.active {
    color: var(--primary);
    background: var(--primary-light);
    border-color: rgba(79, 70, 229, 0.2);
}

.user-menu {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--gray-100);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-full);
    color: var(--gray-800);
    font-weight: 600;
    font-size: 0.85rem;
}

.user-menu .material-icons {
    font-size: 1.15rem;
    color: var(--primary);
}

/* ============== Sidebar Navigation ============== */
.sidebar {
    width: 260px;
    background: var(--white);
    border-right: 1px solid var(--border-color);
    padding: var(--space-lg) var(--space-md);
    position: fixed;
    top: 76px;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 90;
    display: flex;
    flex-direction: column;
}

@media (max-width: 900px) {
    .sidebar {
        display: none; /* Can be toggled on mobile */
    }
}

.sidebar-nav {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    color: var(--gray-600);
    font-weight: 600;
    font-size: 0.92rem;
    border-radius: var(--border-radius);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid transparent;
}

.sidebar-link .material-icons {
    font-size: 1.3rem;
    color: var(--gray-400);
    transition: color 0.2s;
}

.sidebar-link:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.sidebar-link:hover .material-icons {
    color: var(--primary);
}

.sidebar-link.active {
    background: var(--primary-light);
    color: var(--primary);
    border-color: rgba(79, 70, 229, 0.15);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.08);
}

.sidebar-link.active .material-icons {
    color: var(--primary);
}

/* ============== Cards & Widgets ============== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--space-xl);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-md);
    transition: all 0.25s ease;
    position: relative;
}

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============== Modern Stats Grid ============== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 22px 24px;
    box-shadow: var(--shadow-md);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary);
}

.stat-card.border-blue { border-left: 4px solid var(--primary); }
.stat-card.border-green { border-left: 4px solid var(--green); }
.stat-card.border-yellow { border-left: 4px solid var(--yellow); }
.stat-card.border-red { border-left: 4px solid var(--red); }

.stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1.15;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

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

/* ============== Buttons ============== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--border-radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.3;
}

.btn .material-icons {
    font-size: 1.15rem;
    line-height: 1;
}

.btn-primary {
    background: var(--gradient-brand);
    color: var(--white);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.35);
    color: var(--white);
}

.btn-success {
    background: var(--green);
    color: var(--white);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}
.btn-success:hover {
    background: var(--green-dark);
    transform: translateY(-1px);
    color: var(--white);
}

.btn-warning {
    background: var(--yellow-light);
    color: var(--yellow-text);
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.btn-warning:hover {
    background: #fde68a;
    color: #78350f;
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--red);
    color: var(--white);
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.25);
}
.btn-danger:hover {
    background: var(--red-dark);
    transform: translateY(-1px);
    color: var(--white);
}

.btn-outline {
    background: var(--white);
    border-color: var(--border-color);
    color: var(--gray-700);
    box-shadow: var(--shadow-xs);
}
.btn-outline:hover {
    background: var(--gray-100);
    border-color: var(--border-color-hover);
    color: var(--gray-900);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
}
.btn-sm .material-icons { font-size: 1rem; }

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
    border-radius: 12px;
}

/* ============== Forms & Inputs ============== */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gray-800);
}

.form-control {
    width: 100%;
    padding: 11px 16px;
    font-size: 0.95rem;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--white);
    color: var(--gray-900);
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--white);
}

.form-control::placeholder {
    color: var(--gray-400);
}

.form-hint {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 6px;
}

/* ============== Tables ============== */
.table-container {
    overflow-x: auto;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background: var(--white);
    box-shadow: var(--shadow-xs);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    text-align: left;
}

.table th {
    padding: 14px 18px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-soft);
    color: var(--gray-700);
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    color: var(--gray-700);
    vertical-align: middle;
}

.table tbody tr {
    transition: background-color 0.15s ease;
}

.table tbody tr:hover {
    background-color: #f8fafc;
}

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

/* ============== Badges ============== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: var(--border-radius-full);
    line-height: 1.2;
    letter-spacing: 0.02em;
}

.badge-success {
    background: var(--green-light);
    color: var(--green-text);
}

.badge-warning {
    background: var(--yellow-light);
    color: var(--yellow-text);
}

.badge-danger {
    background: var(--red-light);
    color: var(--red-text);
}

.badge-info {
    background: var(--accent-sky-light);
    color: var(--accent-sky);
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

/* ============== Alerts ============== */
.alert {
    padding: 14px 18px;
    border-radius: var(--border-radius-sm);
    margin-bottom: var(--space-lg);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    line-height: 1.45;
}

.alert-error {
    background: var(--red-light);
    border: 1px solid #fca5a5;
    color: var(--red-text);
}

.alert-success {
    background: var(--green-light);
    border: 1px solid #86efac;
    color: var(--green-text);
}

.alert-warning {
    background: var(--yellow-light);
    border: 1px solid #fde68a;
    color: var(--yellow-text);
}

.alert-info {
    background: var(--accent-sky-light);
    border: 1px solid #7dd3fc;
    color: #075985;
}

/* ============== Modals & Overlays ============== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1050;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
    box-sizing: border-box;
}

.modal-overlay.active,
.modal-overlay.show {
    display: flex !important;
}

/* Modal dialog card inside .modal-overlay */
.modal-overlay .modal {
    display: flex !important;
    flex-direction: column;
    position: relative;
    inset: auto;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg, 16px);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1051;
    padding: 0;
    margin: auto;
}

/* Form container inside modal */
.modal-overlay .modal > form,
.modal > form,
.modal-content > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    overflow: hidden;
    margin: 0;
}

/* Direct .modal fallback when used as overlay without .modal-overlay */
.modal:not(.modal-overlay .modal) {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1050;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
    box-sizing: border-box;
}

.modal:not(.modal-overlay .modal).active,
.modal:not(.modal-overlay .modal).show {
    display: flex !important;
}

.modal:not(.modal-overlay .modal) .modal-content {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg, 16px);
    width: 100%;
    max-width: 540px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: #ffffff;
    flex-shrink: 0;
}

.modal-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
}

.close,
.modal-close {
    background: var(--gray-100);
    border: 1px solid var(--border-color);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    transition: all 0.2s ease;
    padding: 0;
}

.close:hover,
.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-900);
    transform: rotate(90deg);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1 1 auto;
    background: #ffffff;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--gray-50);
    flex-shrink: 0;
    margin: 0;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--gray-500);
    margin-top: 4px;
    line-height: 1.4;
}

/* ============== Utilities ============== */
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

.gap-1 { gap: var(--space-xs); }
.gap-2 { gap: var(--space-sm); }
.gap-3 { gap: var(--space-md); }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: var(--space-xs) !important; }
.mb-2 { margin-bottom: var(--space-sm) !important; }
.mb-3 { margin-bottom: var(--space-md) !important; }
.mb-4 { margin-bottom: var(--space-lg) !important; }
.mb-5 { margin-bottom: var(--space-xl) !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: var(--space-xs) !important; }
.mt-2 { margin-top: var(--space-sm) !important; }
.mt-3 { margin-top: var(--space-md) !important; }
.mt-4 { margin-top: var(--space-lg) !important; }

.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.text-muted { color: var(--gray-500) !important; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--green-dark) !important; }
.text-danger { color: var(--red-dark) !important; }
.text-warning { color: var(--yellow-dark) !important; }

.hidden { display: none !important; }

/* Loading Spinner */
.loading, .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(79, 70, 229, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }