@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Palette - Modern Indigo & Gray */
    --primary: #4F46E5;
    /* Indigo 600 */
    --primary-hover: #4338CA;
    /* Indigo 700 */
    --primary-light: #EEF2FF;
    /* Indigo 50 */

    --secondary: #64748B;
    /* Slate 500 */

    --success: #10B981;
    /* Emerald 500 */
    --success-bg: #D1FAE5;
    --success-text: #065F46;

    --danger: #EF4444;
    /* Red 500 */
    --danger-bg: #FEE2E2;
    --danger-text: #991B1B;

    --warning: #F59E0B;
    /* Amber 500 */
    --warning-bg: #FEF3C7;
    --warning-text: #92400E;

    --bg-body: #F3F4F6;
    /* Cool Gray 100 */
    --bg-surface: #FFFFFF;

    --text-main: #111827;
    /* Gray 900 */
    --text-muted: #6B7280;
    /* Gray 500 */
    --text-light: #9CA3AF;
    /* Gray 400 */

    --border: #E5E7EB;
    /* Gray 200 */

    --radius: 12px;
    --radius-sm: 6px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

input,
textarea {
    -webkit-user-select: text;
    user-select: text;
}

body {
    font-family: var(--font-sans);
    background-color: #F3F4F6;
    /* Explicit Light Background */
    color: #111827;
    /* Explicit Dark Text */
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

@media (prefers-color-scheme: dark) {
    body {
        background-color: #F3F4F6 !important;
        color: #111827 !important;
    }
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-hover);
}

/* Layout */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
.header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 1rem 0;
    margin-bottom: 2rem;
    /* backdrop-filter: blur(8px); */
    /* Optional glass effect */
    /* background: rgba(255, 255, 255, 0.95); */
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.025em;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.25;
    gap: 0.5rem;
}

.btn:active {
    transform: translateY(1px);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 1px 2px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: white;
    border-color: var(--border);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background-color: var(--bg-body);
    border-color: #D1D5DB;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #DC2626;
}

.btn-warning {
    background-color: var(--warning);
    color: white;
}

.btn-warning:hover {
    background-color: #D97706;
}


/* Cards */
.card {
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0, 0, 0, 0.02);
    margin-bottom: 2rem;
}

@media(max-width: 640px) {
    .card {
        padding: 1.5rem;
        border-radius: var(--radius);
        /* Keep consistent radius */
    }
}

/* Typography Helpers */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-main);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.text-muted {
    color: var(--text-muted);
}

.text-small {
    font-size: 0.875rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: white;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
    /* Normalize mobile input */
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

th,
td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background-color: var(--bg-body);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tr:last-child td {
    border-bottom: none;
}

/* Dashboard Specifics */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
}

.status-active {
    background-color: var(--success-bg);
    color: var(--success-text);
}

.status-inactive {
    background-color: var(--danger-bg);
    color: var(--danger-text);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Mobile Navigation */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-main);
    border-radius: var(--radius-sm);
}

.hamburger-btn:hover {
    background-color: var(--bg-body);
}

.mobile-menu,
.mobile-menu-overlay {
    display: none;
}

/* Auth Page Specifics */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-body) 0%, #E0E7FF 100%);
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 450px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-lg);
}

/* Mobile Specific Responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    .desktop-nav {
        display: none !important;
    }

    .hamburger-btn {
        display: block;
    }

    /* Overlay */
    .mobile-menu-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1000;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
        backdrop-filter: blur(2px);
    }

    .mobile-menu-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* Menu Drawer */
    .mobile-menu {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: -100%;
        /* Start hidden */
        width: 85%;
        max-width: 320px;
        height: 100vh;
        background: white;
        z-index: 1001;
        padding: 1.5rem;
        padding-top: calc(env(safe-area-inset-top) + 1.5rem);
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: -4px 0 25px rgba(0, 0, 0, 0.1);
    }

    .header {
        background-color: var(--bg-surface);
        /* Fix undefined variable */
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        position: sticky;
        top: 0;
        z-index: 100;
        /* Mobile Safe Area Fix */
        padding-top: calc(env(safe-area-inset-top) + 10px);
        /* Ensure status bar clearance */
        height: auto;
    }

    .nav {
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 70px;
        /* Internal height */
    }

    .mobile-menu.active {
        right: 0;
    }

    .mobile-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 2rem;
        padding-bottom: 1rem;
        border-bottom: 1px solid var(--border);
    }

    .user-greeting {
        font-size: 1.25rem;
        font-weight: 600;
        color: var(--text-main);
    }

    .close-btn {
        background: none;
        border: none;
        font-size: 1.5rem;
        color: var(--text-muted);
        cursor: pointer;
        padding: 0.25rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-menu-links {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        flex: 1;
    }

    .mobile-link {
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 0.875rem 1rem;
        border-radius: var(--radius);
        color: var(--text-main);
        font-weight: 500;
        transition: background 0.2s;
    }

    .mobile-link:hover {
        background: var(--bg-body);
        color: var(--primary);
    }

    .mobile-link.logout {
        margin-top: 1rem;
        color: var(--danger);
        background: var(--danger-bg);
    }

    /* Mobile Grid Adjustments */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Modal System */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}