/* ==========================================================================
   Ticket Management Portal
   UI Prototype Design System
   ========================================================================== */

:root {
  --bg-body: #f4f6fb;
  --bg-sidebar: #16192b;
  --bg-sidebar-hover: #1f2340;
  --bg-sidebar-active: #4f46e5;
  --bg-card: #ffffff;
  --bg-topbar: #ffffff;

  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --secondary: #64748b;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0891b2;
  --info-light: #cffafe;
  --purple: #7c3aed;
  --purple-light: #ede9fe;

  --text-primary: #1e2233;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #e5e9f2;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 28px rgba(16, 24, 40, 0.12);

  --sidebar-width: 264px;
  --sidebar-collapsed-width: 78px;
  --topbar-height: 66px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

/* ==========================================================================
   Layout Shell
   ========================================================================== */

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

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1030;
  display: flex;
  flex-direction: column;
  transition: width .2s ease, transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .2px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: var(--topbar-height);
}

.sidebar-brand .logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-brand small {
  display: block;
  font-size: 10.5px;
  font-weight: 500;
  color: #8b8fb3;
  letter-spacing: .4px;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 20px;
}

.sidebar-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: #6b6f94;
  font-weight: 600;
  margin: 18px 12px 8px;
}

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

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: #c3c6e0;
  border-radius: var(--radius-sm);
  font-size: 13.6px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background .15s ease, color .15s ease;
}

.sidebar-nav .nav-link i { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-nav .nav-link:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}

.sidebar-nav .nav-link.active {
  background: var(--bg-sidebar-active);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.sidebar-nav .nav-badge {
  margin-left: auto;
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 20px;
  background: rgba(255,255,255,.12);
  color: #fff;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11px;
  color: #6b6f94;
}

/* ---- Main / Content ---- */
.main-wrap {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left .2s ease;
}

.topbar {
  height: var(--topbar-height);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 1020;
  gap: 16px;
}

.topbar-search {
  position: relative;
  max-width: 380px;
  width: 100%;
}

.topbar-search input {
  padding-left: 38px;
  background: var(--bg-body);
  border: 1px solid var(--border-color);
}

.topbar-search i {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  position: relative;
  transition: background .15s ease;
}
.icon-btn:hover { background: var(--bg-body); }

.icon-btn .dot {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 1.5px solid #fff;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 72px; height: 72px; font-size: 24px; }

.page-content { padding: 24px; }

.sidebar-toggle-btn {
  border: 1px solid var(--border-color);
  background: #fff;
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: none;
  align-items: center;
  justify-content: center;
}

/* Breadcrumb */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 22px;
}
.page-title { font-size: 21px; font-weight: 700; margin: 0 0 4px; color: var(--text-primary); }
.breadcrumb { margin: 0; padding: 0; font-size: 12.5px; }
.breadcrumb-item, .breadcrumb-item a { color: var(--text-muted); }
.breadcrumb-item.active { color: var(--text-secondary); }

/* ==========================================================================
   Cards / Stats
   ========================================================================== */

.card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  padding: 16px 20px;
}
.card-body { padding: 20px; }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  height: 100%;
}
.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12.3px; color: var(--text-secondary); font-weight: 500; }
.stat-trend { font-size: 11.5px; font-weight: 600; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ==========================================================================
   Badges / Status Pills
   ========================================================================== */

.badge-pill {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.badge-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-open { background: var(--info-light); color: #0e7490; }
.badge-assigned { background: var(--purple-light); color: #6d28d9; }
.badge-pending { background: var(--warning-light); color: #b45309; }
.badge-inprogress { background: #dbeafe; color: #1d4ed8; }
.badge-escalated { background: var(--danger-light); color: #b91c1c; }
.badge-resolved { background: var(--success-light); color: #15803d; }
.badge-closed { background: #e2e8f0; color: #475569; }
.badge-active { background: var(--success-light); color: #15803d; }
.badge-inactive { background: #f1f5f9; color: #64748b; }

.priority-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.priority-urgent { background: var(--danger); }
.priority-high { background: var(--warning); }
.priority-medium { background: #eab308; }
.priority-low { background: var(--success); }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-card { overflow: hidden; }
.table { margin-bottom: 0; }
.table thead th {
  background: #fafbfe;
  border-bottom: 1px solid var(--border-color);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-secondary);
  font-weight: 700;
  padding: 12px 16px;
  white-space: nowrap;
}
.table tbody td {
  padding: 13px 16px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color);
  font-size: 13.4px;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbff; }
.table-link { color: var(--primary); font-weight: 600; }
.table-link:hover { text-decoration: underline; }

.toolbar-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 16px;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-label { font-weight: 600; font-size: 13px; color: var(--text-primary); margin-bottom: 6px; }
.form-label .req { color: var(--danger); }
.form-control, .form-select {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13.6px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.form-hint { font-size: 11.8px; color: var(--text-muted); margin-top: 4px; }
.invalid-feedback { font-size: 11.8px; }
.form-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-secondary);
  margin: 6px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn { border-radius: var(--radius-sm); font-size: 13.4px; font-weight: 600; padding: 8px 16px; }
.btn-sm { padding: 5px 11px; font-size: 12.4px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline-secondary { border-color: var(--border-color); color: var(--text-secondary); }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* ==========================================================================
   Auth Pages
   ========================================================================== */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}
.auth-side {
  flex: 1.1;
  background: linear-gradient(150deg, #16192b 0%, #2a2470 55%, #4f46e5 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.auth-side::after {
  content: "";
  position: absolute;
  width: 480px; height: 480px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  right: -160px; bottom: -160px;
}
.auth-form-col {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: #fff;
}
.auth-card { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; }

/* ==========================================================================
   Timeline (Ticket Detail)
   ========================================================================== */

.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 9px; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--border-color);
}
.timeline-item { position: relative; padding-bottom: 22px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -28px; top: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border-color);
}
.timeline-title { font-size: 13.2px; font-weight: 600; }
.timeline-meta { font-size: 11.5px; color: var(--text-muted); }
.timeline-body { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

.comment-box {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.comment-box.internal { background: var(--warning-light); border-color: #fde68a; }
.comment-box.public { background: #fff; }

/* ==========================================================================
   Skeleton Loader
   ========================================================================== */

.skeleton {
  background: linear-gradient(90deg, #eef0f6 25%, #e4e7f1 37%, #eef0f6 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: 6px;
}
@keyframes skeleton-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
.skeleton-text { height: 12px; margin-bottom: 8px; }
.skeleton-title { height: 20px; width: 60%; margin-bottom: 14px; }
.skeleton-card { height: 90px; }

/* ==========================================================================
   Misc
   ========================================================================== */

.kpi-divider { border-left: 1px solid var(--border-color); }
.section-title { font-size: 15.5px; font-weight: 700; margin-bottom: 2px; }
.section-subtitle { font-size: 12.5px; color: var(--text-secondary); }

.step-indicator { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.step-indicator .step {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--text-muted);
}
.step-indicator .step .num {
  width: 24px; height: 24px; border-radius: 50%;
  background: #e2e8f0; color: #64748b;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px;
}
.step-indicator .step.active .num { background: var(--primary); color: #fff; }
.step-indicator .step.active { color: var(--text-primary); }
.step-indicator .line { flex: 1; height: 1px; background: var(--border-color); }

.code-block {
  background: #14162a;
  color: #d8dae8;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 12.3px;
  overflow-x: auto;
  position: relative;
}
.copy-btn {
  position: absolute; top: 10px; right: 10px;
  background: rgba(255,255,255,.08);
  border: none; color: #cbd5e1;
  border-radius: 6px;
  font-size: 11px;
  padding: 4px 9px;
}
.copy-btn:hover { background: rgba(255,255,255,.16); color: #fff; }

.masked-key { font-family: monospace; letter-spacing: 1px; }

.workflow-level-card {
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  background: #fafbff;
  padding: 14px;
}

.nav-tabs .nav-link {
  border: none; color: var(--text-secondary); font-weight: 600; font-size: 13.2px;
  padding: 10px 4px; margin-right: 22px; border-bottom: 2px solid transparent;
}
.nav-tabs .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); background: none; }
.nav-tabs { border-bottom: 1px solid var(--border-color); }

.pagination .page-link { border-color: var(--border-color); color: var(--text-secondary); font-size: 12.8px; }
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state i { font-size: 40px; margin-bottom: 12px; opacity: .5; }

/* Toast container position handled by bootstrap .toast-container */

/* Responsive */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-wrap { margin-left: 0; }
  .sidebar-toggle-btn { display: inline-flex; }
  .topbar-search { display: none; }
  .auth-side { display: none; }
}

@media (max-width: 575.98px) {
  .page-content { padding: 16px; }
  .stat-value { font-size: 18px; }
}

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,17,32,.45);
  z-index: 1025;
}
.sidebar-backdrop.show { display: block; }
