/* ===== DASHBOARD LAYOUT ===== */
.dashboard-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 260px;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: var(--transition);
}
.sidebar-logo {
  padding: 20px 20px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 800; font-size: 1.1rem;
  color: var(--dark);
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1rem;
}
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gray-light);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 0 8px;
  margin: 16px 0 6px;
}
.nav-section-title:first-child { margin-top: 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  position: relative;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active {
  background: #ede9fe;
  color: var(--primary);
  font-weight: 600;
}
.nav-item .nav-icon { font-size: 1.05rem; width: 22px; text-align: center; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}
.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.sidebar-user:hover { background: var(--bg); }
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 0.875rem;
  flex-shrink: 0;
}
.avatar.lg { width: 48px; height: 48px; font-size: 1.1rem; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-weight: 600; font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.75rem; color: var(--text-light); }

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* TOPBAR */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 62px;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar-left h2 { font-size: 1.15rem; }
.topbar-left p { font-size: 0.8rem; color: var(--text-light); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn .notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid white;
}

/* PAGE CONTENT */
.page-content { padding: 28px; flex: 1; }

/* ===== STAT CARDS ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: flex-start; justify-content: space-between;
}
.stat-card-info h3 { font-size: 1.75rem; font-weight: 800; margin-bottom: 2px; }
.stat-card-info p { font-size: 0.8rem; color: var(--text-light); }
.stat-card-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
}
.stat-card-icon.blue   { background: #dbeafe; }
.stat-card-icon.green  { background: #d1fae5; }
.stat-card-icon.orange { background: #ffedd5; }
.stat-card-icon.red    { background: #fee2e2; }
.stat-card-icon.purple { background: #ede9fe; }
.stat-change {
  font-size: 0.75rem;
  margin-top: 4px;
  font-weight: 500;
}
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ===== TABLE ===== */
.table-wrapper {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-header {
  padding: 18px 20px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 12px;
}
.table-header h3 { font-size: 1rem; }
.table-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  background: var(--bg);
  transition: var(--transition);
}
.search-box:focus-within { border-color: var(--primary); background: white; }
.search-box input {
  border: none; background: none; outline: none;
  font-size: 0.875rem; color: var(--text);
  width: 180px;
}
.search-box input::placeholder { color: var(--gray-light); }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg); }
th {
  padding: 11px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 13px 16px;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafafa; }
.ticket-title { font-weight: 600; color: var(--text); max-width: 260px; }
.ticket-title small { display: block; font-weight: 400; color: var(--text-light); font-size: 0.8rem; }

/* PRIORITY */
.priority {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.75rem; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
}
.priority-low      { background: #d1fae5; color: #065f46; }
.priority-medium   { background: #fef3c7; color: #92400e; }
.priority-high     { background: #ffedd5; color: #9a3412; }
.priority-critical { background: #fee2e2; color: #991b1b; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white;
  border-radius: var(--radius);
  width: 100%; max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--border); background: white;
  font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--danger); color: white; border-color: var(--danger); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-light);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { font-size: 1.1rem; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 0.875rem; max-width: 300px; margin: 0 auto 20px; }

/* ===== TICKET DETAIL ===== */
.ticket-detail-modal { max-width: 680px; }
.message-thread { display: flex; flex-direction: column; gap: 16px; }
.message-bubble {
  display: flex; gap: 12px;
}
.message-bubble.agent { flex-direction: row-reverse; }
.message-bubble .bubble-content {
  max-width: 80%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 2px;
  padding: 12px 16px;
  font-size: 0.875rem;
  line-height: 1.6;
}
.message-bubble.agent .bubble-content {
  background: #ede9fe;
  border-color: #c4b5fd;
  border-radius: 12px 12px 2px 12px;
  color: var(--primary-dark);
}
.bubble-meta { font-size: 0.75rem; color: var(--text-light); margin-top: 4px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}
