/* ============================================================
   CSS Custom Properties — Light Mode (default)
   ============================================================ */
:root {
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-card: #ffffff;
  --text: #212529;
  --text-muted: #6c757d;
  --border: #dee2e6;
  --brand: #0083BE;
  --btn-primary: var(--brand);
  --btn-primary-hover: color-mix(in srgb, var(--brand) 85%, black);
  --status-red: #d9534f;
  --status-amber: #f0ad4e;
  --status-green: #5cb85c;
  --status-grey: #adb5bd;
  --overlay: rgba(0, 0, 0, 0.4);
  --shadow: 0 2px 8px rgba(0,0,0,0.10);
  --shadow-slide: -4px 0 24px rgba(0,0,0,0.12);
}

/* ============================================================
   Dark Mode
   ============================================================ */
[data-theme="dark"] {
  --bg: #1e1e1e;
  --bg-secondary: #252526;
  --bg-card: #2d2d30;
  --text: #e0e0e0;
  --text-muted: #a0a0a0;
  --border: #404040;
  --brand: #0083BE;
  --btn-primary: var(--brand);
  --btn-primary-hover: color-mix(in srgb, var(--brand) 85%, black);
  --overlay: rgba(0, 0, 0, 0.6);
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-slide: -4px 0 24px rgba(0,0,0,0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s, color 0.2s;
  min-height: 100vh;
  overflow-y: scroll;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   Header
   ============================================================ */
.site-header {
  background: var(--brand);
  color: #fff;
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-actions .display-name {
  font-size: 0.9rem;
  opacity: 0.9;
}

/* ============================================================
   Dark Mode Toggle
   ============================================================ */
.dark-toggle {
  background: none;
  border: 1px solid rgba(255,255,255,0.5);
  color: #fff;
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  line-height: 0;
  display: flex;
  align-items: center;
}

.dark-toggle svg { display: block; }

.dark-toggle:hover { background: rgba(255,255,255,0.15); }

/* ============================================================
   Site Nav
   ============================================================ */
.site-nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.site-nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  gap: 0;
}

.site-nav-link {
  display: inline-block;
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.site-nav-link:hover {
  color: var(--text);
  text-decoration: none;
}

.site-nav-link.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

/* ============================================================
   Main Content
   ============================================================ */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ============================================================
   Tickets Toolbar (filter tabs + search + new ticket)
   ============================================================ */
.tickets-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.filter-tabs {
  display: flex;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

.filter-tab {
  padding: 0.4rem 0.9rem;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.filter-tab + .filter-tab { border-left: 1px solid var(--border); }

.filter-tab.active {
  background: var(--btn-primary);
  color: #fff;
}

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

.search-input {
  flex: 1;
  min-width: 320px;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.search-input:focus {
  outline: none;
  border-color: var(--brand);
}

.search-input::placeholder { color: var(--text-muted); }

/* ============================================================
   Section Headers
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--btn-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--btn-primary-hover); color: #fff; text-decoration: none; }

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); text-decoration: none; }

/* ============================================================
   Ticket Table
   ============================================================ */
.ticket-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 2.5rem;
}

.ticket-table th:nth-child(1) { width: 170px; }   /* Status */
.ticket-table th:nth-child(2) { width: auto; }     /* Subject — takes remaining space */
.ticket-table th:nth-child(3) { width: 100px; }   /* Type */
.ticket-table th:nth-child(4) { width: 110px; }   /* Date */

.ticket-table th {
  background: var(--bg-secondary);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.ticket-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.ticket-table tr:last-child td { border-bottom: none; }

.ticket-row {
  cursor: pointer;
  transition: background 0.1s;
}
.ticket-row:hover { background: var(--bg-secondary); }

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.ticket-ref {
  display: block;
  font-size: 0.7rem;
  font-family: monospace;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.1rem;
}

/* ============================================================
   Status Dot
   ============================================================ */
.status-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.red    { background: var(--status-red); }
.status-dot.amber  { background: var(--status-amber); }
.status-dot.green  { background: var(--status-green); }
.status-dot.grey   { background: var(--status-grey); }

/* ============================================================
   Type Badge
   ============================================================ */
.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-issue   { background: #fde8e8; color: #c0392b; }
.badge-request { background: #e8f4fd; color: #1a6fa8; }

[data-theme="dark"] .badge-issue   { background: #5a2020; color: #f1948a; }
[data-theme="dark"] .badge-request { background: #1a3a5c; color: #7ec8e3; }

/* ============================================================
   Slide-Out Panel
   ============================================================ */
.slide-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 100;
}

.slide-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 480px;
  max-width: 95vw;
  background: var(--bg-card);
  box-shadow: var(--shadow-slide);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.slide-panel.open { transform: translateX(0); }
.slide-overlay.open { display: block; }

.slide-header {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
}

.slide-ref {
  font-size: 0.72rem;
  font-weight: 600;
  font-family: monospace;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.slide-header-info h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.slide-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.slide-close:hover { color: var(--text); }

/* Messages area (scrollable) */
.slide-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.no-history {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  margin-top: 1rem;
}

/* ============================================================
   Chat Bubbles
   ============================================================ */
.message-wrap {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}

.message-wrap.inbound {
  align-self: flex-end;
  align-items: flex-end;
}

.message-wrap.outbound,
.message-wrap.unknown {
  align-self: flex-start;
  align-items: flex-start;
}

.message-bubble {
  padding: 0.6rem 0.85rem;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  word-break: break-word;
}

.message-wrap.inbound .message-bubble {
  background: #dbeafe;
  color: #1e3a8a;
  border-bottom-right-radius: 4px;
}

[data-theme="dark"] .message-wrap.inbound .message-bubble {
  background: #1e3a5c;
  color: #93c5fd;
}

.message-wrap.outbound .message-bubble {
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message-wrap.unknown .message-bubble {
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message-text p { margin-bottom: 0.4em; }
.message-text p:last-child { margin-bottom: 0; }
.message-text ul,
.message-text ol { margin: 0.3em 0 0.4em 1.2em; }
.message-text li { margin-bottom: 0.2em; }

.message-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  padding: 0 0.2rem;
}

/* ============================================================
   Reply Area (bottom of panel)
   ============================================================ */
.slide-reply {
  flex-shrink: 0;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

/* Attached file chips above the input row */
.reply-file-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0;
}

.reply-file-list:not(:empty) {
  margin-bottom: 0.5rem;
}

.reply-file-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
}

.reply-file-item-icon { flex-shrink: 0; color: var(--text-muted); }

.reply-file-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.reply-file-remove {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.1rem;
  display: flex;
  align-items: center;
  line-height: 1;
}

.reply-file-remove:hover { color: var(--status-red); }

/* Input row: pill area + circular send button */
.reply-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.reply-area {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.45rem 0.65rem 0.45rem 0.85rem;
  background: var(--bg-secondary);
}

.reply-textarea {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  outline: none;
  line-height: 1.5;
  overflow-y: auto;
  max-height: 160px;
  display: block;
  padding: 0;
}

.reply-paperclip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem 0;
  transition: color 0.15s;
}

.reply-paperclip:hover { color: var(--brand); }

.reply-file-input { display: none; }

/* Circular send button */
.reply-send-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.15s;
}

.reply-send-btn:hover:not(:disabled) { filter: brightness(1.1); }

.reply-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}


/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border-radius: 12px;
  width: 540px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

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

.modal-header h2 { font-size: 1.1rem; font-weight: 600; }

.modal-body { padding: 1.25rem 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem 1.25rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ============================================================
   Form Elements
   ============================================================ */
.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand);
}

textarea.form-control { resize: vertical; min-height: 100px; }

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.alert-danger  { background: #fde8e8; color: #922; border: 1px solid #f5c6cb; }
.alert-success { background: #e8fde8; color: #295; border: 1px solid #c3e6cb; }

[data-theme="dark"] .alert-danger  { background: #4a1010; color: #f1948a; }
[data-theme="dark"] .alert-success { background: #104a10; color: #82e0aa; }

/* ============================================================
   Auth Pages (Login, Forgot Password, Reset Password)
   ============================================================ */
.auth-container {
  display: flex;
  justify-content: center;
  padding-top: 2rem;
}

.auth-card {
  width: 400px;
  max-width: 100%;
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 2rem;
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  text-align: center;
}

.auth-link {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.85rem;
}

/* Header brand — flex so logo and text sit side by side */
.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: none;
}

.header-brand:hover {
  text-decoration: none;
  color: #fff;
}

.header-logo {
  max-height: 36px;
  width: auto;
  display: block;
}
