/* ==========================================
   REFLEKT - Global Styles & Design Tokens
   ========================================== */

/* CSS Variables - Design Tokens */
:root {
    /* Color Palette */
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;
    --primary-200: #c7d2fe;
    --primary-300: #a5b4fc;
    --primary-400: #818cf8;
    --primary-500: #6366f1;
    --primary-600: #4f46e5;
    --primary-700: #4338ca;
    --primary-800: #3730a3;
    --primary-900: #312e81;

    --secondary-50: #fdf4ff;
    --secondary-100: #fae8ff;
    --secondary-200: #f5d0fe;
    --secondary-300: #f0abfc;
    --secondary-400: #e879f9;
    --secondary-500: #d946ef;
    --secondary-600: #c026d3;
    --secondary-700: #a21caf;
    --secondary-800: #86198f;
    --secondary-900: #701a75;

    /* Neutral Colors */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --gray-950: #030712;

    /* Semantic Colors */
    --success: #22c55e;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;

    /* Dark Mode Colors */
    --dark-bg: #0f0f23;
    --dark-surface: #1a1a2e;
    --dark-surface-2: #252542;
    --dark-surface-3: #2d2d4a;
    --dark-border: #3d3d5c;
    --dark-text: #e4e4e7;
    --dark-text-secondary: #a1a1aa;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, var(--primary-500) 0%, var(--secondary-500) 100%);
    --gradient-dark: linear-gradient(135deg, var(--dark-surface) 0%, var(--dark-bg) 100%);
    --gradient-glow: radial-gradient(ellipse at center, rgba(99, 102, 241, 0.15) 0%, transparent 70%);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-serif: 'Playfair Display', Georgia, serif;
    
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.3);
    --shadow-dark: 0 4px 20px rgba(0, 0, 0, 0.4);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
    --transition-bounce: 400ms cubic-bezier(0.68, -0.55, 0.265, 1.55);

    /* Z-index */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal: 300;
    --z-toast: 400;
}

/* ==========================================
   CSS Reset & Base Styles
   ========================================== */

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

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

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--dark-text);
    background: var(--dark-bg);
    min-height: 100vh;
}

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

a:hover {
    color: var(--primary-300);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

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

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

ul, ol {
    list-style: none;
}

/* Focus Styles */
:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background: var(--primary-500);
    color: white;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--dark-surface);
}

::-webkit-scrollbar-thumb {
    background: var(--dark-surface-3);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-600);
}

/* ==========================================
   Utility Classes
   ========================================== */

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================
   Button Components
   ========================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-md), 0 0 20px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(99, 102, 241, 0.3);
}

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

.btn-secondary {
    background: var(--dark-surface-2);
    color: var(--dark-text);
    border: 1px solid var(--dark-border);
}

.btn-secondary:hover {
    background: var(--dark-surface-3);
    border-color: var(--primary-500);
}

.btn-ghost {
    background: transparent;
    color: var(--dark-text-secondary);
}

.btn-ghost:hover {
    background: var(--dark-surface-2);
    color: var(--dark-text);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-full {
    width: 100%;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--dark-surface-2);
    color: var(--dark-text-secondary);
    transition: all var(--transition-base);
}

.btn-icon:hover {
    background: var(--dark-surface-3);
    color: var(--dark-text);
}

/* Button Loader */
.btn-loader {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================
   Form Components
   ========================================== */

.input-group {
    margin-bottom: var(--space-5);
}

.input-group label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--dark-text);
    margin-bottom: var(--space-2);
}

.input-group input,
.input-group textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--dark-surface);
    border: 1px solid var(--dark-border);
    border-radius: var(--radius-lg);
    color: var(--dark-text);
    transition: all var(--transition-base);
}

.input-group input:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-group input::placeholder,
.input-group textarea::placeholder {
    color: var(--dark-text-secondary);
}

.input-hint {
    display: block;
    font-size: var(--text-xs);
    color: var(--dark-text-secondary);
    margin-top: var(--space-1);
}

/* Password Input */
.password-input {
    position: relative;
}

.password-input input {
    padding-right: 48px;
}

.toggle-password {
    position: absolute;
    right: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--dark-text-secondary);
    padding: var(--space-1);
}

.toggle-password:hover {
    color: var(--dark-text);
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--dark-text-secondary);
}

.checkbox-label input {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--dark-border);
    border-radius: var(--radius-sm);
    position: relative;
    transition: all var(--transition-fast);
}

.checkbox-label input:checked + .checkmark {
    background: var(--primary-500);
    border-color: var(--primary-500);
}

.checkbox-label input:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
}

/* ==========================================
   Modal Components
   ========================================== */

.modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--dark-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-dark);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(20px);
    transition: transform var(--transition-base);
}

.modal.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--dark-border);
}

.modal-header h2 {
    font-size: var(--text-xl);
    font-weight: 600;
}

.modal-close {
    font-size: var(--text-2xl);
    color: var(--dark-text-secondary);
    padding: var(--space-1);
    line-height: 1;
}

.modal-close:hover {
    color: var(--dark-text);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--dark-border);
}

/* ==========================================
   Toast Notifications
   ========================================== */

#toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    background: var(--dark-surface-2);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary-500);
    animation: slideIn 0.3s ease;
    min-width: 300px;
    max-width: 400px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast-icon {
    font-size: var(--text-lg);
}

.toast-message {
    flex: 1;
    font-size: var(--text-sm);
}

.toast-close {
    color: var(--dark-text-secondary);
    font-size: var(--text-lg);
}

.toast-close:hover {
    color: var(--dark-text);
}

/* ==========================================
   Loading States
   ========================================== */

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid var(--dark-surface-3);
    border-top-color: var(--primary-500);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-16);
    gap: var(--space-4);
    color: var(--dark-text-secondary);
}

/* ==========================================
   Animations
   ========================================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* ==========================================
   Responsive Breakpoints
   ========================================== */

@media (max-width: 768px) {
    :root {
        --text-4xl: 1.875rem;
        --text-5xl: 2.25rem;
    }

    .btn {
        padding: var(--space-3) var(--space-4);
    }
}

@media (max-width: 480px) {
    :root {
        --text-3xl: 1.5rem;
        --text-4xl: 1.75rem;
    }
}
