/* ════════════════════════════════════════════════════════════════
   SST Tickets — Minimalist UI with urgency-driven color system
   ════════════════════════════════════════════════════════════════ */

:root {
  /* Surface */
  --bg:           #f7f7f5;
  --surface:      #ffffff;
  --surface-2:    #fafaf9;
  --border:       #e7e5e4;
  --border-2:     #d6d3d1;

  /* Text */
  --text:         #0c0a09;
  --text-2:       #44403c;
  --text-3:       #78716c;
  --text-muted:   #a8a29e;

  /* Brand accent */
  --accent:       #0c0a09;
  --accent-soft:  #1c1917;

  /* Priority colors */
  --p-urgent:     #dc2626;
  --p-urgent-bg:  #fef2f2;
  --p-high:       #ea580c;
  --p-high-bg:    #fff7ed;
  --p-medium:     #ca8a04;
  --p-medium-bg:  #fefce8;
  --p-low:        #2563eb;
  --p-low-bg:     #eff6ff;

  /* Status colors */
  --s-new:           #6366f1;
  --s-progress:      #0ea5e9;
  --s-awaiting:      #d97706;
  --s-done:          #16a34a;

  /* System */
  --success:      #16a34a;
  --error:        #dc2626;
  --shadow-sm:    0 1px 2px rgba(0,0,0,.04);
  --shadow:       0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --radius:       10px;
  --radius-lg:    14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: 'cv11','ss01','ss03';
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 14px;
  z-index: 50;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 24px; }
.brand-mark {
  width: 34px; height: 34px;
  background: var(--accent); color: #fff;
  border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 11px; letter-spacing: .05em;
}
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.1; }
.brand-sub  { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500; font-size: 13.5px;
  transition: background .12s, color .12s;
}
.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .7; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.is-active {
  background: var(--accent);
  color: #fff;
}
.nav-link.is-active svg { opacity: 1; }

.sidebar-footer {
  display: flex; align-items: center; gap: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.user-chip {
  flex: 1;
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
}
.user-chip:hover { background: var(--surface-2); }
.avatar {
  width: 30px; height: 30px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.user-meta { line-height: 1.2; min-width: 0; }
.user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-3); text-transform: capitalize; }
.logout {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--text-3);
}
.logout svg { width: 16px; height: 16px; }
.logout:hover { background: var(--surface-2); color: var(--text); }

.menu-toggle {
  display: none;
  position: fixed; top: 12px; left: 12px;
  z-index: 60;
  width: 40px; height: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  align-items: center; justify-content: center;
}
.menu-toggle svg { width: 20px; height: 20px; }

/* ── Main ──────────────────────────────────────────────────── */
.main { padding: 28px 36px 60px; max-width: 1280px; margin: 0 auto; }
.main.with-sidebar { padding-left: 276px; padding-right: 36px; max-width: none; margin: 0; }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 24px;
}
.page-header h1 {
  margin: 0; font-size: 24px; font-weight: 700;
  letter-spacing: -.02em;
}
.page-header .sub { margin-top: 4px; color: var(--text-3); font-size: 13px; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--accent); color: #fff;
  border: 1px solid var(--accent);
  border-radius: 8px;
  font: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: transform .06s, opacity .12s;
}
.btn:hover { opacity: .9; }
.btn:active { transform: scale(.98); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-2);
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--error); border-color: var(--error); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn svg { width: 14px; height: 14px; }

/* ── Inputs ────────────────────────────────────────────────── */
.input, .select, .textarea {
  display: block; width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  font: inherit; font-size: 14px;
  color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(12,10,9,.08);
}
.textarea { resize: vertical; min-height: 100px; line-height: 1.5; }

.field { margin-bottom: 16px; }
.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; letter-spacing: .01em; }
.field-hint  { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.field-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}

/* ── Auth pages ────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 20px;
  background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
}
.auth-card .brand { padding: 0 0 22px; }
.auth-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; }
.auth-card .sub { color: var(--text-3); margin-bottom: 22px; font-size: 13.5px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 11px; }
.auth-card .below {
  margin-top: 18px; text-align: center; font-size: 13px; color: var(--text-3);
}
.auth-card a { color: var(--accent); text-decoration: none; font-weight: 500; }
.auth-card a:hover { text-decoration: underline; }

/* ── Flash ─────────────────────────────────────────────────── */
.flash {
  padding: 11px 14px; border-radius: 8px;
  margin-bottom: 18px;
  font-size: 13.5px;
  display: flex; justify-content: space-between; align-items: center;
  border: 1px solid;
}
.flash-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.flash-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.flash-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.flash-close   { background: none; border: 0; font-size: 20px; cursor: pointer; color: inherit; opacity: .6; line-height: 1; }
.flash-close:hover { opacity: 1; }

/* ── Ticket list ───────────────────────────────────────────── */
.todo-section { margin-bottom: 28px; }
.todo-section-title {
  display: flex; align-items: baseline; gap: 8px;
  margin: 0 0 10px;
  font-size: 11.5px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3);
}
.todo-section-count {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  letter-spacing: 0;
}

.ticket-list { display: flex; flex-direction: column; gap: 8px; }

.ticket-card {
  position: relative;
  display: grid;
  grid-template-columns: 4px 1fr auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform .08s, box-shadow .12s, border-color .12s;
}
.ticket-card:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow);
}
.ticket-card.is-done { opacity: .65; }
.ticket-card.is-overdue .ticket-due { color: var(--p-urgent); font-weight: 600; }

.ticket-stripe { width: 4px; }
.priority-urgent .ticket-stripe { background: var(--p-urgent); }
.priority-high   .ticket-stripe { background: var(--p-high); }
.priority-medium .ticket-stripe { background: var(--p-medium); }
.priority-low    .ticket-stripe { background: var(--p-low); }

.ticket-body { padding: 13px 16px; min-width: 0; }
.ticket-title-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
}
.ticket-title {
  font-weight: 600; font-size: 14.5px;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.ticket-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  color: var(--text-3); font-size: 12px;
}
.ticket-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.ticket-meta .dot {
  width: 3px; height: 3px; background: var(--text-muted); border-radius: 50%;
}

.ticket-aside {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px;
}

/* Priority pill */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  font-size: 11px; font-weight: 600;
  border-radius: 6px;
  white-space: nowrap;
}
.pill-priority-urgent { background: var(--p-urgent-bg); color: var(--p-urgent); }
.pill-priority-high   { background: var(--p-high-bg);   color: var(--p-high); }
.pill-priority-medium { background: var(--p-medium-bg); color: var(--p-medium); }
.pill-priority-low    { background: var(--p-low-bg);    color: var(--p-low); }

.pill-status-new             { background: #eef2ff; color: var(--s-new); }
.pill-status-in_progress     { background: #f0f9ff; color: var(--s-progress); }
.pill-status-awaiting_client { background: #fff7ed; color: var(--s-awaiting); }
.pill-status-done            { background: #f0fdf4; color: var(--s-done); }

.pill-cat {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}

/* Empty state */
.empty {
  text-align: center; padding: 50px 20px;
  color: var(--text-3);
  background: var(--surface);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-lg);
}
.empty h3 { margin: 0 0 4px; font-size: 15px; color: var(--text-2); }
.empty p { margin: 0; font-size: 13px; }

/* ── Filter bar ────────────────────────────────────────────── */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 18px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filter-bar .input, .filter-bar .select { padding: 7px 10px; font-size: 13px; height: 34px; }
.filter-bar .search { flex: 1; min-width: 200px; }
.filter-bar .select { min-width: 130px; }

/* ── Ticket detail ─────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0,1fr) 280px;
  gap: 22px;
}

.ticket-head { margin-bottom: 18px; }
.ticket-head h1 {
  margin: 0 0 8px; font-size: 22px; font-weight: 700;
  letter-spacing: -.01em; line-height: 1.3;
}
.ticket-head .meta {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  font-size: 12.5px; color: var(--text-3);
}

.ticket-desc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 22px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-2);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.attachments {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 12px;
}
.attachment-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text-2);
  text-decoration: none;
}
.attachment-chip:hover { background: var(--surface); border-color: var(--border-2); }
.attachment-chip svg { width: 13px; height: 13px; opacity: .6; }
.attachment-chip .size { color: var(--text-3); font-size: 11px; }

/* Conversation */
.thread { display: flex; flex-direction: column; gap: 14px; }
.response {
  display: grid; grid-template-columns: 32px 1fr; gap: 12px;
}
.response-author { color: var(--text); font-weight: 600; font-size: 13px; }
.response-time   { color: var(--text-3); font-size: 12px; }
.response-content {
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.response.is-mine .response-content { background: #fafaf6; }

.response-form {
  margin-top: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.response-form .file-row {
  display: flex; gap: 8px; align-items: center; margin-top: 10px;
}

/* Sidebar info panel */
.detail-side .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
}
.detail-side h4 {
  margin: 0 0 10px; font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3);
}
.kv { display: flex; flex-direction: column; gap: 10px; }
.kv-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; }
.kv-key { color: var(--text-3); }
.kv-val { color: var(--text); font-weight: 500; text-align: right; }

/* Tables */
.table {
  width: 100%; border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table th, .table td {
  padding: 10px 14px; text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.table th { background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--surface-2); }

/* Badge dot */
.badge-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px;
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
}
.modal h3 { margin: 0 0 14px; font-size: 17px; }

/* Tag input */
.tag-input-wrap {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  min-height: 40px;
}
.tag-input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(12,10,9,.08); }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 4px 2px 8px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 12px;
  border: 1px solid var(--border);
}
.tag-chip button {
  width: 18px; height: 18px;
  background: none; border: 0; padding: 0;
  cursor: pointer; opacity: .5;
  font-size: 14px;
}
.tag-chip button:hover { opacity: 1; }
.tag-input-wrap input {
  flex: 1; min-width: 100px;
  border: 0; outline: 0; background: none;
  font: inherit; font-size: 13px;
  padding: 4px;
}

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .main.with-sidebar { padding: 64px 16px 40px; }
  .menu-toggle { display: inline-flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    width: 260px;
    box-shadow: 0 0 50px rgba(0,0,0,.2);
  }
  body.menu-open .sidebar { transform: translateX(0); }
  body.menu-open::after {
    content: ''; position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 49;
  }
  .field-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .ticket-aside { padding: 0 16px 13px; }
}

@media (max-width: 600px) {
  .page-header { flex-direction: column; align-items: stretch; }
  .ticket-card { grid-template-columns: 4px 1fr; }
  .ticket-aside {
    grid-column: 2; padding: 0 16px 12px;
    flex-wrap: wrap;
  }
}
