/**
 * Runbook - Styles V1.0
 */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --theme-d: #3b82f6;
    --theme-i: #10b981;
    --theme-c: #8b5cf6;
    --critical-low: #10b981;
    --critical-medium: #f59e0b;
    --critical-high: #ef4444;
    --critical-critical: #7c3aed;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-light: #475569;
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
    --shadow-glow: 0 0 20px rgb(59 130 246 / 0.3);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.app-container { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
}

.sidebar-logo svg { width: 32px; height: 32px; color: var(--primary); }
.sidebar-logo h1 { font-size: 1.25rem; font-weight: 700; }

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }
.nav-section { margin-bottom: 1.5rem; }

.nav-section-title {
    padding: 0.5rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
}

.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-link.active { background: rgba(59, 130, 246, 0.1); color: var(--primary); border-left-color: var(--primary); }
.nav-link svg { width: 20px; height: 20px; flex-shrink: 0; }

.sidebar-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border-color); }

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.user-menu:hover { background: var(--bg-hover); }

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.875rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.75rem; color: var(--text-muted); }

.main-content { flex: 1; margin-left: 260px; min-height: 100vh; }

.main-header {
    height: 64px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title { font-size: 1.25rem; font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 1rem; }
.main-body { padding: 2rem; }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.5rem; }
.card-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border-color); background: rgba(0, 0, 0, 0.2); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); box-shadow: var(--shadow-glow); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); }
.btn-danger { background: #dc2626; color: white; }
.btn-success { background: var(--critical-low); color: white; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.875rem 1.75rem; font-size: 1rem; }

/* Theme Grid */
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin-bottom: 2rem; }

.theme-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.theme-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--theme-color);
}

.theme-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--theme-color); }

.theme-card[data-theme="D"] { --theme-color: var(--theme-d); }
.theme-card[data-theme="I"] { --theme-color: var(--theme-i); }
.theme-card[data-theme="C"] { --theme-color: var(--theme-c); }

.theme-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-card[data-theme="D"] .theme-icon { background: rgba(59, 130, 246, 0.15); color: var(--theme-d); }
.theme-card[data-theme="I"] .theme-icon { background: rgba(16, 185, 129, 0.15); color: var(--theme-i); }
.theme-card[data-theme="C"] .theme-icon { background: rgba(139, 92, 246, 0.15); color: var(--theme-c); }

.theme-icon svg { width: 32px; height: 32px; }
.theme-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; }
.theme-description { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 1rem; }
.theme-count { display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.375rem 0.75rem; background: var(--bg-tertiary); border-radius: var(--radius-sm); font-size: 0.8125rem; color: var(--text-secondary); }

/* Categories & Incidents */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }

.incident-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.incident-card:hover { border-color: var(--primary); box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3); }

.incident-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.incident-icon svg { width: 24px; height: 24px; }
.incident-content { flex: 1; min-width: 0; }
.incident-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; }
.incident-description { font-size: 0.8125rem; color: var(--text-secondary); }
.incident-meta { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.75rem; }

.criticality-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

.criticality-badge[data-level="1"] { background: rgba(16, 185, 129, 0.15); color: var(--critical-low); }
.criticality-badge[data-level="2"] { background: rgba(245, 158, 11, 0.15); color: var(--critical-medium); }
.criticality-badge[data-level="3"] { background: rgba(239, 68, 68, 0.15); color: var(--critical-high); }
.criticality-badge[data-level="4"] { background: rgba(124, 58, 237, 0.15); color: var(--critical-critical); }

/* Procedure Wizard */
.procedure-wizard { max-width: 800px; margin: 0 auto; }
.wizard-header { text-align: center; margin-bottom: 2rem; }
.wizard-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.wizard-subtitle { color: var(--text-secondary); }
.wizard-progress { display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-bottom: 2rem; }

.progress-step {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 500;
}

.progress-step.completed { background: var(--critical-low); color: white; }
.progress-step.current { background: var(--primary); color: white; box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3); }
.progress-line { width: 40px; height: 2px; background: var(--bg-tertiary); }
.progress-line.completed { background: var(--critical-low); }

.step-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
}

.step-header { margin-bottom: 1.5rem; }

.step-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.step-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; }
.step-description { color: var(--text-secondary); }

.step-instructions {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    white-space: pre-wrap;
    font-size: 0.9375rem;
    line-height: 1.7;
}

.step-external-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.step-external-link:hover { text-decoration: underline; }

.step-options { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.5rem; }

.option-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.option-btn:hover { border-color: var(--primary); background: rgba(59, 130, 246, 0.05); }
.option-btn.selected { border-color: var(--primary); background: rgba(59, 130, 246, 0.1); }

.option-radio {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.option-btn.selected .option-radio { border-color: var(--primary); }
.option-btn.selected .option-radio::after { content: ''; width: 10px; height: 10px; background: var(--primary); border-radius: 50%; }

.option-content { flex: 1; }
.option-label { font-weight: 500; margin-bottom: 0.125rem; }
.option-description { font-size: 0.8125rem; color: var(--text-secondary); }

.step-actions-grid { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.5rem; }

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-btn:hover { background: var(--bg-hover); }
.action-btn.executed { background: rgba(16, 185, 129, 0.15); border-color: var(--critical-low); color: var(--critical-low); }

.step-notes { margin-bottom: 1.5rem; }

.step-notes textarea {
    width: 100%;
    min-height: 100px;
    padding: 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9375rem;
    resize: vertical;
}

.step-notes textarea:focus { outline: none; border-color: var(--primary); }

.step-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.5rem; }

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: border-color var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--primary); }
.form-input::placeholder { color: var(--text-muted); }
.form-textarea { min-height: 120px; resize: vertical; font-family: inherit; }
.form-help { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.375rem; }
.form-error { font-size: 0.8125rem; color: var(--critical-high); margin-top: 0.375rem; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }

/* Tables */
.table-container { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.875rem 1rem; text-align: left; border-bottom: 1px solid var(--border-color); }
.table th { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); background: var(--bg-primary); }
.table tbody tr { transition: background var(--transition-fast); }
.table tbody tr:hover { background: var(--bg-hover); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.25rem 0.625rem; border-radius: var(--radius-sm); font-size: 0.75rem; font-weight: 500; }
.badge-primary { background: rgba(59, 130, 246, 0.15); color: var(--primary); }
.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--critical-low); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--critical-medium); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--critical-high); }

.status-indicator { display: inline-flex; align-items: center; gap: 0.5rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.in_progress { background: #3b82f6; animation: pulse 2s infinite; }
.status-dot.completed { background: #10b981; }
.status-dot.abandoned { background: #ef4444; }

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

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.alert-icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 0.125rem; }
.alert-content { flex: 1; }
.alert-title { font-weight: 600; margin-bottom: 0.25rem; }

.alert-info { background: rgba(59, 130, 246, 0.15); border: 1px solid rgba(59, 130, 246, 0.3); color: #60a5fa; }
.alert-success { background: rgba(16, 185, 129, 0.15); border: 1px solid rgba(16, 185, 129, 0.3); color: #34d399; }
.alert-warning { background: rgba(245, 158, 11, 0.15); border: 1px solid rgba(245, 158, 11, 0.3); color: #fbbf24; }
.alert-danger { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.3); color: #f87171; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

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

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal { transform: scale(1); }

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title { font-size: 1.125rem; font-weight: 600; }

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.modal-body { padding: 1.5rem; overflow-y: auto; max-height: calc(90vh - 140px); }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 0.75rem; }

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.login-container { width: 100%; max-width: 420px; padding: 2rem; }

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.login-header { text-align: center; margin-bottom: 2rem; }

.login-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background: rgba(59, 130, 246, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.login-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.login-subtitle { color: var(--text-secondary); }

/* Utilities */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--critical-low); }
.text-warning { color: var(--critical-medium); }
.text-danger { color: var(--critical-high); }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

.hidden { display: none; }

/* Stats Cards */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 2rem; }

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.stat-value { font-size: 2rem; font-weight: 700; margin-bottom: 0.25rem; }
.stat-label { font-size: 0.875rem; color: var(--text-secondary); }

/* Responsive */
@media (max-width: 1024px) {
    .theme-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform var(--transition-normal); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .main-body { padding: 1rem; }
    .stats-grid { grid-template-columns: 1fr; }
}
