/* ============================================================
   Support System - Main Stylesheet
   Theme: Clean Professional White
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --primary:        #2563eb;
  --primary-hover:  #1d4ed8;
  --primary-light:  #eff6ff;
  --secondary:      #64748b;
  --success:        #16a34a;
  --warning:        #d97706;
  --danger:         #dc2626;
  --info:           #0891b2;
  --dark:           #0f172a;
  --body-bg:        #f8fafc;
  --card-bg:        #ffffff;
  --border:         #e2e8f0;
  --text:           #1e293b;
  --text-muted:     #64748b;
  --sidebar-width:  260px;
  --topbar-height:  64px;
  --radius:         10px;
  --radius-sm:      6px;
  --shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,.1);
  --font:           'Plus Jakarta Sans', sans-serif;
  --font-mono:      'JetBrains Mono', monospace;
  --transition:     all .2s ease;
}

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

body {
  font-family: var(--font);
  background: var(--body-bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1,h2,h3,h4,h5,h6 { font-weight: 600; color: var(--dark); margin-bottom: .5rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
code { font-family: var(--font-mono); background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 13px; }

/* ============================================================
   LAYOUT - SIDEBAR
   ============================================================ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: var(--transition);
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 16px;
  color: var(--dark);
  text-decoration: none;
}

.sidebar-brand .brand-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: 12px 20px 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13.5px;
  border-radius: 0;
  transition: var(--transition);
  position: relative;
}

.sidebar-link i { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }

.sidebar-link:hover {
  color: var(--primary);
  background: var(--primary-light);
  text-decoration: none;
}

.sidebar-link.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.sidebar-link .badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 6px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user .avatar-sm {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.sidebar-user .user-info { min-width: 0; }
.sidebar-user .user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: 11px; color: var(--text-muted); }

/* ============================================================
   TOPBAR
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  flex: 1;
  font-weight: 600;
  font-size: 16px;
  color: var(--dark);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.btn-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.btn-icon:hover { background: var(--body-bg); color: var(--text); }

.notification-badge {
  position: absolute;
  top: -4px; right: -4px;
  width: 18px; height: 18px;
  background: var(--danger);
  color: #fff;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content { padding: 24px; flex: 1; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 15px;
}

.card-body { padding: 20px; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.blue   { background: #eff6ff; color: var(--primary); }
.stat-icon.green  { background: #f0fdf4; color: var(--success); }
.stat-icon.yellow { background: #fffbeb; color: var(--warning); }
.stat-icon.red    { background: #fef2f2; color: var(--danger); }
.stat-icon.cyan   { background: #ecfeff; color: var(--info); }
.stat-icon.purple { background: #faf5ff; color: #9333ea; }

.stat-value { font-size: 26px; font-weight: 700; color: var(--dark); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-trend { font-size: 12px; margin-top: 4px; }
.stat-trend.up   { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ============================================================
   TABLES
   ============================================================ */
.table { font-size: 13.5px; }
.table th { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); border-bottom-width: 1px; white-space: nowrap; }
.table td { vertical-align: middle; }
.table tbody tr:hover { background: #f8fafc; }
.table-wrapper { overflow-x: auto; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
}

.badge-status-open        { background: #eff6ff; color: #2563eb; }
.badge-status-in_progress { background: #ecfeff; color: #0891b2; }
.badge-status-waiting     { background: #fffbeb; color: #d97706; }
.badge-status-resolved    { background: #f0fdf4; color: #16a34a; }
.badge-status-closed      { background: #f1f5f9; color: #64748b; }

.badge-priority-low    { background: #f1f5f9; color: #64748b; }
.badge-priority-medium { background: #ecfeff; color: #0891b2; }
.badge-priority-high   { background: #fffbeb; color: #d97706; }
.badge-priority-urgent { background: #fef2f2; color: #dc2626; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn { font-weight: 500; font-size: 13.5px; border-radius: var(--radius-sm); padding: 8px 16px; transition: var(--transition); }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-sm { font-size: 12px; padding: 5px 10px; }
.btn-xs { font-size: 11px; padding: 3px 8px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-control, .form-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  padding: 8px 12px;
  color: var(--text);
  background: #fff;
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  outline: none;
}

.form-label { font-weight: 500; font-size: 13px; color: var(--text); margin-bottom: 5px; }
.form-text  { font-size: 12px; color: var(--text-muted); }

/* ============================================================
   TICKET THREAD
   ============================================================ */
.ticket-reply {
  display: flex;
  gap: 14px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.ticket-reply:last-child { border-bottom: none; }

.reply-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.reply-avatar-placeholder {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.reply-body { flex: 1; min-width: 0; }

.reply-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.reply-author { font-weight: 600; font-size: 14px; }
.reply-role   { font-size: 11px; background: var(--primary-light); color: var(--primary); padding: 2px 7px; border-radius: 10px; font-weight: 600; }
.reply-role.agent  { background: #f0fdf4; color: #16a34a; }
.reply-time   { font-size: 12px; color: var(--text-muted); margin-left: auto; }

.reply-content { font-size: 14px; line-height: 1.7; color: var(--text); }
.reply-content p:last-child { margin-bottom: 0; }

.reply-internal {
  background: #fffbeb;
  border: 1px dashed #fbbf24;
  border-radius: var(--radius);
  padding: 16px;
}

.reply-quote {
  background: var(--body-bg);
  border-left: 3px solid var(--border);
  padding: 8px 12px;
  margin-bottom: 12px;
  border-radius: 0 4px 4px 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ============================================================
   TICKET SIDEBAR INFO
   ============================================================ */
.ticket-info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.ticket-info-item:last-child { border-bottom: none; }
.ticket-info-label { color: var(--text-muted); font-weight: 500; }
.ticket-info-value { font-weight: 600; }

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
  border-radius: 50%;
  object-fit: cover;
}

.avatar-placeholder {
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
  background: var(--primary-light);
  color: var(--primary);
}

.avatar-xs, .avatar-placeholder.avatar-xs { width: 24px; height: 24px; font-size: 10px; }
.avatar-sm, .avatar-placeholder.avatar-sm { width: 34px; height: 34px; font-size: 13px; }
.avatar-md, .avatar-placeholder.avatar-md { width: 44px; height: 44px; font-size: 16px; }
.avatar-lg, .avatar-placeholder.avatar-lg { width: 60px; height: 60px; font-size: 22px; }

/* ============================================================
   NOTIFICATION DROPDOWN
   ============================================================ */
.notif-dropdown {
  width: 360px;
  max-height: 440px;
  overflow-y: auto;
}

.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: var(--transition);
}

.notif-item:hover { background: var(--body-bg); color: var(--text); }
.notif-item.unread { background: var(--primary-light); }

.notif-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.notif-title   { font-weight: 600; font-size: 13px; }
.notif-msg     { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.notif-time    { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ============================================================
   TIMELINE (AUDIT LOG)
   ============================================================ */
.timeline { padding: 0; list-style: none; position: relative; }
.timeline::before {
  content: '';
  position: absolute;
  left: 16px; top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  display: flex;
  gap: 12px;
  padding-bottom: 16px;
  position: relative;
}

.timeline-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary);
  flex-shrink: 0;
  margin-top: 4px;
  z-index: 1;
  position: relative;
  left: 11px;
}

.timeline-content { padding-left: 10px; }
.timeline-content .text { font-size: 13px; }
.timeline-content .time { font-size: 11px; color: var(--text-muted); }

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-page {
  min-height: 100vh;
  background: var(--body-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
  width: 100%;
  max-width: 420px;
  padding: 36px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo .logo-icon {
  width: 52px; height: 52px;
  background: var(--primary);
  border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 24px;
  margin-bottom: 10px;
}

.auth-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.auth-subtitle { color: var(--text-muted); font-size: 14px; }

.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-muted); font-size: 12px; margin: 16px 0;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb { font-size: 13px; margin-bottom: 0; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }
.breadcrumb-item a { color: var(--text-muted); }
.breadcrumb-item.active { color: var(--text); font-weight: 500; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ============================================================
   STEP WIZARD
   ============================================================ */
.step-wizard {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 28px;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  position: relative;
}

.step::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 12px;
}

.step:last-child::after { display: none; }
.step.active::after, .step.done::after { background: var(--primary); }

.step-num {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  color: var(--text-muted);
  background: #fff;
  flex-shrink: 0;
}

.step.active .step-num { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.step.done .step-num   { border-color: var(--success); color: #fff; background: var(--success); }

.step-label { font-size: 12px; font-weight: 500; color: var(--text-muted); white-space: nowrap; }
.step.active .step-label { color: var(--primary); font-weight: 600; }
.step.done .step-label   { color: var(--success); }

/* ============================================================
   LICENSE CARD
   ============================================================ */
.license-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: var(--transition);
}

.license-card:hover { box-shadow: var(--shadow-md); }

.license-thumb {
  width: 56px; height: 44px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--body-bg);
  flex-shrink: 0;
}

/* ============================================================
   RATING STARS
   ============================================================ */
.star-rating { display: flex; gap: 4px; }
.star-rating i { font-size: 20px; cursor: pointer; color: #e2e8f0; transition: var(--transition); }
.star-rating i.active, .star-rating i:hover ~ i, .star-rating:hover i { color: #fbbf24; }
.star-rating i:hover ~ i { color: #e2e8f0 !important; }

/* ============================================================
   SLA INDICATOR
   ============================================================ */
.sla-ok     { color: var(--success); }
.sla-warn   { color: var(--warning); }
.sla-breach { color: var(--danger); font-weight: 600; }
tr.sla-breached td { background: #fef2f2 !important; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================================
   UTILITIES
   ============================================================ */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gap-2  { gap: .5rem; }
.fw-600 { font-weight: 600; }
.fs-12  { font-size: 12px; }
.fs-13  { font-size: 13px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .filter-bar {
    flex-direction: column;
  }
  .stat-card {
    padding: 14px;
  }
}
