/* ============================================================
   TicketBot Dashboard — Core Styles
   Dark/Light theme via CSS custom properties
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root,
[data-theme="dark"] {
  --bg:           #050505;
  --bg-secondary: #0a0a0a;
  --surface:      #0f0f0f;
  --surface-2:    #181818;
  --border:       #222222;
  --border-light: #2a2a2a;

  --text:         #e2e8f0;
  --text-muted:   #8892a4;
  --text-faint:   #4a5568;

  --accent:       #5865f2;
  --accent-hover: #4752c4;
  --accent-light: rgba(88, 101, 242, 0.15);

  --success:      #3ba55d;
  --success-light: rgba(59, 165, 93, 0.15);
  --warning:      #faa61a;
  --warning-light: rgba(250, 166, 26, 0.15);
  --danger:       #ed4245;
  --danger-light: rgba(237, 66, 69, 0.15);
  --info:         #00b0f4;
  --info-light:   rgba(0, 176, 244, 0.15);

  --shadow-sm:    0 1px 3px rgba(0,0,0,.4);
  --shadow-md:    0 4px 12px rgba(0,0,0,.5);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.6);

  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    16px;

  --nav-height:   60px;
  --sidebar-w:    240px;
}

[data-theme="light"] {
  --bg:           #f0f2f5;
  --bg-secondary: #e8eaf0;
  --surface:      #ffffff;
  --surface-2:    #f5f6fa;
  --border:       #dde1ec;
  --border-light: #c8cdd8;

  --text:         #1a1d27;
  --text-muted:   #5a6478;
  --text-faint:   #9aa0b0;

  --accent:       #5865f2;
  --accent-hover: #4752c4;
  --accent-light: rgba(88, 101, 242, 0.1);

  --success:      #2d8a4e;
  --success-light: rgba(45, 138, 78, 0.1);
  --warning:      #c47f00;
  --warning-light: rgba(196, 127, 0, 0.1);
  --danger:       #c0392b;
  --danger-light: rgba(192, 57, 43, 0.1);
  --info:         #0077b6;
  --info-light:   rgba(0, 119, 182, 0.1);

  --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
  --shadow-md:    0 4px 12px rgba(0,0,0,.12);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.16);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { 
  scroll-behavior: smooth; 
  background: var(--bg);
  color: var(--text);
}

[data-theme="dark"] { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.2s ease, color 0.2s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ── Typography ────────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem;    font-weight: 600; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s, transform .1s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: var(--accent);  color: #fff; }
.btn-primary:hover  { background: var(--accent-hover); }

.btn-ghost    { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover    { background: var(--surface-2); }

.btn-danger   { background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover   { background: var(--danger); color: #fff; }

.btn-discord  { background: #5865f2; color: #fff; }
.btn-discord:hover  { background: #4752c4; }

.btn-lg  { padding: 12px 24px; font-size: 15px; border-radius: var(--radius-md); }
.btn-sm  { padding: 5px 12px;  font-size: 13px; }
.btn-xs  { padding: 3px 8px;   font-size: 12px; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.badge-success  { background: var(--success-light);  color: var(--success); }
.badge-danger   { background: var(--danger-light);   color: var(--danger); }
.badge-warning  { background: var(--warning-light);  color: var(--warning); }
.badge-info     { background: var(--info-light);     color: var(--info); }
.badge-muted    { background: var(--surface-2);      color: var(--text-muted); }

.badge-open     { background: var(--success-light);  color: var(--success); }
.badge-claimed  { background: var(--info-light);     color: var(--info); }
.badge-closed   { background: var(--surface-2);      color: var(--text-muted); }

.badge-priority-urgent { background: var(--danger-light);  color: var(--danger); }
.badge-priority-high   { background: var(--warning-light); color: var(--warning); }
.badge-priority-medium { background: var(--info-light);    color: var(--info); }
.badge-priority-low    { background: var(--surface-2);     color: var(--text-muted); }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}
.card-body { padding: 20px; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

input[type="text"],
input[type="url"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="color"],
select,
textarea {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  padding: 8px 12px;
  width: 100%;
  transition: border-color .15s;
  outline: none;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

input[type="color"] {
  padding: 2px 4px;
  width: 44px;
  height: 36px;
  cursor: pointer;
}
.color-input-row { display: flex; gap: 8px; align-items: center; }
.color-input-row input[type="text"] { flex: 1; }

/* ── Toggle ────────────────────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

.toggle-row { flex-direction: row; align-items: center; justify-content: space-between; }
.toggle-inline { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }

/* ── Tables ────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: var(--surface-2);
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.table-loading, .table-empty { text-align: center; color: var(--text-muted); padding: 2rem; }

/* ── Modals ────────────────────────────────────────────────── */
.modal { display: none; position: fixed; inset: 0; z-index: 1000; align-items: center; justify-content: center; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
.modal-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  z-index: 1;
}
.modal-box-lg { max-width: 720px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-form { padding: 20px 24px; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ── Toast ─────────────────────────────────────────────────── */
#toastContainer {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  box-shadow: var(--shadow-md);
  font-size: 14px;
  animation: slideIn .2s ease;
  max-width: 320px;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Loading ───────────────────────────────────────────────── */
.loading-spinner {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}
.loading-spinner::after {
  content: "";
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stat-card.loading .stat-value::after {
  content: "";
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h2 { color: var(--text); margin-bottom: .5rem; }
.empty-state p { margin-bottom: 1.5rem; }

/* ── Error ─────────────────────────────────────────────────── */
.error-msg { color: var(--danger); font-size: 13px; }

/* ── Misc ──────────────────────────────────────────────────── */
.ticket-num { font-family: monospace; font-weight: 600; color: var(--accent); }
