/* ── KSI Customer Portal — Shared Styles ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --red:      #C0392B;
    --darkred:  #8B1A1A;
    --black:    #111111;
    --charcoal: #2b2b2b;
    --gray:     #555555;
    --border:   #e0e0e0;
    --light:    #f5f5f5;
    --white:    #ffffff;
    --green:    #2e7d52;
    --amber:    #d97706;
    --blue:     #1d6fa4;

    --sidebar-w: 240px;
    --header-h:  60px;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--light);
    color: var(--black);
    font-size: 14px;
    line-height: 1.5;
}

/* ── Status Pills ── */
.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; letter-spacing: 0.3px; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; }
.status-open      { background: #fff3cd; color: #856404; }
.status-open::before { background: #d97706; }
.status-enroute   { background: #dbeafe; color: #1e40af; }
.status-enroute::before { background: #3b82f6; animation: pulse 1.2s infinite; }
.status-onsite    { background: #dcfce7; color: #166534; }
.status-onsite::before { background: #22c55e; }
.status-complete  { background: #f3f4f6; color: #374151; }
.status-complete::before { background: #9ca3af; }
.status-scheduled { background: #ede9fe; color: #5b21b6; }
.status-scheduled::before { background: #8b5cf6; }

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

/* ── Shared Card ── */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: 6px; border: none;
    font-size: 13px; font-weight: 700; cursor: pointer;
    transition: all 0.18s; text-decoration: none; letter-spacing: 0.3px;
}
.btn-primary { background: var(--red); color: white; }
.btn-primary:hover { background: var(--darkred); }
.btn-ghost { background: transparent; color: var(--gray); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--light); border-color: #ccc; }
.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-danger:hover { background: #fecaca; }
.btn-success { background: #dcfce7; color: #166534; }
.btn-success:hover { background: #bbf7d0; }

/* ── Form Elements ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--charcoal); margin-bottom: 6px; }
.form-input {
    width: 100%; padding: 11px 14px; border: 1.5px solid var(--border);
    border-radius: 6px; font-size: 14px; font-family: inherit;
    color: var(--black); background: white; transition: border-color 0.18s;
}
.form-input:focus { outline: none; border-color: var(--red); }
.form-select { appearance: auto; }
.form-textarea { resize: vertical; min-height: 100px; }

/* ── Avatar ── */
.avatar { border-radius: 50%; object-fit: cover; background: var(--light); flex-shrink: 0; }
.avatar-sm  { width: 32px;  height: 32px;  }
.avatar-md  { width: 48px;  height: 48px;  }
.avatar-lg  { width: 72px;  height: 72px;  }
.avatar-xl  { width: 100px; height: 100px; }
.avatar-placeholder {
    border-radius: 50%; background: var(--charcoal); color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; flex-shrink: 0;
}

/* ── Portal Layout ── */
.portal-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w); background: var(--black);
    position: fixed; top: 0; left: 0; height: 100vh;
    display: flex; flex-direction: column; z-index: 200;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand-name { font-size: 15px; font-weight: 900; letter-spacing: 2px; color: white; }
.sidebar-brand-sub  { font-size: 10px; letter-spacing: 2px; color: var(--red); text-transform: uppercase; margin-top: 2px; }

.sidebar-section-label {
    font-size: 9px; font-weight: 800; text-transform: uppercase;
    letter-spacing: 2px; color: rgba(255,255,255,0.25);
    padding: 18px 20px 6px;
}
.sidebar-nav { list-style: none; }
.sidebar-nav li a, .sidebar-nav li button {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 20px; color: rgba(255,255,255,0.6);
    text-decoration: none; font-size: 13px; font-weight: 600;
    transition: all 0.18s; width: 100%; background: none; border: none; cursor: pointer;
    text-align: left;
}
.sidebar-nav li a:hover, .sidebar-nav li button:hover { color: white; background: rgba(255,255,255,0.05); }
.sidebar-nav li a.active, .sidebar-nav li button.active { color: white; background: rgba(192,57,43,0.2); border-left: 3px solid var(--red); padding-left: 17px; }
.sidebar-nav .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-user {
    margin-top: auto; padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex; align-items: center; gap: 10px;
}
.sidebar-user-name  { font-size: 13px; font-weight: 700; color: white; }
.sidebar-user-role  { font-size: 11px; color: rgba(255,255,255,0.4); }
.sidebar-user-logout { margin-left: auto; font-size: 11px; color: rgba(255,255,255,0.35); background: none; border: none; cursor: pointer; }
.sidebar-user-logout:hover { color: var(--red); }

/* Main content */
.portal-main {
    margin-left: var(--sidebar-w);
    flex: 1; display: flex; flex-direction: column; min-height: 100vh;
}
.portal-topbar {
    height: var(--header-h); background: white;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 28px;
    position: sticky; top: 0; z-index: 100; gap: 16px;
}
.portal-topbar-title { font-size: 17px; font-weight: 800; color: var(--black); flex: 1; }
.portal-content { padding: 28px; flex: 1; }

/* ── Stats Row ── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 20px; }
.stat-card-num   { font-size: 32px; font-weight: 900; color: var(--black); line-height: 1; }
.stat-card-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--gray); margin-top: 5px; }
.stat-card.red   { border-top: 3px solid var(--red); }
.stat-card.green { border-top: 3px solid var(--green); }
.stat-card.amber { border-top: 3px solid var(--amber); }
.stat-card.blue  { border-top: 3px solid var(--blue); }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--gray); font-weight: 800; padding: 10px 14px; border-bottom: 2px solid var(--border); text-align: left; white-space: nowrap; }
tbody td { padding: 13px 14px; border-bottom: 1px solid #f0f0f0; font-size: 13px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafafa; }
tbody tr.clickable { cursor: pointer; }

/* ── Map ── */
#map { width: 100%; height: 320px; border-radius: 8px; border: 1px solid var(--border); z-index: 1; }

/* ── Tech Card ── */
.tech-card {
    background: var(--black); border-radius: 10px;
    padding: 20px; display: block;
    color: white;
}
.tech-card-info h3 { font-size: 18px; font-weight: 800; margin-bottom: 3px; }
.tech-card-info .tech-title { font-size: 12px; color: var(--red); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700; margin-bottom: 10px; }
.tech-card-info p { font-size: 13px; color: rgba(255,255,255,0.6); line-height: 1.6; }
.tech-card-badge { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12); border-radius: 20px; padding: 4px 12px; font-size: 11px; color: rgba(255,255,255,0.6); margin-top: 12px; }

/* ── Sidebar Theme Toggle ── */
.sidebar-theme-row {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-theme-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,0.28); font-weight: 700; }
.theme-btns { display: flex; gap: 5px; margin-left: auto; }
.theme-btn {
    width: 28px; height: 28px; border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    cursor: pointer; font-size: 14px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.theme-btn:hover  { background: rgba(255,255,255,0.13); border-color: rgba(255,255,255,0.25); }
.theme-btn.active { background: rgba(192,57,43,0.35); border-color: var(--red); }

/* ══ GRAY MODE ══ */
html.gray-mode { --light: #dae0ea; --white: #e6ecf4; --border: #c2cad8; }
html.gray-mode body                   { background: #cfd6e2; }
html.gray-mode .portal-topbar         { background: #e6ecf4; border-color: #c2cad8; }
html.gray-mode .stat-card             { background: #e6ecf4; border-color: #c2cad8; }
html.gray-mode .request-card          { background: #e6ecf4; border-color: #c2cad8; }
html.gray-mode .history-card          { background: #e6ecf4; border-color: #c2cad8; }
html.gray-mode .doc-card              { background: #e6ecf4; border-color: #c2cad8; }
html.gray-mode .card                  { background: #e6ecf4; border-color: #c2cad8; }
html.gray-mode .filter-btn            { background: #e6ecf4; border-color: #c2cad8; }
html.gray-mode .filter-btn.active     { background: var(--black); color: white; border-color: var(--black); }
html.gray-mode .hours-row             { border-color: #c2cad8; }

/* ══ DARK MODE ══ */
html.dark-mode { --light: #191d28; --white: #1e2336; --border: #282f45; --gray: #8892a4; }
html.dark-mode body                   { background: #12151d; color: #dce3f2; }
html.dark-mode .portal-topbar         { background: #1e2336; border-color: #282f45; }
html.dark-mode .portal-topbar-title   { color: #dce3f2; }
html.dark-mode .stat-card             { background: #1e2336; border-color: #282f45; }
html.dark-mode .stat-card-num         { color: #dce3f2; }
html.dark-mode .card                  { background: #1e2336; border-color: #282f45; }
html.dark-mode .request-card          { background: #1e2336; border-color: #282f45; }
html.dark-mode .request-title         { color: #dce3f2; }
html.dark-mode .request-num           { color: #8892a4; }
html.dark-mode .history-card          { background: #1e2336; border-color: #282f45; }
html.dark-mode .history-title         { color: #dce3f2; }
html.dark-mode .doc-card              { background: #1e2336; border-color: #282f45; }
html.dark-mode .doc-title             { color: #dce3f2; }
html.dark-mode .filter-btn            { background: #1e2336; border-color: #282f45; color: #8892a4; }
html.dark-mode .filter-btn.active     { background: #dce3f2; color: #12151d; border-color: #dce3f2; }
html.dark-mode .section-divider       { color: #8892a4; }
html.dark-mode .hours-row             { border-color: #282f45; }
html.dark-mode .hours-day             { color: #dce3f2; }
html.dark-mode .hours-time            { color: #8892a4; }
html.dark-mode .contact-card          { background: #1e2336; border-color: #282f45; }
html.dark-mode .contact-item-value    { color: #dce3f2; }
html.dark-mode .form-input            { background: #191d28; color: #dce3f2; border-color: #282f45; }
html.dark-mode .form-label            { color: #8892a4; }
html.dark-mode thead th               { border-color: #282f45; color: #8892a4; }
html.dark-mode tbody td               { border-color: #282f45; }
html.dark-mode tbody tr:hover td      { background: #222840; }
html.dark-mode .summary-bar           { background: #0d0f15 !important; }
html.dark-mode .alert-form-success    { background: #162416; border-color: #2d4a2d; color: #86efac; }

/* ── Timeline ── */
.timeline { list-style: none; position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 18px 20px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; left: -14px; top: 3px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid white; }
.timeline-dot.done    { background: var(--green); border-color: var(--green); }
.timeline-dot.active  { background: var(--blue); border-color: var(--blue); animation: pulse 1.2s infinite; }
.timeline-dot.pending { background: var(--border); border-color: var(--border); }
.timeline-time  { font-size: 11px; color: var(--gray); margin-bottom: 2px; }
.timeline-label { font-size: 13px; font-weight: 700; }
.timeline-note  { font-size: 12px; color: var(--gray); margin-top: 2px; }

/* ── Responsive ── */
@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }
    .sidebar { transform: translateX(-240px); transition: transform 0.25s; }
    .sidebar.open { transform: translateX(0); width: 240px; }
    .portal-main { margin-left: 0; }
    .portal-content { padding: 16px; }
}
