/* ===================================================================
   IT Support Desk — Design System
   =================================================================== */

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --accent: #6366f1;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0284c7;
  --info-light: #e0f2fe;

  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --sidebar-w: 250px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 700; line-height: 1.25; }
p { margin: 0 0 1em; }

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------------------------------------------------------------
   Buttons
   --------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  font-size: 14.5px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s ease;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(79,70,229,.3); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: #f1f5f9; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-icon { padding: 9px; }

/* ---------------------------------------------------------------
   Forms
   --------------------------------------------------------------- */
.form-group { margin-bottom: 18px; }
label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-hint { font-size: 12.5px; color: var(--text-faint); margin-top: 5px; }

input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=search], input[type=number], textarea, select {
  width: 100%;
  padding: 11px 14px;
  font-size: 14.5px;
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { resize: vertical; min-height: 120px; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
input.error, textarea.error { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12.5px; margin-top: 5px; }

.otp-inputs { display: flex; gap: 10px; justify-content: center; margin: 20px 0; }
.otp-inputs input {
  width: 46px; height: 54px; text-align: center; font-size: 22px; font-weight: 700;
  padding: 0;
}

.select-wrap { position: relative; }
select { appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 36px; }
.select-wrap::after {
  content: "▾"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); pointer-events: none;
}

/* ---------------------------------------------------------------
   Cards / surfaces
   --------------------------------------------------------------- */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.card-pad { padding: 28px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.card-body { padding: 24px; }

/* Auth pages (login/register/otp) */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top left, #eef2ff, #f4f6fb 55%);
}
.auth-card { width: 100%; max-width: 420px; padding: 40px 36px; }
.auth-logo {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  margin-bottom: 24px; font-weight: 800; font-size: 20px; color: var(--primary-dark);
}
.auth-logo .logo-dot {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.auth-title { text-align: center; font-size: 22px; margin-bottom: 4px; }
.auth-sub { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.auth-footer { text-align: center; margin-top: 22px; font-size: 14px; color: var(--text-muted); }

/* ---------------------------------------------------------------
   Badges
   --------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 700;
  white-space: nowrap; text-transform: capitalize;
}
.badge-open { background: var(--info-light); color: var(--info); }
.badge-progress { background: var(--warning-light); color: var(--warning); }
.badge-resolved { background: var(--success-light); color: var(--success); }
.badge-closed { background: #f1f5f9; color: var(--text-muted); }

.badge-low { background: #f1f5f9; color: var(--text-muted); }
.badge-medium { background: var(--info-light); color: var(--info); }
.badge-high { background: var(--warning-light); color: var(--warning); }
.badge-critical { background: var(--danger-light); color: var(--danger); }

.badge-overdue { background: var(--danger-light); color: var(--danger); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.55;} }

/* ---------------------------------------------------------------
   Alerts / flash messages
   --------------------------------------------------------------- */
.alert {
  padding: 13px 18px; border-radius: var(--radius); font-size: 14px;
  margin-bottom: 18px; display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-light); color: #15803d; border-color: #bbf7d0; }
.alert-danger { background: var(--danger-light); color: #b91c1c; border-color: #fecaca; }
.alert-info { background: var(--info-light); color: #0369a1; border-color: #bae6fd; }
.alert-warning { background: var(--warning-light); color: #b45309; border-color: #fde68a; }

#toast-stack {
  position: fixed; top: 20px; right: 20px; z-index: 1000;
  display: flex; flex-direction: column; gap: 10px; max-width: 340px;
}
#toast-stack .alert { box-shadow: var(--shadow); animation: slideIn .25s ease; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------------------------------------------------------------
   Public site nav (marketing/login area)
   --------------------------------------------------------------- */
.site-header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 66px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--text); }
.brand .logo-dot {
  width: 32px; height: 32px; border-radius: 8px; font-size: 15px;
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.nav-actions { display: flex; align-items: center; gap: 10px; }

/* ---------------------------------------------------------------
   App shell (dashboard layout: sidebar + topbar)
   --------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); background: #14163a; color: #cbd2f0;
  flex-shrink: 0; position: fixed; top: 0; left: 0; bottom: 0; z-index: 200;
  display: flex; flex-direction: column; transition: transform .25s ease;
}
.sidebar .brand { color: #fff; padding: 22px 22px; font-size: 17px; }
.sidebar .brand .logo-dot { background: linear-gradient(135deg,#818cf8,#c084fc); }
.sidebar nav { flex: 1; padding: 10px 12px; overflow-y: auto; }
.sidebar .nav-link {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: var(--radius-sm);
  color: #cbd2f0; font-size: 14.5px; font-weight: 500; margin-bottom: 2px;
}
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.sidebar .nav-link.active { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; }
.sidebar .nav-icon { width: 18px; text-align: center; }
.sidebar-footer { padding: 16px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.1);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; flex-shrink: 0;
}

.main-area { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  position: sticky; top: 0; z-index: 90;
}
.topbar h1 { font-size: 18px; margin: 0; }
.menu-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text); }
.sidebar-overlay { display: none; }

.page-content { padding: 26px 24px 60px; flex: 1; }

/* ---------------------------------------------------------------
   Stat cards / grid
   --------------------------------------------------------------- */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 26px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 22px; box-shadow: var(--shadow-sm);
}
.stat-card .stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.stat-card .stat-icon {
  width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.stat-card .stat-value { font-size: 26px; font-weight: 800; }
.stat-card .stat-label { color: var(--text-muted); font-size: 13px; }

/* ---------------------------------------------------------------
   Tables
   --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
thead th {
  text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); padding: 14px 18px; border-bottom: 1px solid var(--border); background: #fafbff;
}
tbody td { padding: 15px 18px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbff; }
.row-link { cursor: pointer; }
.ticket-num { font-weight: 700; color: var(--primary); font-size: 13.5px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 42px; margin-bottom: 12px; }

/* ---------------------------------------------------------------
   Filters bar
   --------------------------------------------------------------- */
.filters-bar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px;
}
.filters-bar .form-group { margin: 0; min-width: 150px; flex: 1; }
.filters-bar label { margin-bottom: 4px; }

/* ---------------------------------------------------------------
   Ticket detail / conversation thread
   --------------------------------------------------------------- */
.ticket-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
.ticket-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ticket-info-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 16px;
  background: #fafbff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 22px;
}
.ticket-info-grid .info-label { font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .03em; }
.ticket-info-grid .info-value { font-weight: 600; margin-top: 3px; }

.thread { display: flex; flex-direction: column; gap: 16px; margin: 24px 0; }
.thread-msg { display: flex; gap: 12px; max-width: 85%; }
.thread-msg.is-self { align-self: flex-end; flex-direction: row-reverse; }
.thread-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: #fff;
}
.thread-msg.is-admin .thread-avatar { background: linear-gradient(135deg, var(--primary), var(--accent)); }
.thread-msg:not(.is-admin) .thread-avatar { background: linear-gradient(135deg, #64748b, #94a3b8); }
.thread-bubble { background: #fafbff; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.thread-msg.is-self .thread-bubble { background: var(--primary-light); border-color: #d8dcfb; }
.thread-name { font-size: 12.5px; font-weight: 700; margin-bottom: 3px; }
.thread-time { font-size: 11.5px; color: var(--text-faint); font-weight: 400; margin-left: 6px; }
.thread-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thread-attachments img {
  width: 90px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: pointer;
}

/* File dropzone */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 26px; text-align: center;
  cursor: pointer; transition: all .15s ease; background: #fafbff;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: var(--primary-light); }
.dropzone .dz-icon { font-size: 28px; margin-bottom: 8px; }
.dropzone input[type=file] { display: none; }
.preview-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.preview-item { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-item .remove-btn {
  position: absolute; top: 3px; right: 3px; background: rgba(15,23,42,.65); color: #fff;
  border: none; border-radius: 50%; width: 20px; height: 20px; font-size: 12px; cursor: pointer; line-height: 1;
}

/* Lightbox */
.lightbox {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.85); z-index: 1000;
  align-items: center; justify-content: center; padding: 30px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 8px; }
.lightbox-close { position: absolute; top: 20px; right: 26px; color: #fff; font-size: 30px; cursor: pointer; background: none; border: none; }

/* Priority/status pill selectors on admin ticket view */
.pill-select-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------------------------------------------------------------
   Landing page
   --------------------------------------------------------------- */
.hero {
  padding: 90px 0 70px; text-align: center;
  background: radial-gradient(circle at top, #eef2ff, #f4f6fb 60%);
}
.hero h1 { font-size: 40px; max-width: 700px; margin: 0 auto 16px; }
.hero p { font-size: 17px; color: var(--text-muted); max-width: 560px; margin: 0 auto 30px; }
.hero-actions { display: flex; gap: 14px; justify-content: center; }
.features { padding: 70px 0; }
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.feature-card { padding: 26px; }
.feature-icon {
  width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 14px; background: var(--primary-light); color: var(--primary);
}

/* ---------------------------------------------------------------
   Utility
   --------------------------------------------------------------- */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-16 { gap: 16px; }
.mt-0{margin-top:0} .mb-0{margin-bottom:0} .mt-10{margin-top:10px} .mb-10{margin-bottom:10px}
.mt-20{margin-top:20px} .mb-20{margin-bottom:20px}
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-sm { font-size: 13px; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------
   Responsive
   --------------------------------------------------------------- */
@media (max-width: 992px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .features-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-area { margin-left: 0; }
  .menu-toggle { display: inline-flex; align-items: center; }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 150;
  }
  .sidebar-overlay.open { display: block; }
}

@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-card .stat-value { font-size: 21px; }
  .hero h1 { font-size: 28px; }
  .hero p { font-size: 15px; }
  .hero-actions { flex-direction: column; }
  .hero-actions .btn { width: 100%; }
  .auth-card { padding: 30px 22px; }
  .card-pad { padding: 20px; }
  .card-body { padding: 18px; }
  .page-content { padding: 18px 14px 50px; }
  .otp-inputs input { width: 40px; height: 48px; font-size: 18px; }
  .thread-msg { max-width: 100%; }
  .ticket-header { flex-direction: column; }
  .filters-bar .form-group { min-width: 100%; }
}
