/* =====================================================
   Ticket App — Mobile-First Stylesheet
   Base: dark theme variables
   ===================================================== */

:root {
  --bg: #141414;
  --panel: #1e1e1e;
  --panel-hover: #242424;
  --border: #2d2d2d;
  --muted: #6b7280;
  --text: #e5e7eb;
  --text-bright: #f9fafb;
  --primary: #22c55e;
  --accent: #38bdf8;
  --danger: #ef4444;
  --warn: #f59e0b;
  --success: #10b981;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* =====================================================
   Light Mode Overrides
   ===================================================== */
body.light-mode {
  --bg: #f0f4f8;
  --panel: #ffffff;
  --panel-hover: #f1f5f9;
  --border: #e2e8f0;
  --muted: #64748b;
  --text: #334155;
  --text-bright: #0f172a;
  --accent: #0284c7;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body.light-mode .app-header {
  background: #dde3ec;
  border-bottom-color: #c8cdd5;
}

body.light-mode input,
body.light-mode select,
body.light-mode textarea,
body.light-mode .input {
  background: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
}

body.light-mode input:focus,
body.light-mode select:focus,
body.light-mode textarea:focus,
body.light-mode .input:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2,132,199,0.12);
}

body.light-mode .tab-btn {
  color: var(--text);
}

body.light-mode .bottom-nav {
  background: #ffffff;
  border-top-color: #e2e8f0;
}

body.light-mode .ticket-card {
  background: #ffffff;
  border-color: #e2e8f0;
}

body.light-mode .ticket-card:active {
  background: #f1f5f9;
}

body.light-mode .filter-btn {
  border-color: #cbd5e1;
  color: var(--text);
}

/* =====================================================
   Reset & Base
   ===================================================== */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* =====================================================
   App Header
   ===================================================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 12px;
}

.app-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-bright);
  white-space: nowrap;
}

/* Desktop: tabs in the header */
.tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.tab-btn {
  padding: 6px 14px;
  font-size: 13px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.session-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

/* =====================================================
   Main Container
   ===================================================== */
.app-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 12px 12px 80px; /* bottom pad for bottom-nav */
}

/* =====================================================
   Bottom Nav (mobile only — shown via media query)
   ===================================================== */
.bottom-nav {
  display: none; /* hidden by default; shown on mobile */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  z-index: 200;
  align-items: stretch;
  justify-content: space-around;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
}

.bottom-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  gap: 2px;
  min-height: 44px;
  padding: 6px 4px;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-btn.active {
  color: var(--accent);
}

.bottom-nav-btn:active {
  background: var(--panel-hover);
}

.bnav-icon {
  font-size: 20px;
  line-height: 1;
}

.bnav-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* =====================================================
   Mobile overrides
   ===================================================== */
@media (max-width: 768px) {
  /* Hide header tabs on mobile — bottom nav takes over */
  .app-header .tabs {
    display: none;
  }

  /* Show bottom nav */
  .bottom-nav {
    display: flex;
  }

  /* Shrink header on mobile */
  .app-header {
    padding: 8px 12px;
  }

  .app-container {
    padding: 10px 10px 72px;
  }

  /* Hide logout button in header on mobile (use settings tab) */
  .session-actions .btn#btn-logout {
    display: none;
  }
}

/* =====================================================
   Ticket Cards
   ===================================================== */
#tickets-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ticket-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  cursor: pointer;
  transition: background 0.12s;
  /* left border is set inline per urgency */
  min-height: 44px;
  box-shadow: var(--shadow);
}

.ticket-card:hover,
.ticket-card:active {
  background: var(--panel-hover);
}

.ticket-card.selected {
  background: var(--panel-hover);
  border-color: var(--accent);
}

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

.tc-number {
  font-family: monospace;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.tc-category {
  font-size: 12px;
  color: var(--muted);
}

.tc-client {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 4px;
}

.tc-desc {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 8px;
  /* 2-line clamp */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.tc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tc-due {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.tc-due.overdue {
  color: var(--danger);
  font-weight: 600;
}

/* =====================================================
   Status & Urgency Badges (light-mode-aware)
   ===================================================== */
.badge-status,
.badge-urgency {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}

/* Status: dark mode inline styles used in JS are fine;
   light mode overrides for status chips */
body.light-mode .status-open        { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
body.light-mode .status-in_progress { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
body.light-mode .status-on_hold     { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
body.light-mode .status-closed      { background: #dcfce7; color: #14532d; border-color: #86efac; }
body.light-mode .status-cancelled   { background: #f3f4f6; color: #374151; border-color: #d1d5db; }

/* Urgency: light mode overrides */
body.light-mode .urgency-Critical { background: #fee2e2; color: #7f1d1d; border-color: #fca5a5; }
body.light-mode .urgency-High     { background: #ffedd5; color: #7c2d12; border-color: #fdba74; }
body.light-mode .urgency-Elevated { background: #fef9c3; color: #713f12; border-color: #fde047; }
body.light-mode .urgency-Standard { background: #dbeafe; color: #1e3a5f; border-color: #93c5fd; }
body.light-mode .urgency-Low      { background: #f3f4f6; color: #374151; border-color: #d1d5db; }

/* =====================================================
   Filter Buttons
   ===================================================== */
.filters-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filter-btn {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  min-height: 36px;
  -webkit-tap-highlight-color: transparent;
}

.filter-btn.active {
  background: var(--accent);
  color: #0f172a;
  border-color: var(--accent);
  font-weight: 600;
}

.filter-btn:hover:not(.active) {
  background: var(--panel-hover);
  color: var(--text);
}

/* =====================================================
   Buttons
   ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  min-height: 36px;
}

.btn:hover {
  background: var(--panel-hover);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0f172a;
  font-weight: 600;
}

.btn.primary:hover {
  opacity: 0.9;
}

.btn.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn.danger:hover {
  background: rgba(239,68,68,0.1);
}

/* =====================================================
   Inputs
   ===================================================== */
.input,
input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  background: #111111;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font: inherit;
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,0.12);
}

/* =====================================================
   Panel / Card
   ===================================================== */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

/* =====================================================
   Utility
   ===================================================== */
.muted { color: var(--muted); }
.text-bright { color: var(--text-bright); }

.empty-state {
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* =====================================================
   Modal (Settings)
   ===================================================== */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.open { display: flex; }

.modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.modal-sm { max-width: 380px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-bright);
}

.modal-body { padding: 20px 24px; }

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.settings-row label {
  margin: 0;
  font-weight: 500;
  color: var(--text);
}

.settings-btns { display: flex; gap: 8px; }
