/* ==========================================================================
   RELIABLE HELPDESK — style.css
   Dark glassmorphism admin dashboard. Single stylesheet, no framework.
   ========================================================================== */

:root {
  /* Core palette */
  --bg: #0A0C12;
  --bg-soft: #10131C;
  --bg-elevated: #151926;
  --glass-bg: rgba(255, 255, 255, 0.045);
  --glass-bg-strong: rgba(255, 255, 255, 0.07);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-border-strong: rgba(255, 255, 255, 0.16);

  /* Brand accents */
  --accent: #8B5CF6;
  --accent-soft: rgba(139, 92, 246, 0.15);
  --accent-2: #22D3EE;

  /* Status colors (fixed per spec: blue/yellow/green) */
  --status-open: #3B82F6;
  --status-open-bg: rgba(59, 130, 246, 0.14);
  --status-pending: #F5B942;
  --status-pending-bg: rgba(245, 185, 66, 0.14);
  --status-solved: #22C55E;
  --status-solved-bg: rgba(34, 197, 94, 0.14);
  --danger: #EF4444;
  --danger-bg: rgba(239, 68, 68, 0.14);

  /* Text */
  --text: #E7EAF3;
  --text-dim: #939AAE;
  --text-faint: #676E82;

  /* Shape / shadow */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.28);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.38);
  --shadow-glow: 0 0 0 1px rgba(139, 92, 246, 0.25), 0 16px 40px rgba(139, 92, 246, 0.12);

  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --sidebar-w: 264px;
}

/* ---------------- Reset ---------------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--font-body);
  background: radial-gradient(1100px 700px at 85% -10%, rgba(139, 92, 246, 0.12), transparent 60%),
              radial-gradient(900px 600px at 0% 100%, rgba(34, 211, 238, 0.08), transparent 60%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; color: var(--text); }
ul { list-style: none; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* Custom scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.24); }

/* ---------------- Loading screen ---------------- */
#loadingScreen {
  position: fixed; inset: 0; z-index: 9999; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
#loadingScreen.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-ring {
  width: 58px; height: 58px; border-radius: 50%;
  border: 3px solid rgba(139, 92, 246, 0.18);
  border-top-color: var(--accent);
  border-right-color: var(--accent-2);
  animation: spin 0.85s linear infinite;
}
.loader-box { text-align: center; }
.loader-box p {
  margin-top: 18px; font-family: var(--font-display); letter-spacing: 0.16em;
  font-size: 0.78rem; color: var(--text-dim); text-transform: uppercase;
}
@keyframes spin { to { transform: rotate(360deg); } }

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

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: fixed; top: 0; left: 0; bottom: 0;
  background: var(--glass-bg); border-right: 1px solid var(--glass-border);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  display: flex; flex-direction: column; padding: 26px 18px; z-index: 200;
  transition: transform 0.3s ease;
}
.brand-row { display: flex; align-items: center; gap: 12px; padding: 6px 10px 28px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: var(--radius-sm); flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; box-shadow: var(--shadow-glow);
}
.brand-mark svg { width: 22px; height: 22px; stroke: #fff; fill: none; }
.brand-text .top { font-family: var(--font-display); font-size: 1.02rem; line-height: 1.15; }
.brand-text .sub { font-size: 0.68rem; color: var(--text-dim); letter-spacing: 0.12em; text-transform: uppercase; }

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-nav .nav-label {
  font-size: 0.68rem; color: var(--text-faint); text-transform: uppercase;
  letter-spacing: 0.14em; margin: 18px 10px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 0.9rem; font-weight: 500; transition: all 0.2s ease; position: relative;
}
.nav-item svg { width: 18px; height: 18px; stroke: currentColor; fill: none; flex-shrink: 0; }
.nav-item:hover { background: var(--glass-bg-strong); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: #fff; }
.nav-item.active::before {
  content: ""; position: absolute; left: -18px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; background: linear-gradient(var(--accent), var(--accent-2)); border-radius: 3px;
}
.nav-item .count-pill {
  margin-left: auto; background: rgba(255, 255, 255, 0.08); color: var(--text-dim);
  font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; font-family: var(--font-display);
}
.nav-item.active .count-pill { background: rgba(255, 255, 255, 0.16); color: #fff; }

.sidebar-foot { padding-top: 16px; border-top: 1px solid var(--glass-border); }
.reset-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; border-radius: var(--radius-sm); border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger); font-size: 0.85rem; font-weight: 600; transition: all 0.2s ease;
}
.reset-btn:hover { background: var(--danger-bg); }
.reset-btn svg { width: 16px; height: 16px; }

/* ---------------- Main content ---------------- */
.main-content { margin-left: var(--sidebar-w); flex: 1; min-width: 0; padding: 28px 34px 60px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 30px; flex-wrap: wrap;
}
.topbar h1 { font-size: 1.5rem; }
.topbar .date-chip { font-size: 0.82rem; color: var(--text-dim); margin-top: 4px; }
.hamburger-mobile {
  display: none; width: 42px; height: 42px; border-radius: var(--radius-sm); background: var(--glass-bg);
  border: 1px solid var(--glass-border); align-items: center; justify-content: center; flex-shrink: 0;
}
.hamburger-mobile svg { width: 20px; height: 20px; stroke: var(--text); fill: none; }

.search-filter-row { display: flex; gap: 14px; align-items: center; margin-bottom: 26px; flex-wrap: wrap; }
.search-box {
  position: relative; flex: 1; min-width: 220px;
}
.search-box svg {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px;
  stroke: var(--text-dim); fill: none;
}
.search-box input {
  width: 100%; padding: 13px 16px 13px 44px; border-radius: var(--radius); background: var(--glass-bg);
  border: 1px solid var(--glass-border); font-size: 0.92rem; transition: border-color 0.2s ease;
}
.search-box input::placeholder { color: var(--text-faint); }
.search-box input:focus { border-color: var(--accent); }
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.f-chip {
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--glass-border); background: var(--glass-bg);
  font-size: 0.82rem; font-weight: 600; color: var(--text-dim); transition: all 0.2s ease;
}
.f-chip:hover { color: var(--text); border-color: var(--glass-border-strong); }
.f-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------------- Views ---------------- */
.view { display: none; animation: fadeIn 0.45s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------- Dashboard cards ---------------- */
.dash-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px; margin-bottom: 40px; }
.dash-card {
  background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-lg);
  padding: 26px; position: relative; overflow: hidden; backdrop-filter: blur(16px);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease; cursor: pointer;
  opacity: 0; transform: translateY(24px); animation: cardIn 0.6s ease forwards;
}
.dash-card:nth-child(1) { animation-delay: 0.05s; }
.dash-card:nth-child(2) { animation-delay: 0.15s; }
.dash-card:nth-child(3) { animation-delay: 0.25s; }
.dash-card:nth-child(4) { animation-delay: 0.35s; }
@keyframes cardIn { to { opacity: 1; transform: translateY(0); } }
.dash-card:hover { transform: translateY(-6px); border-color: var(--glass-border-strong); box-shadow: var(--shadow); }
.dash-card::after {
  content: ""; position: absolute; width: 140px; height: 140px; border-radius: 50%; top: -60px; right: -60px;
  background: radial-gradient(circle, var(--card-glow, rgba(139,92,246,0.25)), transparent 70%);
}
.dash-card.new { --card-glow: rgba(139, 92, 246, 0.3); }
.dash-card.open-c { --card-glow: rgba(59, 130, 246, 0.3); }
.dash-card.pending-c { --card-glow: rgba(245, 185, 66, 0.3); }
.dash-card.solved-c { --card-glow: rgba(34, 197, 94, 0.3); }
.dash-card .ic-wrap {
  width: 46px; height: 46px; border-radius: var(--radius-sm); display: grid; place-items: center; margin-bottom: 18px;
  background: rgba(255, 255, 255, 0.06); position: relative; z-index: 1;
}
.dash-card.new .ic-wrap { color: var(--accent); }
.dash-card.open-c .ic-wrap { color: var(--status-open); }
.dash-card.pending-c .ic-wrap { color: var(--status-pending); }
.dash-card.solved-c .ic-wrap { color: var(--status-solved); }
.dash-card .ic-wrap svg { width: 22px; height: 22px; stroke: currentColor; fill: none; }
.dash-card .count { font-family: var(--font-display); font-size: 2.4rem; position: relative; z-index: 1; }
.dash-card .label { font-size: 0.88rem; color: var(--text-dim); margin-top: 4px; position: relative; z-index: 1; }
.dash-card .cta { font-size: 0.78rem; color: var(--text-faint); margin-top: 14px; display: flex; align-items: center; gap: 6px; position: relative; z-index: 1; }
.dash-card .cta svg { width: 13px; height: 13px; }

.section-title { font-size: 1.1rem; margin-bottom: 18px; color: var(--text); }
.recent-list { display: flex; flex-direction: column; gap: 10px; }

/* ---------------- Ticket cards ---------------- */
.ticket-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.ticket-card {
  background: var(--glass-bg); border: 1px solid var(--glass-border); border-left: 3px solid var(--status-open);
  border-radius: var(--radius); padding: 20px 22px; transition: all 0.25s ease; backdrop-filter: blur(14px);
}
.ticket-card:hover { transform: translateY(-4px); border-color: var(--glass-border-strong); box-shadow: var(--shadow-sm); }
.ticket-card.status-pending { border-left-color: var(--status-pending); }
.ticket-card.status-solved { border-left-color: var(--status-solved); }
.ticket-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.ticket-card-head h4 { font-size: 1rem; }
.status-badge {
  font-size: 0.7rem; font-weight: 700; padding: 5px 11px; border-radius: 999px; text-transform: uppercase;
  letter-spacing: 0.04em; white-space: nowrap;
}
.status-badge.open { background: var(--status-open-bg); color: var(--status-open); }
.status-badge.pending { background: var(--status-pending-bg); color: var(--status-pending); }
.status-badge.solved { background: var(--status-solved-bg); color: var(--status-solved); }
.ticket-card .client { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 8px; }
.ticket-card .client strong { color: var(--text); }
.ticket-card .problem {
  font-size: 0.88rem; color: var(--text-dim); margin-bottom: 14px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ticket-card .meta-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.76rem; color: var(--text-faint); margin-bottom: 16px; }
.ticket-card .card-actions { display: flex; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px; border-radius: var(--radius-sm); font-size: 0.84rem; font-weight: 600;
  transition: all 0.2s ease; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #7A48F0; box-shadow: 0 8px 22px rgba(139, 92, 246, 0.35); transform: translateY(-2px); }
.btn-ghost { background: var(--glass-bg-strong); color: var(--text); border: 1px solid var(--glass-border); }
.btn-ghost:hover { border-color: var(--glass-border-strong); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.22); }
.btn-yellow { background: var(--status-pending-bg); color: var(--status-pending); border: 1px solid rgba(245, 185, 66, 0.35); }
.btn-yellow:hover { background: rgba(245, 185, 66, 0.24); }
.btn-green { background: var(--status-solved-bg); color: var(--status-solved); border: 1px solid rgba(34, 197, 94, 0.35); }
.btn-green:hover { background: rgba(34, 197, 94, 0.24); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 0.78rem; }
.icon-only { padding: 9px; }

.empty-state {
  grid-column: 1 / -1; text-align: center; padding: 70px 20px; color: var(--text-faint);
}
.empty-state svg { width: 54px; height: 54px; stroke: var(--text-faint); fill: none; margin-bottom: 16px; }
.empty-state p { font-size: 0.95rem; }

/* ---------------- Modals ---------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5, 6, 10, 0.72); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 800; padding: 20px;
  opacity: 0; visibility: hidden; transition: opacity 0.28s ease, visibility 0.28s ease;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal-box {
  background: var(--bg-elevated); border: 1px solid var(--glass-border-strong); border-radius: var(--radius-lg);
  width: 100%; max-width: 460px; padding: 32px; box-shadow: var(--shadow); position: relative;
  transform: scale(0.92) translateY(20px); transition: transform 0.3s cubic-bezier(.2,.9,.3,1.2);
  max-height: 88vh; overflow-y: auto;
}
.modal-overlay.open .modal-box { transform: scale(1) translateY(0); }
.modal-box.wide { max-width: 560px; }
.modal-close {
  position: absolute; top: 18px; right: 18px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--glass-bg-strong); display: grid; place-items: center; transition: all 0.2s ease;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.14); }
.modal-close svg { width: 16px; height: 16px; stroke: var(--text); fill: none; }
.modal-icon-badge {
  width: 52px; height: 52px; border-radius: var(--radius-sm); background: var(--accent-soft);
  color: var(--accent); display: grid; place-items: center; margin-bottom: 18px;
}
.modal-icon-badge svg { width: 24px; height: 24px; stroke: currentColor; fill: none; }
.modal-box h2 { font-size: 1.25rem; margin-bottom: 6px; }
.modal-box > p.modal-sub { color: var(--text-dim); font-size: 0.88rem; margin-bottom: 22px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 7px; color: var(--text-dim); }
.field input, .field textarea, .field select {
  width: 100%; padding: 12px 15px; border-radius: var(--radius-sm); background: var(--bg-soft);
  border: 1px solid var(--glass-border); font-size: 0.92rem; transition: border-color 0.2s ease;
}
.field select { appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23939AAE' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 16px; padding-right: 40px;
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-faint); }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 90px; }
.field.has-error input, .field.has-error textarea, .field.has-error select { border-color: var(--danger); }

/* ---------------- Agent cards ---------------- */
.agent-card {
  background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius);
  padding: 22px; display: flex; align-items: center; gap: 14px; transition: all 0.25s ease; backdrop-filter: blur(14px);
}
.agent-card:hover { transform: translateY(-4px); border-color: var(--glass-border-strong); box-shadow: var(--shadow-sm); }
.agent-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-family: var(--font-display);
  font-size: 1rem; font-weight: 700;
}
.agent-info h4 { font-size: 0.98rem; margin-bottom: 3px; }
.agent-info p { font-size: 0.8rem; color: var(--text-dim); }
.field-error { color: var(--danger); font-size: 0.76rem; margin-top: 6px; display: none; }
.field.has-error .field-error { display: block; }
.form-error-text { color: var(--danger); font-size: 0.84rem; margin: -8px 0 16px; display: none; }
.form-error-text.show { display: block; }

.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn { flex: 1; }

/* ---------------- Ticket detail modal ---------------- */
.detail-row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--glass-border); }
.detail-row:last-of-type { border-bottom: none; }
.detail-row .k { color: var(--text-dim); font-size: 0.86rem; }
.detail-row .v { font-weight: 600; font-size: 0.9rem; text-align: right; max-width: 60%; }
.detail-problem-box {
  background: var(--bg-soft); border-radius: var(--radius-sm); padding: 16px; margin: 14px 0 20px;
  font-size: 0.9rem; color: var(--text-dim); line-height: 1.6; border: 1px solid var(--glass-border);
}

/* ---------------- Toasts ---------------- */
#toastContainer {
  position: fixed; bottom: 26px; right: 26px; display: flex; flex-direction: column; gap: 12px; z-index: 1000;
}
.toast {
  min-width: 280px; max-width: 340px; background: var(--bg-elevated); border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius); padding: 14px 18px; display: flex; align-items: flex-start; gap: 12px;
  box-shadow: var(--shadow); animation: toastIn 0.35s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
.toast.hide { animation: toastOut 0.3s ease forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }
.toast .ic { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.toast.success .ic { color: var(--status-solved); }
.toast.error .ic { color: var(--danger); }
.toast.info .ic { color: var(--accent-2); }
.toast p { font-size: 0.86rem; color: var(--text); }

/* ---------------- Responsive ---------------- */
@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 22px 18px 50px; }
  .hamburger-mobile { display: grid; place-items: center; }
}
@media (max-width: 600px) {
  .dash-grid { grid-template-columns: 1fr; }
  .ticket-grid { grid-template-columns: 1fr; }
  .search-filter-row { flex-direction: column; align-items: stretch; }
  .modal-box { padding: 24px; }
  .detail-row { flex-direction: column; gap: 4px; }
  .detail-row .v { text-align: left; max-width: 100%; }
  #toastContainer { left: 16px; right: 16px; }
  .toast { max-width: 100%; }
}
