/* LolaHR.ai Digital Twin Platform - Complete Theme */

/* =================================================================
   CSS VARIABLES
   ================================================================= */
:root {
    /* Brand Colors */
    --primary: #3D7A7F;
    --primary-dark: #2D5A5E;
    --primary-light: #5D9A9F;
    --accent: #B8860B;
    --accent-dark: #8B6508;
    --accent-light: #D4A017;

    /* Status Colors */
    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #DC143C;
    --danger-light: #FEE2E2;
    --info: #3B82F6;
    --info-light: #DBEAFE;

    /* Neutrals */
    --background: #F5F7FA;
    --surface: #FFFFFF;
    --border: #E5E7EB;
    --border-dark: #D1D5DB;
    --text: #0A1F3D;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

/* =================================================================
   BASE STYLES
   ================================================================= */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background);
    color: var(--text);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

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

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--space-md);
    line-height: 1.3;
    color: var(--text);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p {
    margin: 0 0 var(--space-md);
}

/* =================================================================
   HEADER
   ================================================================= */
.main-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: var(--space-md) var(--space-xl);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo a {
    color: white;
    display: flex;
    flex-direction: column;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
}

.logo-accent {
    color: var(--accent-light);
}

.logo-subtitle {
    font-size: 0.75rem;
    opacity: 0.9;
    font-weight: 400;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
}

.nav-links {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: var(--space-lg);
}

.nav-links a {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.nav-links a:hover,
.nav-links a.active {
    color: white;
    background-color: rgba(255, 255, 255, 0.15);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.user-name {
    font-weight: 500;
}

.user-role {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    text-transform: capitalize;
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-sm);
}

.mobile-menu-toggle span {
    width: 24px;
    height: 2px;
    background: white;
}

/* =================================================================
   MAIN CONTENT
   ================================================================= */
.main-content {
    flex: 1;
    padding: var(--space-xl);
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* =================================================================
   FOOTER
   ================================================================= */
.main-footer {
    background-color: var(--text);
    color: white;
    padding: var(--space-lg) var(--space-xl);
    text-align: center;
    margin-top: auto;
}

.footer-container {
    max-width: 1400px;
    margin: 0 auto;
}

.footer-container p {
    margin: var(--space-xs) 0;
    font-size: 0.875rem;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.7);
}

.footer-links a:hover {
    color: white;
}

/* =================================================================
   BUTTONS
   ================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline {
    background-color: transparent;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline:hover:not(:disabled) {
    background-color: var(--primary);
    color: white;
}

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

.btn-ghost:hover:not(:disabled) {
    background-color: var(--border);
    color: var(--text);
}

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

.btn-accent:hover:not(:disabled) {
    background-color: var(--accent-dark);
    border-color: var(--accent-dark);
}

.btn-sm {
    padding: var(--space-xs) var(--space-md);
    font-size: 0.75rem;
}

.btn-block {
    width: 100%;
}

/* =================================================================
   CARDS
   ================================================================= */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.summary-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.card-icon-primary { background: var(--primary-light); color: var(--primary-dark); }
.card-icon-success { background: var(--success-light); color: var(--success); }
.card-icon-accent { background: rgba(184, 134, 11, 0.2); color: var(--accent-dark); }
.card-icon-warning { background: var(--warning-light); color: var(--warning); }

.card-content {
    display: flex;
    flex-direction: column;
}

.card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.card-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

/* =================================================================
   KPI CARDS
   ================================================================= */
.kpi-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.kpi-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary);
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.kpi-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.kpi-icon {
    font-size: 1.25rem;
    opacity: 0.5;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: var(--space-xs);
}

.kpi-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.kpi-progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-top: var(--space-sm);
}

/* =================================================================
   TWIN CARDS
   ================================================================= */
.twins-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-lg);
}

.twin-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--transition-normal);
}

.twin-card:hover {
    box-shadow: var(--shadow-lg);
}

.twin-card-header {
    padding: var(--space-lg);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.twin-name {
    font-size: 1.1rem;
    margin: 0;
    color: white;
}

.twin-status {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    font-weight: 600;
}

.status-active { background: var(--success); color: white; }
.status-draft { background: var(--warning); color: white; }
.status-inactive { background: var(--danger); color: white; }
.status-archived { background: var(--text-muted); color: white; }

.twin-card-body {
    padding: var(--space-lg);
}

.twin-metrics {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.twin-metrics .metric {
    text-align: center;
}

.twin-metrics .metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

.twin-metrics .metric-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.twin-progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: var(--space-md);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--success) 100%);
    border-radius: 4px;
    transition: width var(--transition-normal);
}

.progress-success { background: var(--success); }
.progress-warning { background: var(--warning); }
.progress-danger { background: var(--danger); }

.twin-last-sync {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.twin-card-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border);
    display: flex;
    gap: var(--space-sm);
}

/* =================================================================
   SECTIONS
   ================================================================= */
.section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-sm);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.section-header h2 {
    margin: 0;
}

.section-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* =================================================================
   METRICS GRID
   ================================================================= */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-md);
}

.metric-card {
    background: var(--background);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    border: 1px solid var(--border);
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.metric-name {
    font-weight: 600;
    color: var(--text);
}

.metric-status {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    font-weight: 600;
}

.status-on_track { background: var(--success-light); color: var(--success); }
.status-warning { background: var(--warning-light); color: var(--warning); }
.status-off_track { background: var(--danger-light); color: var(--danger); }

.metric-values {
    font-size: 0.875rem;
    margin-bottom: var(--space-md);
}

.metric-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-xs) 0;
}

.metric-row.actual {
    font-weight: 600;
}

.metric-progress {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.metric-progress .progress-bar {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: right;
}

/* Metric Trend Chart */
.metric-trend {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.trend-chart-container {
    flex: 1;
    height: 60px;
    position: relative;
}

.trend-chart-container canvas {
    max-width: 100%;
}

/* =================================================================
   MONTE CARLO SECTION
   ================================================================= */
.monte-carlo-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: var(--space-xl);
}

.mc-stats {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.mc-stat {
    background: var(--background);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    border-left: 4px solid var(--primary);
}

.mc-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: var(--space-xs);
}

.mc-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.mc-chart-container {
    height: 300px;
    position: relative;
}

.mc-interpretation {
    grid-column: 1 / -1;
    background: var(--info-light);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-top: var(--space-md);
}

.mc-interpretation p {
    margin: 0;
    color: var(--text);
}

.mc-interpretation .highlight {
    font-weight: 600;
    color: var(--primary);
}

/* =================================================================
   ALERTS
   ================================================================= */
.alerts-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.alert-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    background: var(--background);
    border-left: 4px solid var(--text-muted);
}

.alert-item.alert-critical { border-left-color: var(--danger); background: var(--danger-light); }
.alert-item.alert-warning { border-left-color: var(--warning); background: var(--warning-light); }
.alert-item.alert-info { border-left-color: var(--info); background: var(--info-light); }

.alert-icon {
    font-size: 1.25rem;
}

.alert-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.alert-title {
    font-weight: 600;
    color: var(--text);
}

.alert-message {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.alert-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.alert-actions {
    display: flex;
    gap: var(--space-sm);
}

/* Alert Summary Cards */
.alert-summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.alert-card-critical .card-value { color: var(--danger); }
.alert-card-warning .card-value { color: var(--warning); }
.alert-card-info .card-value { color: var(--info); }

/* Full Alert Items */
.alerts-list-full .alert-item-full {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--surface);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    border: 1px solid var(--border);
    border-left: 4px solid var(--text-muted);
}

.alert-item-full.alert-critical { border-left-color: var(--danger); }
.alert-item-full.alert-warning { border-left-color: var(--warning); }
.alert-item-full.alert-info { border-left-color: var(--info); }

.alert-main {
    flex: 1;
}

.alert-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
}

.alert-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    font-weight: 600;
    background: var(--border);
    color: var(--text-secondary);
}

.alert-status {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

.status-triggered { background: var(--danger-light); color: var(--danger); }
.status-acknowledged { background: var(--warning-light); color: var(--warning); }
.status-resolved { background: var(--success-light); color: var(--success); }

.alert-details {
    display: flex;
    gap: var(--space-lg);
    font-size: 0.875rem;
    margin-top: var(--space-sm);
}

.alert-footer {
    display: flex;
    gap: var(--space-lg);
    margin-top: var(--space-sm);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.alert-count {
    background: var(--danger-light);
    color: var(--danger);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

/* =================================================================
   TABLES
   ================================================================= */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.data-table th,
.data-table td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--background);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tbody tr:hover {
    background: var(--background);
}

.twin-link {
    font-weight: 500;
    color: var(--primary);
}

.progress-cell {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.progress-bar-sm {
    width: 80px;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.alert-badge-table {
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.action-buttons {
    display: flex;
    gap: var(--space-xs);
}

.status-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    text-transform: capitalize;
    font-weight: 500;
}

/* =================================================================
   FORMS
   ================================================================= */
.form-container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-sm);
}

.form-section {
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-xl);
    border-bottom: 1px solid var(--border);
}

.form-section:last-of-type {
    border-bottom: none;
    margin-bottom: var(--space-lg);
}

.form-section h2 {
    font-size: 1.125rem;
    margin-bottom: var(--space-md);
}

.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: var(--space-xs);
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--text);
    transition: border-color var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(61, 122, 127, 0.1);
}

.form-help {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.form-error {
    background: var(--danger-light);
    color: var(--danger);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
}

.required {
    color: var(--danger);
}

.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.form-check input[type="checkbox"] {
    width: auto;
}

.form-check label {
    margin-bottom: 0;
}

/* Metrics Input */
.metrics-input-group {
    margin-bottom: var(--space-md);
}

.metric-row-input {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.metric-row-input input {
    padding: var(--space-sm);
}

.remove-metric {
    color: var(--danger);
}

/* Combined metric row with baseline and target values */
.metric-row-combined {
    grid-template-columns: 1fr 1fr 1fr auto;
}

.metric-row-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.metric-column-header {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

/* =================================================================
   AUTH PAGES
   ================================================================= */
.auth-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2xl);
    max-width: 900px;
    margin: var(--space-2xl) auto;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-md);
}

.auth-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.auth-header h1 {
    margin-bottom: var(--space-sm);
}

.auth-header p {
    color: var(--text-secondary);
    margin: 0;
}

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

.auth-footer {
    text-align: center;
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border);
}

.auth-footer p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.auth-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--space-xl);
}

.auth-info h2 {
    color: var(--primary);
    margin-bottom: var(--space-lg);
}

.feature-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.feature-list li {
    padding: var(--space-sm) 0;
    padding-left: var(--space-lg);
    position: relative;
    color: var(--text-secondary);
}

.feature-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: bold;
}

/* =================================================================
   UPLOAD
   ================================================================= */
.upload-container {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: var(--space-xl);
}

.upload-info {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-sm);
}

.upload-info h2 {
    font-size: 1.125rem;
    margin-bottom: var(--space-md);
}

.upload-info h3 {
    font-size: 1rem;
    margin-top: var(--space-lg);
}

.format-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.format-list li {
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border);
}

.example-structure {
    background: var(--background);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-top: var(--space-md);
}

.example-structure code {
    font-family: monospace;
    font-size: 0.875rem;
}

.upload-form-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-sm);
}

.upload-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    text-align: center;
    transition: all var(--transition-fast);
    margin-bottom: var(--space-xl);
}

.upload-dropzone.dragover {
    border-color: var(--primary);
    background: rgba(61, 122, 127, 0.05);
}

.dropzone-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
}

.dropzone-selected {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
}

.file-icon {
    font-size: 2rem;
}

.file-name {
    font-weight: 500;
}

/* Preview Section */
.preview-section {
    margin-bottom: var(--space-xl);
}

.preview-section h3 {
    margin-bottom: var(--space-md);
}

.preview-info {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.preview-table-container {
    overflow-x: auto;
    max-height: 300px;
}

.preview-table {
    font-size: 0.875rem;
}

/* Mapping Section */
.mapping-section {
    margin-bottom: var(--space-xl);
}

.mapping-section h3 {
    margin-bottom: var(--space-sm);
}

.mapping-fields {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.mapping-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm);
    background: var(--background);
    border-radius: var(--radius-md);
}

.mapping-col {
    font-weight: 500;
    min-width: 150px;
}

.mapping-arrow {
    color: var(--text-muted);
}

.mapping-row select {
    flex: 1;
    padding: var(--space-xs) var(--space-sm);
}

/* =================================================================
   PAGE HEADER
   ================================================================= */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-xl);
}

/* Twin detail header - full width title with actions below */
.page-header.twin-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-md);
}

.page-header.twin-header .page-title {
    width: 100%;
}

.page-header.twin-header .page-title h1 {
    font-size: 2rem;
    line-height: 1.2;
    margin-bottom: var(--space-sm);
}

.page-header.twin-header .page-actions {
    flex-wrap: wrap;
}

.page-title h1 {
    margin-bottom: var(--space-xs);
}

.page-title p {
    color: var(--text-secondary);
    margin: 0;
}

.breadcrumb {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.breadcrumb a {
    color: var(--text-muted);
}

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

.page-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.last-refresh {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* =================================================================
   DASHBOARD HEADER
   ================================================================= */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
}

.dashboard-title h1 {
    margin-bottom: var(--space-xs);
}

.dashboard-title p {
    color: var(--text-secondary);
    margin: 0;
}

.dashboard-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.refresh-icon {
    display: inline-block;
    transition: transform var(--transition-fast);
}

.btn:hover .refresh-icon {
    transform: rotate(180deg);
}

/* =================================================================
   DETAIL GRID
   ================================================================= */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
}

.metrics-section,
.monte-carlo-section {
    grid-column: span 2;
}

.alerts-section,
.sync-section {
    grid-column: span 1;
}

/* =================================================================
   SYNC HISTORY
   ================================================================= */
.sync-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.sync-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--background);
    border-radius: var(--radius-md);
}

.sync-status {
    font-size: 1.25rem;
}

.sync-item.sync-success .sync-status { color: var(--success); }
.sync-item.sync-failed .sync-status { color: var(--danger); }
.sync-item.sync-partial .sync-status { color: var(--warning); }

.sync-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.sync-time {
    font-weight: 500;
    color: var(--text);
}

.sync-details {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.sync-error {
    font-size: 0.75rem;
    color: var(--danger);
}

/* =================================================================
   FILTERS
   ================================================================= */
.filters-bar {
    display: flex;
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
    padding: var(--space-md);
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.filter-group label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-group select {
    padding: var(--space-xs) var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.search-group {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.search-group input {
    padding: var(--space-xs) var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    width: 250px;
}

/* =================================================================
   EMPTY STATES
   ================================================================= */
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text);
    margin-bottom: var(--space-sm);
}

.empty-state p {
    margin-bottom: var(--space-lg);
}

.empty-state-small {
    text-align: center;
    padding: var(--space-lg);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.empty-table {
    text-align: center;
    padding: var(--space-2xl) !important;
}

/* =================================================================
   FLASH MESSAGES
   ================================================================= */
.flash-messages {
    position: fixed;
    top: 80px;
    right: var(--space-xl);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    min-width: 300px;
}

.flash-success { background: var(--success); color: white; }
.flash-error { background: var(--danger); color: white; }
.flash-warning { background: var(--warning); color: white; }
.flash-info { background: var(--info); color: white; }

.flash-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.8;
}

.flash-close:hover {
    opacity: 1;
}

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

/* =================================================================
   LOADING OVERLAY
   ================================================================= */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    z-index: 9999;
    color: white;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-sm {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* =================================================================
   UTILITY CLASSES
   ================================================================= */
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }

.bg-success { background-color: var(--success-light) !important; }
.bg-warning { background-color: var(--warning-light) !important; }
.bg-danger { background-color: var(--danger-light) !important; }

/* =================================================================
   RESPONSIVE
   ================================================================= */
@media (max-width: 1024px) {
    .monte-carlo-grid {
        grid-template-columns: 1fr;
    }

    .mc-chart-container {
        order: -1;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .alerts-section,
    .sync-section {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .main-header {
        padding: var(--space-md);
    }

    .header-container {
        flex-wrap: wrap;
    }

    .main-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        padding-top: var(--space-md);
    }

    .main-nav.active {
        display: flex;
    }

    .nav-links {
        flex-direction: column;
        width: 100%;
    }

    .user-menu {
        flex-direction: column;
        align-items: flex-start;
        padding-top: var(--space-md);
        border-top: 1px solid rgba(255, 255, 255, 0.2);
        width: 100%;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .main-content {
        padding: var(--space-md);
    }

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

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

    .twins-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        gap: var(--space-md);
    }

    .page-actions {
        flex-wrap: wrap;
    }

    .auth-container {
        grid-template-columns: 1fr;
    }

    .auth-info {
        display: none;
    }

    .upload-container {
        grid-template-columns: 1fr;
    }

    .upload-info {
        order: 2;
    }

    .filters-bar {
        flex-direction: column;
    }

    .search-group {
        justify-content: stretch;
    }

    .search-group input {
        width: 100%;
    }

    .alert-summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .alert-item-full {
        flex-direction: column;
    }

    .alert-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 480px) {
    .summary-cards {
        grid-template-columns: 1fr;
    }

    .kpi-cards {
        grid-template-columns: 1fr;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .alert-summary-cards {
        grid-template-columns: 1fr;
    }
}
