/* ============================================================================
   Mandira Travel Helpdesk — style.css
   Theme: Dark industrial ops-center with warm amber accents
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --bg: #0a0d14;
  --surface: #111622;
  --surface2: #181f2e;
  --border: #1e2a3d;
  --border2: #2a3a50;

  --accent: #f0a500;
  --accent-dim: #f0a50030;
  --accent-glow: #f0a50015;

  --text: #dce3f0;
  --text-dim: #7a8aaa;
  --text-muted: #4a5568;

  --blue: #3b82f6;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --purple: #8b5cf6;

  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 4px 20px rgba(0, 0, 0, .5);

  --font: 'Sora', sans-serif;
  --mono: 'JetBrains Mono', monospace;

  --sidebar-w: 220px;
}

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

html {
  font-size: 14px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── Login Page ─────────────────────────────────────────────────────────────── */
body.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 30% 20%, #1a1200 0%, var(--bg) 60%);
}

.login-wrap {
  width: 100%;
  max-width: 400px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.login-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow), 0 0 60px rgba(240, 165, 0, .06);
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 56px;
  height: 56px;
  background: var(--accent);
  color: #0a0d14;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 18px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: 0 0 24px rgba(240, 165, 0, .3);
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-footer {
  font-size: 12px;
  color: var(--text-muted);
}

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

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #0a0d14;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
  gap: 2px;
  border-bottom: 1px solid var(--border);
}

.nav-item,
.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 13px;
  transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.nav-item:hover,
.filter-item:hover {
  background: var(--surface2);
  color: var(--text);
  transform: translateX(4px);
  text-decoration: none;
}

.nav-item.active,
.filter-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
  transform: translateX(4px);
}

.nav-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
}

.sidebar-section-label {
  padding: 12px 18px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--text-muted);
}

.sidebar-filters {
  display: flex;
  flex-direction: column;
  padding: 4px 8px;
  gap: 1px;
  flex: 1;
}

.sidebar-user {
  padding: 12px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}

.user-avatar {
  width: 30px;
  height: 30px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 50%;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--accent);
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.logout-btn {
  color: var(--text-muted);
  font-size: 16px;
  padding: 4px;
  cursor: pointer;
  background: none;
  border: none;
  transition: color .15s;
}

.logout-btn:hover {
  color: var(--red);
  text-decoration: none;
}

/* ── Main Content ───────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 24px 28px;
  min-width: 0;
  overflow-x: hidden;
}

/* ── Page Header ────────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.page-header-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.ticket-count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--border);
}

/* ── Search form ────────────────────────────────────────────────────────────── */
.search-form {
  display: flex;
  gap: 6px;
  align-items: center;
}

.search-input {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  padding: 6px 12px;
  font-family: var(--font);
  font-size: 13px;
  width: 240px;
  outline: none;
  transition: border-color .15s;
}

.search-input:focus {
  border-color: var(--accent);
}

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  border-left: 3px solid;
}

.alert-success {
  background: #10b98115;
  border-color: var(--green);
  color: var(--green);
}

.alert-error {
  background: #ef444415;
  border-color: var(--red);
  color: var(--red);
}

.alert-warn {
  background: #f59e0b15;
  border-color: var(--amber);
  color: var(--amber);
}

/* ── Section Card ───────────────────────────────────────────────────────────── */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.section-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead {
  background: var(--surface2);
}

.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.data-table tbody tr:hover {
  background: var(--surface2);
}

.data-table .row-new td {
  border-left: 2px solid var(--blue);
}

.data-table .row-new td:first-child {
  padding-left: 12px;
}

.data-table .row-current {
  background: var(--accent-glow) !important;
}

.text-center {
  text-align: center;
}

/* ── Tickets table specifics ────────────────────────────────────────────────── */
.tickets-table {
  background: var(--surface);
  border-radius: var(--radius-lg);
}

.ticket-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
}

.booking-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.ticket-subject {
  font-size: 13px;
  color: var(--text);
}

.fw-bold {
  font-weight: 600;
}

.meta-text {
  font-size: 12px;
  color: var(--text-dim);
}

.date-text {
  font-size: 12px;
  color: var(--text-dim);
}

.snippet {
  font-size: 12px;
  color: var(--text-muted);
}

.unassigned {
  color: var(--text-muted);
}

.assignee-chip {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 12px;
  color: var(--text);
}

.step-tag {
  display: inline-block;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 500;
}

.msg-count {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 99px;
  padding: 1px 7px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .02em;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.channel-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border2);
  color: var(--text-dim);
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #0a0d14;
}

.btn-primary:hover {
  background: #ffb624;
  box-shadow: 0 0 16px rgba(240, 165, 0, .3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border2);
}

.btn-ghost:hover {
  background: var(--surface2);
  color: var(--text);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid #ef444440;
}

.btn-danger:hover {
  background: #ef444415;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 10px 20px;
  font-size: 14px;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
}

.btn-full {
  width: 100%;
}

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: -3px;
}

.form-input,
.form-select,
.form-textarea,
.search-input {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
  width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M6 8L0 0h12z' fill='%237a8aaa'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.form-textarea {
  resize: vertical;
  line-height: 1.5;
}

.code-textarea {
  font-family: var(--mono);
  font-size: 12px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.rules-checkboxes {
  display: flex;
  gap: 24px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.checkbox-item input[type=checkbox] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.inline-input {
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--text);
  padding: 3px 8px;
  font-size: 13px;
  font-family: var(--font);
  outline: none;
}

.inline-select {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--font);
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
  max-width: 180px;
}

.inline-select:focus {
  border-color: var(--accent);
}

.edit-inline-btn {
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all .15s;
  margin-left: 6px;
}

.edit-inline-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}

/* ── Ticket Header Card ─────────────────────────────────────────────────────── */
.ticket-header-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: 0 0 30px rgba(240, 165, 0, .04);
}

.ticket-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
  flex-wrap: wrap;
}

.ticket-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ticket-id-large {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}

.ticket-subject-heading {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 18px;
}

.ticket-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.meta-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.meta-value {
  font-size: 13px;
  color: var(--text);
}

.meta-editable {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── Ticket body layout ─────────────────────────────────────────────────────── */
.ticket-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

@media (max-width: 1100px) {
  .ticket-body {
    grid-template-columns: 1fr;
  }
}

.ticket-messages-col,
.ticket-reply-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Message thread ─────────────────────────────────────────────────────────── */
.message-thread {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 500px;
  overflow-y: auto;
}

.message-bubble {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.message-bubble.inbound {
  border-left: 3px solid var(--blue);
}

.message-bubble.outbound {
  border-left: 3px solid var(--green);
  margin-left: 24px;
}

.message-bubble-header {
  background: var(--surface2);
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.msg-direction-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.message-bubble.inbound .msg-direction-label {
  color: var(--blue);
}

.message-bubble.outbound .msg-direction-label {
  color: var(--green);
}

.msg-from {
  font-size: 12px;
  color: var(--text-dim);
  flex: 1;
}

.msg-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.message-bubble-body {
  padding: 12px;
}

.email-html-preview {
  font-size: 13px;
  color: var(--text);
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.6;
}

.email-text-preview {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}

/* ── Reply builder ──────────────────────────────────────────────────────────── */
.reply-builder {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reply-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.reply-row {
  display: flex;
  flex-direction: column;
}

.reply-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.step-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all .2s;
}

.step-hint.hint-visible {
  background: var(--accent-dim);
  color: var(--accent);
}

.reply-preview-area {
  min-height: 180px;
  background: #fff;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 14px;
  color: #222;
  font-size: 13px;
  line-height: 1.6;
  font-family: Arial, sans-serif;
  outline: none;
  transition: border-color .15s;
  overflow-y: auto;
}

.reply-preview-area:focus {
  border-color: var(--accent);
}

.reply-preview-area:empty::before {
  content: attr(data-placeholder);
  color: #aaa;
  font-style: italic;
}

.reply-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.reply-status-msg {
  font-size: 12px;
  margin-left: auto;
}

.reply-status-msg.ok {
  color: var(--green);
}

.reply-status-msg.err {
  color: var(--red);
}

/* ── Template editor layout ─────────────────────────────────────────────────── */
.template-editor-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 1000px) {
  .template-editor-layout {
    grid-template-columns: 1fr;
  }
}

.template-editor-form {
  padding: 20px;
}

.template-editor-form .section-header {
  margin: -20px -20px 16px;
  padding: 14px 18px;
}

.template-preview-pane {
  padding: 0;
}

.email-preview-wrap {
  padding: 16px;
}

.email-preview-header {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.email-preview-body {
  background: #fff;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 16px;
  color: #333;
  font-size: 13px;
  line-height: 1.6;
  min-height: 200px;
}

/* ── Breadcrumb ─────────────────────────────────────────────────────────────── */
.breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb a {
  color: var(--text-dim);
}

.breadcrumb a:hover {
  color: var(--accent);
}

.bc-sep {
  color: var(--text-muted);
}

/* ── Current/chip indicators ────────────────────────────────────────────────── */
.current-chip {
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
}

.bool-indicator {
  font-weight: 700;
  font-size: 14px;
}

.bool-true {
  color: var(--green);
}

.bool-false {
  color: var(--text-muted);
}

/* ── Empty states ───────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-muted);
  max-width: 400px;
  margin: 0 auto;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 20px;
  filter: grayscale(0.5);
  opacity: 0.7;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text-dim);
  margin-bottom: 10px;
  font-weight: 600;
}

.empty-state p {
  font-size: 14px;
  line-height: 1.5;
}

.empty-state-sm {
  padding: 32px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}