/* Modern UI Design System */

:root {
    /* Color Palette - Modern and Clean */
    --color-primary: #3b82f6;
    --color-primary-dark: #2563eb;
    --color-primary-light: #60a5fa;
    --color-secondary: #8b5cf6;
    --color-success: #10b981;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;
    --color-info: #06b6d4;
    
    /* Neutral Colors */
    --color-gray-50: #f9fafb;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-400: #9ca3af;
    --color-gray-500: #6b7280;
    --color-gray-600: #4b5563;
    --color-gray-700: #374151;
    --color-gray-800: #1f2937;
    --color-gray-900: #111827;
    
    /* Semantic Colors */
    --bg-primary: #ffffff;
    --bg-secondary: var(--color-gray-50);
    --text-primary: var(--color-gray-900);
    --text-secondary: var(--color-gray-600);
    --text-muted: var(--color-gray-400);
    --border-color: var(--color-gray-200);
    
    /* Typography Scale */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
    
    --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;
    
    /* Spacing Scale */
    --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.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-2xl: 1rem;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --bg-primary: var(--color-gray-900);
    --bg-secondary: var(--color-gray-800);
    --text-primary: var(--color-gray-100);
    --text-secondary: var(--color-gray-400);
    --text-muted: var(--color-gray-500);
    --border-color: var(--color-gray-700);
}

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

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Modern Card Component */
.card-modern {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: box-shadow var(--transition-base);
}

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

.card-modern__header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.card-modern__title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-modern__subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

.card-modern__body {
    padding: var(--space-6);
}

.card-modern__footer {
    padding: var(--space-4) var(--space-6);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

/* Modern Button Styles */
.btn-modern {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    line-height: 1.5;
    position: relative;
    overflow: hidden;
}

.btn-modern:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

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

.btn-modern--primary:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-modern--secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-modern--secondary:hover {
    background: var(--color-gray-100);
}

.btn-modern--ghost {
    background: transparent;
    color: var(--text-primary);
}

.btn-modern--ghost:hover {
    background: var(--bg-secondary);
}

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

.btn-modern--sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}

.btn-modern--lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
}

/* Button Loading State */
.btn-modern--loading {
    color: transparent;
}

.btn-modern--loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
}

/* Modern Form Controls */
.form-modern {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.form-modern__group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.form-modern__label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
}

.form-modern__label--required::after {
    content: " *";
    color: var(--color-danger);
}

.form-modern__input {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all var(--transition-base);
}

.form-modern__input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

.form-modern__input--error {
    border-color: var(--color-danger);
}

.form-modern__input--error:focus {
    box-shadow: 0 0 0 3px rgb(239 68 68 / 0.1);
}

.form-modern__hint {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.form-modern__error {
    font-size: var(--text-xs);
    color: var(--color-danger);
}

/* Modern Table */
.table-modern {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-modern__head {
    background: var(--bg-secondary);
}

.table-modern__row {
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-base);
}

.table-modern__row:hover {
    background: var(--bg-secondary);
}

.table-modern__cell {
    padding: var(--space-3) var(--space-4);
    text-align: left;
}

.table-modern__header {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

/* Badge Component */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    font-weight: 500;
    border-radius: var(--radius-full);
    line-height: 1;
}

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

.badge--success {
    background: #d1fae5;
    color: #065f46;
}

.badge--warning {
    background: #fed7aa;
    color: #92400e;
}

.badge--danger {
    background: #fee2e2;
    color: #991b1b;
}

/* Alert Component */
.alert-modern {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    border: 1px solid;
}

.alert-modern__icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.alert-modern__content {
    flex: 1;
}

.alert-modern__title {
    font-weight: 600;
    margin-bottom: var(--space-1);
}

.alert-modern--info {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
}

.alert-modern--success {
    background: #d1fae5;
    border-color: #86efac;
    color: #065f46;
}

.alert-modern--warning {
    background: #fed7aa;
    border-color: #fdba74;
    color: #92400e;
}

.alert-modern--danger {
    background: #fee2e2;
    border-color: #fecaca;
    color: #991b1b;
}

/* Modal Component */
.modal-modern {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.modal-modern__backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-modern__content {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
}

.modal-modern__header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-color);
}

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

.modal-modern__body {
    padding: var(--space-6);
}

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

/* Loading Spinner */
@keyframes spinner {
    to { transform: rotate(360deg); }
}

.spinner-modern {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spinner 0.6s linear infinite;
}

/* HTMX Specific Styles */
.htmx-indicator {
    opacity: 0;
    transition: opacity var(--transition-base);
}

.htmx-request .htmx-indicator {
    opacity: 1;
}

.htmx-swapping {
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.htmx-settling {
    opacity: 1;
    transition: opacity var(--transition-base);
}

/* Utility Classes */
.container-modern {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--space-4);
}

.grid {
    display: grid;
    gap: var(--space-4);
}

.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid--2,
    .grid--3,
    .grid--4 {
        grid-template-columns: 1fr;
    }
}

.flex {
    display: flex;
}

.flex--center {
    align-items: center;
    justify-content: center;
}

.flex--between {
    justify-content: space-between;
}

.flex--gap-2 { gap: var(--space-2); }
.flex--gap-4 { gap: var(--space-4); }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fadeIn {
    animation: fadeIn var(--transition-slow) ease-out;
}

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