/**
 * Errational by Newbii - Project Theme
 * 
 * Global color palette and design system variables
 * All templates should import this file to maintain consistent branding
 * 
 * Usage in HTML:
 * <link rel="stylesheet" href="{{ url_for('static', filename='css/theme.css') }}">
 */

:root {
    /* === BRAND COLORS === */
    --brand-purple: #7c3aed;            /* Deep purple - primary gradient start */
    --brand-purple-mid: #6d28d9;        /* Mid purple - gradient middle */
    --brand-purple-dark: #5b21b6;       /* Darker purple - gradient end */
    --brand-purple-glow: rgba(124, 58, 237, 0.4);  /* Purple glow effect */
    
    --brand-green: #00ff88;             /* Bright green - success metrics */
    --brand-green-dark: #00e67a;        /* Darker green for hover */
    --brand-green-glow: rgba(0, 255, 136, 0.3);  /* Green glow effect */
    
    --brand-cyan: #00d4ff;              /* Electric cyan - accents */
    --brand-cyan-dark: #00b8e6;         /* Darker cyan for hover */
    --brand-cyan-glow: rgba(0, 212, 255, 0.25);  /* Cyan glow effect */
    
    /* === PRIMARY COLORS === */
    --color-primary: #0ea5e9;           /* Sky blue - main brand accent */
    --color-primary-dark: #0284c7;      /* Darker blue for hover states */
    --color-primary-light: #38bdf8;     /* Lighter blue for highlights */
    --color-primary-glow: rgba(14, 165, 233, 0.2);  /* Glow effect */
    
    /* === BACKGROUND COLORS === */
    --color-bg-primary: #ffffff;        /* Main white background */
    --color-bg-secondary: #f8fafc;      /* Light gray background */
    --color-bg-card: #ffffff;           /* Card/panel background */
    --color-bg-hover: #f1f5f9;          /* Hover state for cards */
    --color-bg-input: #f8fafc;          /* Form input backgrounds */
    
    /* === TEXT COLORS === */
    --color-text-primary: #0f172a;      /* Primary dark text */
    --color-text-secondary: #475569;    /* Secondary gray text */
    --color-text-muted: #64748b;        /* Muted gray for labels */
    --color-text-disabled: #cbd5e1;     /* Disabled text */
    
    /* === SEMANTIC COLORS === */
    --color-success: #10b981;           /* Green - positive values */
    --color-success-dark: #059669;      /* Darker green */
    --color-error: #ef4444;             /* Red - negative values/errors */
    --color-error-dark: #dc2626;        /* Darker red */
    --color-warning: #f59e0b;           /* Orange/amber - warnings */
    --color-info: #0ea5e9;              /* Info messages (same as primary) */
    
    /* === BORDER COLORS === */
    --color-border: #e2e8f0;            /* Default border */
    --color-border-light: #cbd5e1;      /* Lighter border */
    --color-border-focus: #0ea5e9;      /* Focus state border */
    
    /* === 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);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(14, 165, 233, 0.15);
    --shadow-glow-success: 0 0 20px rgba(16, 185, 129, 0.15);
    
    /* === SPACING === */
    --spacing-xs: 0.25rem;   /* 4px */
    --spacing-sm: 0.5rem;    /* 8px */
    --spacing-md: 1rem;      /* 16px */
    --spacing-lg: 1.5rem;    /* 24px */
    --spacing-xl: 2rem;      /* 32px */
    --spacing-2xl: 3rem;     /* 48px */
    --spacing-3xl: 4rem;     /* 64px */
    
    /* === BORDER RADIUS === */
    --radius-sm: 0.25rem;    /* 4px */
    --radius-md: 0.5rem;     /* 8px */
    --radius-lg: 0.75rem;    /* 12px */
    --radius-xl: 1rem;       /* 16px */
    --radius-2xl: 1.5rem;    /* 24px */
    --radius-full: 9999px;   /* Fully rounded */
    
    /* === TYPOGRAPHY === */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    --font-mono: 'Consolas', 'Monaco', 'Courier New', monospace;
    
    --font-size-xs: 0.75rem;    /* 12px */
    --font-size-sm: 0.875rem;   /* 14px */
    --font-size-base: 1rem;     /* 16px */
    --font-size-lg: 1.125rem;   /* 18px */
    --font-size-xl: 1.25rem;    /* 20px */
    --font-size-2xl: 1.5rem;    /* 24px */
    --font-size-3xl: 1.875rem;  /* 30px */
    --font-size-4xl: 2.25rem;   /* 36px */
    --font-size-5xl: 3rem;      /* 48px */
    
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    
    /* === TRANSITIONS === */
    --transition-fast: 150ms ease-in-out;
    --transition-base: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;
    
    /* === Z-INDEX LAYERS === */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
}

/* === NEW PALETTE (from provided palette) === */
:root {
    /* Layered blues into sand */
    --dash-navy: #13364a;
    --dash-ocean: #1f4f70;
    --dash-steel: #3f6a83;
    --dash-slate: #5b7a8d;
    --dash-sand: #cbb8a6;
    --dash-sand-light: #e5d7c6;
    --dash-sand-ghost: #f3ece4;
    --palette-brick: #b74b4b;           /* Terracotta red */
    --palette-brick-dark: #9f3f3f;      /* Darker terracotta  */

    /* Dashboard semantic variables */
    --dashboard-bg-gradient: linear-gradient(180deg, var(--dash-navy) 0%, var(--dash-ocean) 25%, var(--dash-steel) 50%, var(--dash-slate) 75%, var(--dash-sand) 100%);
    --dashboard-card-bg: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(203,184,166,0.55));
    --dashboard-card-border: rgba(31,79,112,0.14);
    --dashboard-header-bg: linear-gradient(135deg, var(--dash-navy), var(--dash-ocean));
    --dashboard-header-text: #f5f7fa;
    --dashboard-chip-bg: rgba(243,236,228,0.9);
    --dashboard-chip-border: rgba(31,79,112,0.22);
    --dashboard-border-strong: rgba(63,106,131,0.5);
    --dashboard-border-soft: rgba(91,122,141,0.28);
    --dashboard-muted: #2c4254;
    --dashboard-accent: var(--dash-ocean);
    --dashboard-accent-strong: var(--dash-navy);
    --dashboard-highlight: rgba(31,79,112,0.12);
    --dashboard-badge-bg: rgba(31,79,112,0.12);
    --dashboard-badge-icon: var(--dash-navy);
}

/* Dashboard specific utility classes */
.dashboard-background {
    background: var(--dashboard-bg-gradient);
    color: var(--color-text-primary);
}

.dashboard-header {
    background: var(--dashboard-header-bg);
    color: var(--dashboard-header-text);
}

.dashboard-card {
    background: var(--dashboard-card-bg);
    border: 1px solid var(--dashboard-card-border);
    color: var(--color-text-primary);
}

.dashboard-footer {
    /* Use dashboard theme colors for footer for consistent branding */
    background: var(--dashboard-header-bg);
    color: var(--dashboard-header-text);
    border-top: 1px solid var(--dashboard-border-strong);
    backdrop-filter: blur(6px);
}

.dashboard-footer a {
    color: var(--dashboard-header-text);
    opacity: 0.92;
    text-decoration: none;
}

.strategy-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, rgba(203,184,166,0.4) 100%);
}

/* === UTILITY CLASSES === */

/* Background utilities */
.bg-primary { background-color: var(--color-bg-primary); }
.bg-secondary { background-color: var(--color-bg-secondary); }
.bg-card { background-color: var(--color-bg-card); }

/* Text color utilities */
.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.text-accent { color: var(--color-primary); }

/* Button base styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: var(--font-sans);
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-purple) 0%, var(--brand-purple-dark) 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--brand-purple-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--brand-purple-mid) 0%, var(--brand-purple-dark) 100%);
    box-shadow: 0 8px 20px var(--brand-purple-glow);
    transform: translateY(-2px);
}

.btn-brand-cyan {
    background-color: var(--brand-cyan);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--brand-cyan-glow);
}

.btn-brand-cyan:hover {
    background-color: var(--brand-cyan-dark);
    box-shadow: 0 8px 20px var(--brand-cyan-glow);
    transform: translateY(-2px);
}

.btn-brand-purple {
    background-color: var(--brand-purple);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--brand-purple-glow);
}

.btn-brand-purple:hover {
    background-color: var(--brand-purple-dark);
    box-shadow: 0 8px 20px var(--brand-purple-glow);
    transform: translateY(-2px);
}

.btn-brand-pink {
    background-color: var(--brand-pink);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--brand-pink-glow);
}

.btn-brand-pink:hover {
    background-color: var(--brand-pink-dark);
    box-shadow: 0 8px 20px var(--brand-pink-glow);
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: var(--color-bg-card);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background-color: var(--color-bg-hover);
    border-color: var(--color-border-light);
}

.btn-success {
    background-color: var(--color-success);
    color: #ffffff;
}

.btn-success:hover {
    background-color: var(--color-success-dark);
    box-shadow: var(--shadow-glow-success);
}

/* Batch test button using dashboard palette green */
.btn-batch {
    background: linear-gradient(135deg, var(--dash-ocean), var(--dash-steel));
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(19,54,74,0.25);
}

.btn-batch:hover {
    background: linear-gradient(135deg, var(--dash-steel), var(--dash-slate));
    transform: translateY(-2px);
    box-shadow: 0 12px 22px rgba(19,54,74,0.3);
}

/* Logout / destructive action button tuned for the new palette */
.btn-logout {
    /* Use terracotta "brick" palette for destructive actions */
    background: linear-gradient(135deg, var(--palette-brick), var(--palette-brick-dark));
    color: #ffffff;
    border: 1px solid rgba(159,63,63,0.18);
    box-shadow: 0 8px 16px rgba(159,63,63,0.10);
}
.btn-logout:hover {
    background: linear-gradient(135deg, var(--palette-brick-dark), var(--palette-brick));
    transform: translateY(-1px);
}

/* Card styles */
.card {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
}

.card:hover {
    background-color: var(--color-bg-hover);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

/* Input styles */
.input {
    background-color: var(--color-bg-input);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-base);
    font-family: var(--font-sans);
    transition: all var(--transition-fast);
    width: 100%;
}

.input:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.input::placeholder {
    color: var(--color-text-muted);
}

/* Badge styles */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--color-success-dark);
    border: 1px solid var(--color-success);
}

.badge-error {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--color-error-dark);
    border: 1px solid var(--color-error);
}

.badge-info {
    background-color: rgba(14, 165, 233, 0.1);
    color: var(--color-primary-dark);
    border: 1px solid var(--color-primary);
}

/* Glow effect utility */
.glow {
    box-shadow: var(--shadow-glow);
}

.glow-success {
    box-shadow: var(--shadow-glow-success);
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Link styles */
a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary-light);
}

/* Selection styles */
::selection {
    background-color: var(--color-primary);
    color: #ffffff;
}

::-moz-selection {
    background-color: var(--color-primary);
    color: #ffffff;
}

/* Scrollbar styles (Webkit browsers) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border-light);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* === MODAL STYLES === */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    max-width: 90%;
    width: 500px;
    margin: 0 16px;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.5s ease;
}

@media (min-width: 640px) {
    .modal-content {
        padding: 40px;
        max-width: 500px;
        margin: 0;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === LOADING SPINNER === */
.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--color-border-light);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === PROGRESS STEPS === */
.progress-step {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0;
    opacity: 0.5;
    transition: all var(--transition-base);
}

.progress-step.active {
    opacity: 1;
}

.progress-step.completed {
    opacity: 1;
}

.step-indicator {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    flex-shrink: 0;
}

.step-indicator.pending {
    background: var(--color-border-light);
    color: var(--color-text-muted);
}

.step-indicator.active {
    background: var(--color-primary);
    color: #ffffff;
    animation: pulse 2s ease-in-out infinite;
}

.step-indicator.completed {
    background: var(--color-success);
    color: #ffffff;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.step-text {
    flex: 1;
}

.step-title {
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
}

.step-subtitle {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* Progress bar */
.progress-bar-container {
    width: 100%;
    height: 4px;
    background: var(--color-border-light);
    border-radius: var(--radius-sm);
    margin-top: 20px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-info));
    width: 0%;
    transition: width var(--transition-base);
    border-radius: var(--radius-sm);
}

/* Status messages */
.status-message {
    margin-top: 20px;
    padding: 12px;
    background: rgba(14, 165, 233, 0.1);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    color: var(--color-primary-dark);
    min-height: 40px;
    display: flex;
    align-items: center;
}

.status-message.error {
    background: rgba(239, 68, 68, 0.1);
    border-left-color: var(--color-error);
    color: var(--color-error-dark);
}

.status-message.success {
    background: rgba(16, 185, 129, 0.1);
    border-left-color: var(--color-success);
    color: var(--color-success-dark);
}

/* === AUTOCOMPLETE DROPDOWN === */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border: 2px solid var(--color-primary);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    display: none;
}

.autocomplete-dropdown.active {
    display: block;
}

.autocomplete-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color var(--transition-fast);
    border-bottom: 1px solid var(--color-border-light);
    font-family: var(--font-mono);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background-color: rgba(14, 165, 233, 0.1);
}

.autocomplete-item .item-symbol {
    font-weight: var(--font-weight-semibold);
    color: var(--color-primary-dark);
}

.autocomplete-item .item-match {
    background-color: #fef3c7;
    font-weight: var(--font-weight-semibold);
}

.autocomplete-empty {
    padding: 16px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

/* === CHECKBOX CUSTOM === */
.checkbox-custom {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    position: relative;
    transition: all var(--transition-fast);
}

.checkbox-custom:checked {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.checkbox-custom:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
}

/* === ANIMATIONS === */
@keyframes fadeInSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeInSlideUp 0.3s ease-out;
}

.fade-in {
    animation: fadeInEffect 0.3s ease-out;
}

@keyframes fadeInEffect {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === FLOATING PARTICLES === */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--color-primary);
    border-radius: 50%;
    opacity: 0.3;
    animation: float 3s ease-in-out infinite;
}

.particle:nth-child(1) { top: 10%; left: 10%; animation-delay: 0s; }
.particle:nth-child(2) { top: 20%; right: 15%; animation-delay: 0.5s; }
.particle:nth-child(3) { bottom: 15%; left: 20%; animation-delay: 1s; }
.particle:nth-child(4) { bottom: 10%; right: 10%; animation-delay: 1.5s; }
