/* Sothik AI Support Portal — Modern, Low-Saturation Warm Theme */

:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-raised: #f5f3f0;
  --text: #1f1d1b;
  --text-secondary: #6b6560;
  --text-muted: #9a9590;
  --border: #e8e4df;
  --border-light: #f0ece7;
  --accent: #8b7355;
  --accent-light: #a68b6a;
  --accent-bg: #f5f0e8;
  --danger: #b85450;
  --danger-bg: #fdf0ef;
  --warning: #c28a3a;
  --warning-bg: #fdf6ec;
  --success: #5a8f6e;
  --success-bg: #eef5f1;
  --info: #5a7a8f;
  --info-bg: #eef2f5;
  --shadow-sm: 0 1px 2px rgba(31, 29, 27, 0.04);
  --shadow: 0 4px 12px rgba(31, 29, 27, 0.06);
  --shadow-lg: 0 8px 24px rgba(31, 29, 27, 0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', Menlo, Consolas, monospace;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.portal-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 32px;
  padding-left: 8px;
  letter-spacing: -0.3px;
}

.sidebar-nav { list-style: none; }

.sidebar-nav li { margin-bottom: 4px; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.sidebar-nav a:hover { background: var(--accent-bg); color: var(--accent); }

.sidebar-nav a.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 32px;
  max-width: 1400px;
}

/* Top bar */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.top-bar h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
}

.top-bar .actions { display: flex; gap: 10px; align-items: center; }

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.stat-card:hover { box-shadow: var(--shadow); }

.stat-card .label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.stat-card .value.high { color: var(--danger); }

.stat-card .value.medium { color: var(--warning); }

.stat-card .value.low { color: var(--text-muted); }

.stat-card .value.success { color: var(--success); }

/* Table */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.data-table th {
  background: var(--surface-raised);
  padding: 12px 16px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13.5px;
  color: var(--text);
  vertical-align: top;
}

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

.data-table tr:hover td { background: var(--accent-bg); }

.data-table a { color: var(--accent); text-decoration: none; font-weight: 500; }

.data-table a:hover { text-decoration: underline; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-priority-high { background: var(--danger-bg); color: var(--danger); }

.badge-priority-medium { background: var(--warning-bg); color: var(--warning); }

.badge-priority-low { background: #f0f0f0; color: var(--text-muted); }

.badge-status-open { background: var(--info-bg); color: var(--info); }

.badge-status-resolved { background: var(--success-bg); color: var(--success); }

.badge-status-pending { background: var(--warning-bg); color: var(--warning); }

.badge-status-closed { background: #f0f0f0; color: var(--text-muted); }

.badge-ai { background: var(--accent-bg); color: var(--accent); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }

.btn-primary:hover { background: var(--accent-light); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }

.btn-secondary:hover { background: var(--surface-raised); }

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

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

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

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

.card-body { font-size: 13.5px; color: var(--text-secondary); line-height: 1.6; }

/* Forms */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 115, 85, 0.08);
}

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

/* Ticket detail */
.ticket-detail { display: grid; grid-template-columns: 1fr 320px; gap: 24px; }

.ticket-main { min-width: 0; }

.ticket-sidebar { min-width: 0; }

.ticket-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.ticket-header h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }

.ticket-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-secondary); }

.ticket-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}

/* AI Analysis Box */
.ai-box {
  background: var(--accent-bg);
  border: 1px solid #e8dfd2;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.ai-box-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ai-box-body { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }

.ai-box-body p { margin-bottom: 8px; }

/* Reply thread */
.reply-thread { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }

.reply-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.reply-item.ai-reply { border-left: 3px solid var(--accent); }

.reply-item.system-reply { border-left: 3px solid var(--info); background: var(--info-bg); }

.reply-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 12.5px;
}

.reply-author { font-weight: 600; color: var(--text); }

.reply-author.ai { color: var(--accent); }

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

.reply-body { font-size: 13.5px; line-height: 1.6; color: var(--text); white-space: pre-wrap; }

/* Project context sidebar */
.context-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.context-panel h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.context-item { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 8px; }

.context-item .label { color: var(--text-muted); }

.context-item .value { color: var(--text); font-weight: 500; }

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}

.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid #d8e0e7; }

.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #d8e7dd; }

.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #e7d8c0; }

.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #e7d0ce; }

/* Responsive */
@media (max-width: 900px) {
  .sidebar { width: 64px; padding: 16px 8px; }
  .sidebar-brand { display: none; }
  .sidebar-nav a { padding: 10px; justify-content: center; }
  .sidebar-nav a span { display: none; }
  .main-content { margin-left: 64px; padding: 20px; }
  .ticket-detail { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .top-bar { flex-direction: column; align-items: flex-start; gap: 12px; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 10px 8px; }
}

/* Utility */
.text-center { text-align: center; }

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

.text-sm { font-size: 12px; }

.mb-4 { margin-bottom: 16px; }

.mt-4 { margin-top: 16px; }

.hidden { display: none; }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Code / preformatted */
pre, code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--surface-raised);
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--text);
}

pre { padding: 12px; overflow-x: auto; }

/* Search bar */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  max-width: 400px;
}

.search-bar input {
  border: none;
  background: none;
  outline: none;
  font-size: 13px;
  width: 100%;
  color: var(--text);
}

/* Pagination */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 20px; }

.pagination a, .pagination span {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.pagination a { background: var(--surface); color: var(--text); border: 1px solid var(--border); }

.pagination a:hover { background: var(--accent-bg); color: var(--accent); }

.pagination span.current { background: var(--accent); color: #fff; }

.pagination span.disabled { color: var(--text-muted); border: 1px solid var(--border-light); }

/* Client support files */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.toolbar input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  min-width: 220px;
  color: var(--text);
  background: var(--surface);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 20px;
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-header h2 {
  font-size: 20px;
  margin: 0 0 4px;
}

.repo-block {
  border-top: 1px solid var(--border-light);
  padding-top: 16px;
  margin-top: 16px;
}

.repo-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 10px;
}

.repo-title > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.source-type-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-raised);
}

.data-table.compact th,
.data-table.compact td {
  padding: 8px 10px;
  vertical-align: top;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  color: var(--text-muted);
  background: var(--surface);
}
