/* Sitzdesign Admin Dashboard */
:root {
  --primary: #2c3e50;
  --primary-light: #34495e;
  --accent: #c0963c;
  --accent-light: #d4a84e;
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #e74c3c;
  --info: #3498db;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #e8e8e8;
  --sidebar-w: 240px;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

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

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: white;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px;
  font-size: 18px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  letter-spacing: 0.3px;
}
.sidebar-logo span { color: var(--accent); }

.sidebar-nav { flex: 1; padding: 12px 0; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  text-decoration: none;
  transition: all 0.15s;
}
.sidebar-nav a:hover { color: white; background: rgba(255,255,255,0.08); }
.sidebar-nav a.active { color: white; background: rgba(255,255,255,0.12); border-right: 3px solid var(--accent); }
.sidebar-nav a svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }

.sidebar-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 24px 32px;
  max-width: 1200px;
}

/* === Header === */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 24px; font-weight: 700; }
.page-header .subtitle { color: var(--text-light); font-size: 13px; margin-top: 2px; }

/* === Cards === */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 16px; font-weight: 600; }

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

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; fill: white; }
.stat-icon.open { background: var(--danger); }
.stat-icon.pending { background: var(--warning); }
.stat-icon.resolved { background: var(--success); }
.stat-icon.total { background: var(--info); }

.stat-info .stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-info .stat-label { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* === Table === */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--text-light);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
}
table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table tr:hover td { background: #fafbfc; }
table tr { cursor: pointer; }

/* === Badges === */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-open { background: #fdecea; color: var(--danger); }
.badge-pending { background: #fef3e2; color: #e67e22; }
.badge-resolved { background: #e8f8ef; color: var(--success); }
.badge-closed { background: #eee; color: #888; }
.badge-chat { background: #e8f0fe; color: var(--info); }
.badge-email { background: #fce4ec; color: #c62828; }

/* === Conversation === */
.conv-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }

.messages-list {
  max-height: 500px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 13.5px;
}
.msg.customer { background: #e3f2fd; align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.agent { background: var(--primary); color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.bot { background: #f5f5f5; align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-meta { font-size: 11px; color: var(--text-light); margin-top: 4px; }

.ai-suggestion {
  background: linear-gradient(135deg, #fff9e6, #fff3cd);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
}
.ai-suggestion h3 { font-size: 13px; color: var(--accent); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.ai-suggestion pre {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 12px;
}

.customer-sidebar .sidebar-section { margin-bottom: 20px; }
.customer-sidebar .sidebar-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}
.customer-sidebar .info-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.customer-sidebar .info-row .label { color: var(--text-light); }

/* === Forms === */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--primary); outline: none; }
.form-group textarea { resize: vertical; min-height: 100px; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-light); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #2ecc71; }
.btn-outline { background: white; color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-danger { background: var(--danger); color: white; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* === Knowledge === */
.knowledge-item {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.knowledge-item:last-child { border-bottom: none; }
.knowledge-item h4 { font-size: 14px; margin-bottom: 4px; }
.knowledge-item p { font-size: 13px; color: var(--text-light); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.knowledge-item .meta { font-size: 11px; color: var(--text-light); margin-top: 6px; display: flex; gap: 12px; }

/* === Alerts === */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.alert-info { background: #e8f0fe; color: #1565c0; }
.alert-success { background: #e8f8ef; color: #1b5e20; }
.alert-warning { background: #fff8e1; color: #e65100; }

/* === Tabs === */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.tab {
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  text-decoration: none;
  transition: all 0.15s;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-light);
}
.empty-state svg { width: 48px; height: 48px; fill: var(--border); margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* === Responsive === */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 16px; }
  .conv-layout { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* === Loading === */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Truncate === */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
