/* ========================================
   GLOBAL STYLES & THEME
   ======================================== */

:root {
    /* Color Palette - Premium Blue & Slate */
    --primary: #4F46E5;
    /* Indigo 600 */
    --primary-dark: #4338CA;
    /* Indigo 700 */
    --primary-light: #818CF8;
    /* Indigo 400 */
    --secondary: #64748B;
    /* Slate 500 */

    --success: #10B981;
    /* Emerald 500 */
    --warning: #F59E0B;
    /* Amber 500 */
    --error: #EF4444;
    /* Red 500 */
    --info: #3B82F6;
    /* Blue 500 */

    /* Backgrounds */
    --bg-body: #F1F5F9;
    /* Slate 100 */
    --bg-surface: #FFFFFF;
    --bg-surface-2: #F8FAFC;
    /* Slate 50 */

    /* Text */
    --text-primary: #0F172A;
    /* Slate 900 */
    --text-secondary: #475569;
    /* Slate 600 */
    --text-tertiary: #94A3B8;
    /* Slate 400 */
    --text-white: #FFFFFF;

    /* Borders */
    --border-color: #E2E8F0;
    /* Slate 200 */
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;

    /* Shadows (Soft & Modern) */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --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);

    /* Spacing */
    --header-height: 64px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    /* Remove tap highlight on mobile */
}

html,
body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

h1 {
    font-size: 1.875rem;
}

/* 30px */
h2 {
    font-size: 1.5rem;
}

/* 24px */
h3 {
    font-size: 1.25rem;
}

/* 20px */
h4 {
    font-size: 1.125rem;
}

/* 18px */

p {
    margin-bottom: var(--spacing-md);
}

/* ========================================
   BUTTONS
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 0.9375rem;
    /* 15px */
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 44px;
    /* Touch target size */
    box-shadow: var(--shadow-sm);
    gap: 8px;
}

.btn:active {
    transform: translateY(1px);
    box-shadow: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Variants */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-white);
    border: none;
}

.btn-primary:hover:not(:disabled) {
    box-shadow: var(--shadow-md);
    filter: brightness(1.1);
}

.btn-success {
    background-color: var(--success);
    color: var(--text-white);
}

.btn-success:hover:not(:disabled) {
    background-color: #059669;
    /* Emerald 600 */
}

.btn-secondary {
    background-color: var(--bg-surface);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--bg-surface-2);
    color: var(--text-primary);
    border-color: var(--text-tertiary);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    box-shadow: none;
}

.btn-outline:hover:not(:disabled) {
    background-color: rgba(79, 70, 229, 0.05);
    /* Primary with opacity */
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    background-color: transparent;
    color: var(--text-secondary);
    box-shadow: none;
}

.btn-icon:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.btn-small {
    padding: 6px 16px;
    font-size: 0.8125rem;
    /* 13px */
    min-height: 32px;
}

/* ========================================
   FORMS
   ======================================== */

.form-group {
    margin-bottom: var(--spacing-lg);
}

label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input,
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
    appearance: none;
    /* Normalize native appearance */
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-tertiary);
}

/* ========================================
   LOADER & INDICATORS
   ======================================== */

.loader {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    z-index: 9999;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(79, 70, 229, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loader p {
    margin-top: var(--spacing-md);
    font-weight: 500;
    color: var(--text-secondary);
}

.offline-indicator,
.sync-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 8px;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    z-index: 1000;
    animation: slideDown 0.3s ease;
}

.offline-indicator {
    background-color: var(--warning);
    color: #FFF;
}

.sync-indicator {
    background-color: var(--primary);
    color: #FFF;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.sync-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #FFF;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }

    to {
        transform: translateY(0);
    }
}

/* ========================================
   TOASTS
   ======================================== */

#toast-container {
    position: fixed;
    bottom: var(--spacing-lg);
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    pointer-events: none;
    width: 100%;
    max-width: 400px;
    padding: 0 var(--spacing-md);
}

.toast {
    background-color: var(--text-primary);
    color: var(--text-white);
    padding: 14px 20px;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 0.9375rem;
    animation: fadeInUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: all;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toast.success {
    background-color: var(--success);
}

.toast.error {
    background-color: var(--error);
}

.toast.warning {
    background-color: var(--warning);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   UTILITIES
   ======================================== */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-sm {
    margin-top: var(--spacing-sm);
}

.mt-md {
    margin-top: var(--spacing-md);
}

.mt-lg {
    margin-top: var(--spacing-lg);
}

.mb-sm {
    margin-bottom: var(--spacing-sm);
}

.mb-md {
    margin-bottom: var(--spacing-md);
}

.mb-lg {
    margin-bottom: var(--spacing-lg);
}

.p-sm {
    padding: var(--spacing-sm);
}

.p-md {
    padding: var(--spacing-md);
}

.p-lg {
    padding: var(--spacing-lg);
}

/* Mobile Optimization */
@media (max-width: 768px) {
    html {
        font-size: 15px;
    }

    /* Slightly larger text on mobile */
    .btn {
        width: 100%;
    }

    .btn-small,
    .btn-icon {
        width: auto;
    }
}