/* ════════════════════════════════════════════════════════════════════
   Evrideo Incident Manager - Professional Light Hi-Tech Theme
   Complete & Final CSS - All Features Unified
   ════════════════════════════════════════════════════════════════════ */

/* ────────────────────────────────────────────────────────────────────
   Variables - Light Hi-Tech Theme
   ──────────────────────────────────────────────────────────────────── */

:root {
    /* Light Hi-Tech Colors */
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    
    --text: #0f172a;
    --muted: #64748b;
    
    --border: #e6e8ef;
    
    --primary: #2563eb;
    --primary-600: #1d4ed8;
    --primary-dark: #1e40af;
    
    /* Semantic Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    
    /* Grays */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    
    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 60px;
    
    /* Radius */
    --radius: 10px;
    --radius-sm: 8px;
    --radius-lg: 12px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1);
}

/* ────────────────────────────────────────────────────────────────────
   Reset & Base
   ──────────────────────────────────────────────────────────────────── */

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

body {
    font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 15px;
    letter-spacing: -0.01em;
}

/* ────────────────────────────────────────────────────────────────────
   Typography
   ──────────────────────────────────────────────────────────────────── */

h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 14px;
    letter-spacing: -0.02em;
    color: var(--text);
}

h3 {
    font-size: 1.02rem;
    font-weight: 700;
    margin: 0 0 10px;
    color: var(--text);
    letter-spacing: -0.015em;
}

/* ────────────────────────────────────────────────────────────────────
   Top Navigation Bar
   ──────────────────────────────────────────────────────────────────── */

.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    color: var(--muted);
}

.sidebar-toggle:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.sidebar-toggle svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
}

.topbar-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.025em;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-user {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
}

/* ────────────────────────────────────────────────────────────────────
   Sidebar Navigation
   ──────────────────────────────────────────────────────────────────── */

.sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-height);
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s ease;
    z-index: 999;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-nav {
    padding: 16px 0;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    padding: 8px 24px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-400);
    transition: opacity 0.3s;
}

.sidebar.collapsed .nav-section-title {
    opacity: 0;
    height: 0;
    padding: 0;
    overflow: hidden;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 24px;
    color: var(--gray-600);
    text-decoration: none;
    transition: all 0.15s;
    position: relative;
    white-space: nowrap;
    font-weight: 600;
    font-size: 0.9rem;
}

.nav-item:hover {
    background: var(--gray-50);
    color: var(--primary);
}

.nav-item.active {
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary);
    font-weight: 700;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary);
}

.nav-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    flex-shrink: 0;
    stroke-width: 2;
}

.sidebar.collapsed .nav-icon {
    margin-right: 0;
}

.nav-text {
    transition: opacity 0.3s;
}

.sidebar.collapsed .nav-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* ────────────────────────────────────────────────────────────────────
   Main Content Area
   ──────────────────────────────────────────────────────────────────── */

.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    padding: 32px;
    transition: margin-left 0.3s ease;
    min-height: calc(100vh - var(--topbar-height));
    background: var(--bg);
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed);
}

/* ────────────────────────────────────────────────────────────────────
   Page Headers
   ──────────────────────────────────────────────────────────────────── */

.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    letter-spacing: -0.025em;
}

.page-subtitle {
    color: var(--muted);
    font-size: 0.95rem;
}

/* ────────────────────────────────────────────────────────────────────
   Dashboard Stats Cards
   ──────────────────────────────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: all 0.15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: rgba(37, 99, 235, 0.2);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--muted);
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

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

.stat-icon svg {
    width: 20px;
    height: 20px;
}

.stat-icon.primary {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.stat-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-icon.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

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

/* ────────────────────────────────────────────────────────────────────
   Cards
   ──────────────────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.025em;
}

/* ────────────────────────────────────────────────────────────────────
   Tables
   ──────────────────────────────────────────────────────────────────── */

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

thead {
    background: var(--surface-2);
}

th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 650;
    color: var(--gray-700);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--gray-700);
    font-size: 0.9rem;
}

tbody tr {
    transition: background 0.12s;
}

tbody tr:hover {
    background: var(--surface-2);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ────────────────────────────────────────────────────────────────────
   Badges & Status
   ──────────────────────────────────────────────────────────────────── */

.badge,
.status,
.severity {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 650;
    letter-spacing: 0.015em;
}

.badge.status-open,
.status.open {
    background: #fef3c7;
    color: #92400e;
}

.badge.status-in-progress {
    background: #dbeafe;
    color: #1e40af;
}

.badge.status-resolved,
.status.resolved {
    background: #d1fae5;
    color: #065f46;
}

.badge.status-closed,
.status.closed {
    background: var(--gray-200);
    color: var(--gray-700);
}

.badge.severity-critical,
.severity.critical {
    background: #fee2e2;
    color: #991b1b;
}

.badge.severity-major,
.severity.major {
    background: #fef3c7;
    color: #92400e;
}

.badge.severity-minor,
.severity.minor {
    background: #dbeafe;
    color: #1e40af;
}

/* ────────────────────────────────────────────────────────────────────
   Buttons
   ──────────────────────────────────────────────────────────────────── */

.btn,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
    line-height: 1;
    letter-spacing: -0.01em;
}

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

.btn-primary:hover,
button.btn-primary:hover {
    background: var(--primary-600);
}

.btn-secondary,
a.btn:not(.btn-primary) {
    background: #eef2f7;
    color: #334155;
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover,
a.btn:not(.btn-primary):hover {
    background: #e9eef6;
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8125rem;
}

.actions {
    display: flex;
    gap: 8px;
}

/* ────────────────────────────────────────────────────────────────────
   Forms
   ──────────────────────────────────────────────────────────────────── */

.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
}

.form-section h3 {
    color: var(--text);
    margin-bottom: 16px;
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -0.015em;
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 650;
    color: var(--muted);
    font-size: 0.88rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    transition: all 0.15s ease;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* ────────────────────────────────────────────────────────────────────
   Flash Messages
   ──────────────────────────────────────────────────────────────────── */

.flash {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
}

.flash.ok {
    background: #d1fae5;
    color: #065f46;
    border-color: #a7f3d0;
}

.flash.bad {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

/* ────────────────────────────────────────────────────────────────────
   Service Selector Dropdown - Light Hi-Tech Style
   ──────────────────────────────────────────────────────────────────── */

.service-selector {
    position: relative;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: visible !important;
}

.service-selector-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
    background: transparent;
    border: none;
    width: 100%;
}

.service-selector-trigger span:first-child {
    color: var(--text);
    font-weight: 680;
    font-size: 0.95rem;
}

.service-selector-arrow {
    color: var(--muted);
    font-size: 0.85rem;
    transition: transform 0.3s ease;
}

.service-selector-trigger.active .service-selector-arrow {
    transform: rotate(180deg);
}

.service-selector-dropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    
    display: none;
    max-height: 360px;
    overflow-y: auto;
    
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow);
    z-index: 2000;
}

.service-selector-dropdown.active {
    display: block;
}

.service-search {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 10;
}

.service-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: var(--surface-2);
}

.service-search input:focus {
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.service-list {
    max-height: 320px;
    overflow-y: auto;
    padding: 6px;
}

.service-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.12s ease;
    margin-bottom: 2px;
}

.service-item:hover {
    background: #f5f7ff;
    border-color: rgba(37, 99, 235, 0.14);
}

.service-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.service-item label {
    cursor: pointer;
    margin: 0;
    flex: 1;
    font-weight: 620;
    font-size: 0.93rem;
    color: var(--text);
}

.service-actions {
    position: sticky;
    bottom: 0;
    z-index: 10;
    display: flex;
    gap: 10px;
    padding: 10px;
    background: linear-gradient(to top, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0.92));
    border-top: 1px solid var(--border);
}

.service-actions button {
    flex: 1;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-weight: 650;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.15s;
}

.service-actions .clear-btn {
    background: white;
    border: 1px solid var(--border);
    color: var(--text);
}

.service-actions .clear-btn:hover {
    background: #f7f8fb;
}

.service-actions .select-all-btn {
    background: rgba(37, 99, 235, 0.10);
    border: 1px solid rgba(37, 99, 235, 0.22);
    color: var(--primary-600);
}

.service-actions .select-all-btn:hover {
    background: rgba(37, 99, 235, 0.14);
}

/* ────────────────────────────────────────────────────────────────────
   Selected Services Tags - Light Hi-Tech Chips
   ──────────────────────────────────────────────────────────────────── */

.selected-services {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    background: var(--surface) !important;
    border: 1px dashed rgba(100, 116, 139, 0.35) !important;
    border-radius: var(--radius) !important;
    padding: 10px !important;
    margin-top: 12px !important;
    min-height: 42px !important;
}

.selected-services-empty {
    color: var(--muted) !important;
    font-weight: 600 !important;
    font-size: 0.875rem !important;
}

/* Override JS inline styles for chips */
.selected-services > div {
    background: #eef2ff !important;
    color: var(--text) !important;
    border: 1px solid rgba(37, 99, 235, 0.18) !important;
    border-radius: 999px !important;
    padding: 6px 12px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    font-weight: 650 !important;
    font-size: 0.9rem !important;
}

.selected-services > div span:first-child {
    color: var(--text) !important;
}

.selected-services > div span:last-child {
    color: #334155 !important;
    opacity: 0.7 !important;
    cursor: pointer !important;
    font-weight: 900 !important;
    font-size: 1.15rem !important;
    line-height: 1 !important;
    transition: opacity 0.15s !important;
}

.selected-services > div span:last-child:hover {
    opacity: 1 !important;
}

/* ────────────────────────────────────────────────────────────────────
   Utility Classes
   ──────────────────────────────────────────────────────────────────── */

.pill {
    display: inline-block;
    padding: 4px 10px;
    background: var(--gray-100);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.75rem;
    margin: 2px;
    color: var(--gray-700);
    font-weight: 600;
}

.muted {
    color: var(--muted);
    font-size: 0.9rem;
}

/* ────────────────────────────────────────────────────────────────────
   Responsive Design
   ──────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 20px;
    }
    
    .sidebar.collapsed ~ .main-content {
        margin-left: 0;
    }
    
    .topbar {
        padding: 0 16px;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .card {
        padding: 20px;
    }
    
    table {
        font-size: 0.85rem;
    }
    
    th, td {
        padding: 10px 12px;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 16px;
    }
    
    .page-title {
        font-size: 1.375rem;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ────────────────────────────────────────────────────────────────────
   Print Styles
   ──────────────────────────────────────────────────────────────────── */

@media print {
    .sidebar,
    .topbar,
    .btn,
    .actions {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #000 !important;
        page-break-inside: avoid;
    }
}

.nav-toggle {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--gray-200);
    background: white;
    cursor: pointer;

    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 10px;

    transition: all 0.15s ease;
}

.nav-toggle:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.nav-toggle span {
    width: 100%;
    height: 2px;
    background: var(--gray-800);
    border-radius: 2px;
}
