/* ============================================================
   CronicDesk — Global Stylesheet
   Matching cronic-v2-portal.html design language
   ============================================================ */

:root {
  --brand:       #1a6ef5;
  --brand-d:     #1258d0;
  --brand-light: #ebf5ff;
  --navy:        #07122b;
  --navy2:       #0d1f45;
  --bg:          #f0f4fa;
  --surface:     #fff;
  --border:      #e2e8f0;
  --border2:     #cbd5e1;
  --text:        #0f172a;
  --text2:       #475569;
  --text3:       #94a3b8;
  --success:     #059669;
  --success-bg:  #ecfdf5;
  --success-bd:  #a7f3d0;
  --warning:     #d97706;
  --warning-bg:  #fffbeb;
  --warning-bd:  #fcd34d;
  --danger:      #dc2626;
  --danger-bg:   #fef2f2;
  --danger-bd:   #fca5a5;
  --purple:      #7c3aed;
  --purple-bg:   #f5f3ff;
  --teal:        #0d9488;
  --teal-bg:     #f0fdfa;
  --coral:       #c2410c;
  --r:           9px;
  --r-sm:        6px;
  --sh:          0 1px 3px rgba(0,0,0,.07);
  --sh-md:       0 4px 16px rgba(0,0,0,.10);
  --sb-w:        250px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.6;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sb-w);
  min-width: var(--sb-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
  z-index: 100;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 10px; }

.sb-logo {
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sb-logo-row { display: flex; align-items: center; gap: 10px; }
.sb-mark {
  width: 32px; height: 32px;
  background: var(--brand);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sb-mark svg { width: 16px; height: 16px; }
.sb-brand { font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 700; color: #fff; }
.sb-tag { font-size: 9px; color: rgba(255,255,255,.3); text-transform: uppercase; letter-spacing: .5px; }
.sb-version {
  display: inline-block;
  background: rgba(26,110,245,.25);
  border: 1px solid rgba(26,110,245,.4);
  border-radius: 4px;
  font-size: 10px; color: #93c5fd;
  padding: 1px 7px; margin-top: 6px;
  font-family: 'JetBrains Mono', monospace;
}

.role-chip {
  margin: 8px 14px 4px;
  border-radius: 7px;
  padding: 7px 11px;
  font-size: 11.5px; font-weight: 600;
  display: flex; align-items: center; gap: 7px;
}
.role-admin, .role-coordinator { background: rgba(124,58,237,.2); border: 1px solid rgba(124,58,237,.4); color: #c4b5fd; }
.role-engineer_l1 { background: rgba(26,110,245,.2); border: 1px solid rgba(26,110,245,.4); color: #93c5fd; }
.role-engineer_l2 { background: rgba(13,148,136,.2); border: 1px solid rgba(13,148,136,.4); color: #5eead4; }
.role-engineer_l3 { background: rgba(217,119,6,.2);  border: 1px solid rgba(217,119,6,.4);  color: #fcd34d; }
.role-sme         { background: rgba(194,65,12,.2);  border: 1px solid rgba(194,65,12,.4);  color: #fdba74; }
.role-customer    { background: rgba(5,150,105,.2);  border: 1px solid rgba(5,150,105,.4);  color: #6ee7b7; }

.sb-section { padding: 8px 0 2px; }
.sb-label {
  font-size: 9px; text-transform: uppercase; letter-spacing: 1px;
  color: rgba(255,255,255,.25);
  padding: 0 16px 4px; font-weight: 600;
}

.sb-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 16px;
  color: rgba(255,255,255,.5);
  font-size: 12.5px;
  border-left: 3px solid transparent;
  transition: all .12s;
  text-decoration: none;
  cursor: pointer;
}
.sb-item:hover { background: rgba(255,255,255,.05); color: rgba(255,255,255,.85); }
.sb-item.active { background: rgba(26,110,245,.18); color: #fff; border-left-color: var(--brand); font-weight: 500; }
.sb-item svg { width: 15px; height: 15px; opacity: .6; flex-shrink: 0; }
.sb-item.active svg { opacity: 1; }
.sb-badge {
  margin-left: auto; font-size: 10px; font-weight: 700;
  border-radius: 20px; padding: 1px 7px;
}
.sb-badge.red   { background: #dc2626; color: #fff; }
.sb-badge.blue  { background: var(--brand); color: #fff; }
.sb-badge.amber { background: #d97706; color: #fff; }
.sb-badge.green { background: #059669; color: #fff; }

.sb-user-section {
  margin-top: auto;
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sb-user { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.sb-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sb-user-name { font-size: 12.5px; font-weight: 600; color: #fff; }
.sb-user-role { font-size: 10.5px; color: rgba(255,255,255,.35); }
.sb-online-dot { width: 7px; height: 7px; border-radius: 50%; background: #34d399; margin-left: auto; }
.sb-logout {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: rgba(255,255,255,.35);
  text-decoration: none; padding: 6px 8px;
  border-radius: 6px; transition: all .12s;
}
.sb-logout:hover { background: rgba(220,38,38,.15); color: #fca5a5; }
.sb-logout svg { width: 14px; height: 14px; }

/* ── MAIN WRAP ── */
.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── TOPBAR ── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 50px;
  padding: 0 20px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--sh);
  flex-shrink: 0;
}
.sb-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: 4px; color: var(--text2);
}
.sb-toggle svg { width: 18px; height: 18px; }
.tb-title { font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 700; color: var(--text); }
.tb-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.tb-icon-btn {
  width: 34px; height: 34px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: var(--text2); background: none; border: 1px solid var(--border);
  cursor: pointer; text-decoration: none; position: relative;
  transition: all .12s;
}
.tb-icon-btn:hover { background: var(--bg); color: var(--text); }
.tb-icon-btn svg { width: 16px; height: 16px; }
.notif-dot {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700; border-radius: 10px;
  padding: 1px 4px; min-width: 16px; text-align: center;
}

/* ── CONTENT ── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.content::-webkit-scrollbar { width: 4px; }
.content::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* ── PAGE HEADER ── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px;
}
.page-header-left h1 {
  font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 700;
  color: var(--text); margin-bottom: 3px;
}
.page-header-left p { font-size: 13px; color: var(--text2); }
.page-header-right { display: flex; gap: 8px; }

/* ── STAT CARDS ── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border-radius: var(--r); border: 1px solid var(--border);
  box-shadow: var(--sh); padding: 16px 18px;
  display: flex; align-items: flex-start; gap: 14px;
}
.stat-icon {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.stat-num {
  font-family: 'Syne', sans-serif; font-size: 26px; font-weight: 700;
  color: var(--text); line-height: 1.1;
}
.stat-label { font-size: 12px; color: var(--text3); margin-top: 2px; }
.stat-trend { font-size: 11px; margin-top: 4px; font-weight: 500; }
.stat-trend.up   { color: var(--danger); }
.stat-trend.down { color: var(--success); }
.stat-trend.ok   { color: var(--text3); }

/* ── CARDS ── */
.card {
  background: var(--surface); border-radius: var(--r);
  border: 1px solid var(--border); box-shadow: var(--sh);
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-family: 'Syne', sans-serif; font-size: 14px; font-weight: 700; color: var(--text); }
.card-body { padding: 16px 18px; }

/* ── GRIDS ── */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.g3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.g4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
.tbl {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.tbl thead th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text3); font-weight: 600; text-align: left;
  padding: 10px 14px; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.tbl tbody tr { border-bottom: 1px solid var(--border); }
.tbl tbody tr:last-child { border-bottom: none; }
.tbl tbody tr:hover { background: #f8fafc; cursor: pointer; }
.tbl tbody td { padding: 11px 14px; vertical-align: middle; }
.tbl a { color: var(--brand); text-decoration: none; font-weight: 500; }
.tbl a:hover { text-decoration: underline; }

/* ── BADGE ── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px;
}

/* ── PRIORITY DOT ── */
.priority-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block;
}
.priority-dot.critical { background: #dc2626; box-shadow: 0 0 0 2px rgba(220,38,38,.2); }
.priority-dot.high     { background: #c2410c; }
.priority-dot.medium   { background: #d97706; }
.priority-dot.low      { background: #94a3b8; }

/* ── ALERT PULSE ── */
.pulse {
  width: 8px; height: 8px; border-radius: 50%; background: #dc2626;
  animation: pulse-anim 1.4s infinite;
}
@keyframes pulse-anim {
  0%,100% { opacity:1; box-shadow: 0 0 0 0 rgba(220,38,38,.4); }
  50%      { opacity:.8; box-shadow: 0 0 0 5px rgba(220,38,38,0); }
}

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .3px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-family: 'Inter', sans-serif; font-size: 13.5px; color: var(--text);
  background: var(--surface); transition: border-color .12s, box-shadow .12s;
  outline: none;
}
.form-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,110,245,.12);
}
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { cursor: pointer; }
.form-hint { font-size: 11.5px; color: var(--text3); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-sm); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .12s; border: none;
  text-decoration: none; font-family: 'Inter', sans-serif;
  white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-d); }
.btn-secondary { background: var(--bg); color: var(--text2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-bd); }
.btn-danger:hover { background: #fee2e2; }
.btn-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-bd); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn svg { width: 14px; height: 14px; }

/* ── INFO BOXES ── */
.infobox {
  border-radius: var(--r); padding: 12px 16px;
  border: 1px solid; margin: 12px 0; font-size: 13px;
}
.ib-blue   { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.ib-amber  { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.ib-green  { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.ib-red    { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }

/* ── SLA BAR ── */
.sla-bar-wrap { display: flex; align-items: center; gap: 8px; }
.sla-bar-bg { flex: 1; height: 4px; background: var(--border); border-radius: 10px; overflow: hidden; }
.sla-bar-fill { height: 100%; border-radius: 10px; transition: width .3s; }
.sla-bar-fill.ok       { background: var(--success); }
.sla-bar-fill.at_risk  { background: var(--warning); }
.sla-bar-fill.breached { background: var(--danger); }

/* ── TICKET THREAD ── */
.thread { display: flex; flex-direction: column; gap: 0; }
.thread-msg {
  display: flex; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.thread-msg:last-child { border-bottom: none; }
.thread-msg.internal { background: #fffbeb; }
.thread-msg.resolution { background: #ecfdf5; }
.thread-msg.system { background: var(--bg); }
.thread-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.thread-meta { font-size: 11.5px; color: var(--text3); margin-bottom: 6px; }
.thread-meta strong { color: var(--text2); font-weight: 600; }
.thread-body { font-size: 13.5px; line-height: 1.65; white-space: pre-wrap; }
.thread-type-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 4px; margin-left: 6px;
}
.ttype-internal   { background: #fffbeb; color: #92400e; }
.ttype-resolution { background: #ecfdf5; color: #065f46; }

/* ── ESCALATION LEVEL STRIP ── */
.level-strip {
  display: flex; align-items: center; gap: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden; margin-bottom: 20px;
}
.level-step {
  flex: 1; padding: 10px 14px; text-align: center;
  font-size: 11.5px; font-weight: 600; color: var(--text3);
  border-right: 1px solid var(--border);
  position: relative;
}
.level-step:last-child { border-right: none; }
.level-step.active { background: var(--brand); color: #fff; }
.level-step.done   { background: var(--success-bg); color: var(--success); }

/* ── STATUS TIMELINE ── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: flex; gap: 12px; padding: 10px 0; position: relative; }
.tl-item:not(:last-child)::before {
  content: ''; position: absolute; left: 9px; top: 28px;
  width: 2px; height: calc(100% - 14px); background: var(--border);
}
.tl-dot {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid; flex-shrink: 0; margin-top: 3px;
  display: flex; align-items: center; justify-content: center; font-size: 9px;
}
.tl-content { flex: 1; }
.tl-title { font-size: 13px; font-weight: 600; color: var(--text); }
.tl-meta  { font-size: 11.5px; color: var(--text3); margin-top: 2px; }

/* ── CODE ── */
.code-block {
  background: var(--navy); border-radius: 8px;
  padding: 14px 16px; font-family: 'JetBrains Mono', monospace;
  font-size: 12px; line-height: 1.75; overflow-x: auto;
  color: #e2e8f0; margin: 8px 0;
}

/* ── EMPTY STATE ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; text-align: center; color: var(--text3);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .5; }
.empty-state h3 { font-size: 16px; font-weight: 700; color: var(--text2); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; max-width: 360px; }

/* ── LOGIN PAGE ── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--navy); padding: 20px;
}
.login-box {
  background: var(--surface); border-radius: 14px;
  width: 100%; max-width: 400px;
  padding: 36px 40px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-logo {
  display: flex; align-items: center; gap: 10px; margin-bottom: 28px;
}
.login-mark {
  width: 40px; height: 40px; background: var(--brand); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.login-mark svg { width: 20px; height: 20px; }
.login-brand { font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 800; color: var(--text); }
.login-sub   { font-size: 12px; color: var(--text3); }
.login-title { font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.login-desc  { font-size: 13px; color: var(--text2); margin-bottom: 24px; }

/* ── ALERT ITEM ── */
.alert-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.alert-item:last-child { border-bottom: none; }
.alert-sev {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px;
}
.sev-critical { background: #dc2626; animation: pulse-anim 1.4s infinite; }
.sev-high     { background: #c2410c; }
.sev-medium   { background: #d97706; }
.sev-low      { background: #94a3b8; }
.sev-info     { background: #3b82f6; }

/* ── ALERT MESSAGE (page-level) ── */
.flash {
  padding: 12px 16px; border-radius: var(--r-sm);
  margin-bottom: 16px; font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
.flash-success { background: var(--success-bg); color: #065f46; border: 1px solid var(--success-bd); }
.flash-error   { background: var(--danger-bg);  color: #991b1b; border: 1px solid var(--danger-bd); }
.flash-warning { background: var(--warning-bg); color: #92400e; border: 1px solid var(--warning-bd); }

/* ── RESPONSIVE MOBILE ── */
@media (max-width: 768px) {
  body { display: block; overflow: auto; }
  .sidebar {
    position: fixed; left: -100%; top: 0; bottom: 0;
    transition: left .2s; z-index: 200;
  }
  .sidebar.open { left: 0; }
  .main-wrap { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
  .sb-toggle { display: flex; }
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-num  { font-size: 22px; }
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
