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

:root {
    /* Color Palette - Corporate Slate & Blue */
    --bg-base: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f1f5f9;
    
    --text-strong: #0f172a;
    --text-body: #334155;
    --text-muted: #64748b;
    
    --border-subtle: #e2e8f0;
    --border-strong: #cbd5e1;
    
    /* Primary Accent - Corporate Royal Blue */
    --brand-primary: #2563eb;
    --brand-primary-hover: #1d4ed8;
    --brand-primary-light: rgba(37, 99, 235, 0.1);
    
    /* Semantic Colors */
    --color-success: #059669;
    --color-success-bg: rgba(5, 150, 105, 0.1);
    --color-warning: #d97706;
    --color-warning-bg: rgba(217, 119, 6, 0.1);
    --color-danger: #dc2626;
    --color-danger-bg: rgba(220, 38, 38, 0.1);
    
    /* Layout */
    --sidebar-width: 280px;
    --header-height: 72px;
    
    /* Radius & Shadows - Premium Soft Looks */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.05), 0 2px 6px -2px rgba(15, 23, 42, 0.03);
    --shadow-lg: 0 20px 40px -8px rgba(15, 23, 42, 0.08);
    --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.15);
    
    /* Transitions */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark Theme Variables */
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) {
        --bg-base: #020617; /* Very Dark Slate */
        --bg-surface: #0f172a;
        --bg-surface-hover: #1e293b;
        
        --text-strong: #f8fafc;
        --text-body: #cbd5e1;
        --text-muted: #94a3b8;
        
        --border-subtle: #1e293b;
        --border-strong: #334155;
        
        --brand-primary: #3b82f6;
        --brand-primary-hover: #60a5fa;
        --brand-primary-light: rgba(59, 130, 246, 0.15);
        
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
        --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 20px 40px -8px rgba(0, 0, 0, 0.6);
    }
}

html[data-theme="dark"] {
    --bg-base: #020617; /* Very Dark Slate */
    --bg-surface: #0f172a;
    --bg-surface-hover: #1e293b;
    
    --text-strong: #f8fafc;
    --text-body: #cbd5e1;
    --text-muted: #94a3b8;
    
    --border-subtle: #1e293b;
    --border-strong: #334155;
    
    --brand-primary: #3b82f6;
    --brand-primary-hover: #60a5fa;
    --brand-primary-light: rgba(59, 130, 246, 0.15);
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 40px -8px rgba(0, 0, 0, 0.6);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', -apple-system, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition-fast);
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

/* ==========================================================================
   Typography
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-strong);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    letter-spacing: -0.03em;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.75rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 1rem;
    transition: all var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background-color: var(--brand-primary);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    background-color: var(--brand-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(37, 99, 235, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

/* ==========================================================================
   Forms
   ========================================================================== */
.form-group {
    margin-bottom: 1.75rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-strong);
}

.form-input {
    width: 100%;
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background-color: var(--bg-surface);
    color: var(--text-strong);
    font-size: 1rem;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 4px var(--brand-primary-light);
}

/* ==========================================================================
   Split Login Page (Corporate SaaS Style)
   ========================================================================== */
.split-auth-container {
    display: flex;
    min-height: 100vh;
}

.auth-sidebar {
    flex: 1;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    position: relative;
    overflow: hidden;
    display: none;
    color: white;
    padding: 4rem;
    flex-direction: column;
    justify-content: space-between;
}

@media (min-width: 1024px) {
    .auth-sidebar {
        display: flex;
    }
}

.auth-sidebar::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(37, 99, 235, 0.2) 0%, transparent 50%);
    animation: rotateSlow 30s linear infinite;
}

.auth-sidebar-content {
    position: relative;
    z-index: 1;
}

.auth-sidebar-title {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    letter-spacing: -0.04em;
    background: linear-gradient(to right, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-sidebar-subtitle {
    font-size: 1.25rem;
    color: #cbd5e1;
    font-weight: 300;
    max-width: 400px;
}

.auth-form-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-base);
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-surface);
    padding: 3rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-subtle);
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-header {
    margin-bottom: 2.5rem;
    text-align: center;
}

.auth-logo-text {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    letter-spacing: -0.02em;
}

.auth-logo-text svg {
    color: var(--brand-primary);
}

.auth-desc {
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* ==========================================================================
   Dashboard Layout
   ========================================================================== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 20;
    transition: transform var(--transition-smooth);
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--text-strong);
    letter-spacing: -0.03em;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-brand span {
    color: var(--brand-primary);
}

.nav-menu {
    padding: 2rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
    overflow-y: auto;
}

.nav-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    color: var(--text-muted);
    margin: 1rem 0 0.5rem 1rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-md);
    color: var(--text-body);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-link:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-strong);
    transform: translateX(4px);
}

.nav-link.active {
    background-color: var(--brand-primary-light);
    color: var(--brand-primary);
    font-weight: 600;
}

.nav-link svg {
    width: 1.25rem;
    height: 1.25rem;
    opacity: 0.8;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}

/* Main Content */
.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-base);
}

/* Header */
.top-header {
    height: var(--header-height);
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

@media (prefers-color-scheme: dark) {
    .top-header {
        background-color: rgba(15, 23, 42, 0.8);
    }
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    border-radius: var(--radius-full);
    transition: background-color var(--transition-fast);
    cursor: pointer;
}

.user-profile:hover {
    background-color: var(--bg-surface-hover);
}

.user-info {
    text-align: right;
    display: none;
}

@media (min-width: 768px) {
    .user-info {
        display: block;
    }
}

.user-name {
    font-weight: 600;
    color: var(--text-strong);
    font-size: 0.875rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.avatar {
    width: 2.5rem;
    height: 2.5rem;
    background: linear-gradient(135deg, var(--brand-primary), #6366f1);
    color: white;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: var(--shadow-sm);
}

.page-content {
    padding: 2.5rem;
    flex-grow: 1;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ==========================================================================
   Dashboard Widgets (Corporate Refinement)
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-smooth);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: var(--card-color, var(--brand-primary));
    opacity: 0.8;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.stat-title {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--card-bg-color, var(--brand-primary-light));
    color: var(--card-color, var(--brand-primary));
}

.stat-icon svg {
    width: 1.25rem;
    height: 1.25rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-strong);
    letter-spacing: -0.03em;
}

/* ==========================================================================
   Data Tables
   ========================================================================== */
.card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    margin-bottom: 2rem;
}

.card-header {
    padding: 1.5rem 1.75rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--text-strong);
}

.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background-color: var(--bg-surface-hover);
    padding: 1rem 1.75rem;
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-subtle);
}

.table td {
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.875rem;
    color: var(--text-body);
    vertical-align: middle;
}

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

.table tr:hover td {
    background-color: var(--bg-surface-hover);
}

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.badge-warning { background-color: var(--color-warning-bg); color: var(--color-warning); }
.badge-success { background-color: var(--color-success-bg); color: var(--color-success); }
.badge-danger { background-color: var(--color-danger-bg); color: var(--color-danger); }
.badge-gray { background-color: var(--border-subtle); color: var(--text-muted); }

/* ==========================================================================
   Impersonation Banner
   ========================================================================== */
.impersonation-banner {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    text-align: center;
    box-shadow: 0 4px 10px rgba(217, 119, 6, 0.2);
}

.impersonation-banner p {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.btn-leave-impersonate {
    background-color: white;
    color: #d97706;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.btn-leave-impersonate:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes rotateSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-slide-up {
    opacity: 0;
    animation: slideUpFade 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
