* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
}

body {
  background: #f4f6f9;
  color: #1f2937;
}

.hidden {
  display: none !important;
}

/* ===================== LOGIN ===================== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2563eb, #1e3a8a);
  padding: 20px;
}

.login-box {
  background: #fff;
  padding: 32px;
  border-radius: 10px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.login-box h1 {
  font-size: 22px;
  margin-bottom: 4px;
  color: #1e3a8a;
}

.subtitle {
  color: #6b7280;
  margin-bottom: 20px;
  font-size: 14px;
}

.login-box label {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
  margin-top: 12px;
  color: #374151;
}

.login-box input {
  width: 100%;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}

.hint-box {
  margin-top: 20px;
  background: #f0f4ff;
  border: 1px solid #dbeafe;
  padding: 12px;
  border-radius: 6px;
  font-size: 12px;
  color: #374151;
}

.hint-box p {
  margin-top: 4px;
}

/* ===================== BUTTONS ===================== */
.btn-primary {
  width: 100%;
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 11px;
  margin-top: 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  width: 100%;
  background: transparent;
  color: #ef4444;
  border: 1px solid #ef4444;
  padding: 10px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  margin-top: auto;
}

.btn-secondary:hover {
  background: #fef2f2;
}

.form-submit-btn {
  width: auto;
  padding: 10px 18px;
}

.form-btn-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  max-width: 500px;
}

.form-btn-row button {
  margin-top: 0;
}

/* ===================== APP LAYOUT ===================== */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: #1e293b;
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.sidebar-header p {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 20px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}

.nav-btn {
  text-align: left;
  background: transparent;
  border: none;
  color: #cbd5e1;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.nav-btn:hover {
  background: #334155;
}

.nav-btn.active {
  background: #2563eb;
  color: #fff;
}

.content {
  flex: 1;
  padding: 28px 36px;
  overflow-y: auto;
}

.content h2 {
  margin-bottom: 18px;
  color: #1e293b;
}

.content h3 {
  margin: 20px 0 10px;
  color: #1e293b;
  font-size: 16px;
}

.content h4 {
  margin: 14px 0 8px;
  color: #1e293b;
  font-size: 14px;
}

/* ===================== CARDS / STATS ===================== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.stat-card h3 {
  font-size: 26px;
  color: #2563eb;
  margin-bottom: 4px;
}

.stat-card p {
  color: #6b7280;
  font-size: 13px;
}

.section-note {
  color: #6b7280;
  font-size: 14px;
  margin-bottom: 18px;
}

/* ===================== DASHBOARD ===================== */
.dashboard-search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.dash-search {
  margin-bottom: 0;
  flex: 1;
  min-width: 200px;
}

.dash-ask-btn {
  width: auto;
  margin-top: 0;
  padding: 10px 18px;
  white-space: nowrap;
}

.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 10px;
}

.dash-card {
  background: #fff;
  border-radius: 8px;
  padding: 18px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.dash-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}

.dash-card h4 {
  font-size: 14px;
  color: #1e293b;
  margin-bottom: 8px;
  margin-top: 0;
}

.dash-card p {
  font-size: 26px;
  color: #2563eb;
  font-weight: bold;
}

.dash-card span {
  font-size: 12px;
  color: #6b7280;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.quick-action-btn {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.quick-action-btn:hover {
  background: #dbeafe;
}

.result-type-tag {
  display: inline-block;
  margin-top: 8px;
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
}

/* ===================== SEARCH ===================== */
.search-input {
  width: 100%;
  max-width: 400px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 18px;
}

/* ===================== KNOWLEDGE BASE ===================== */
.kb-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.kb-card {
  background: #fff;
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.kb-card h4 {
  color: #1e3a8a;
  margin-bottom: 6px;
  margin-top: 8px;
  font-size: 15px;
}

.kb-card p {
  font-size: 13px;
  color: #4b5563;
}

.kb-tag {
  display: inline-block;
  margin-top: 8px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
}

.kb-read-more {
  display: block;
  margin-top: 12px;
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  width: auto;
}

.kb-read-more:hover {
  background: #1d4ed8;
}

.kb-detail {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  max-width: 700px;
}

.kb-detail h3 {
  margin: 12px 0 14px;
  color: #1e293b;
}

.kb-detail p {
  color: #4b5563;
  font-size: 14px;
  line-height: 1.6;
}

.kb-detail label {
  display: block;
  margin-top: 12px;
  margin-bottom: 4px;
  font-size: 13px;
  color: #374151;
}

.kb-detail input,
.kb-detail textarea,
.kb-detail select {
  width: 100%;
  max-width: 500px;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}

.kb-back-btn {
  width: auto;
  margin-top: 0;
  margin-bottom: 16px;
  padding: 8px 14px;
  font-size: 13px;
}

.admin-list-spacing {
  margin-top: 18px;
}

/* ===================== FAQ ===================== */
.faq-item {
  background: #fff;
  border-radius: 8px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: hidden;
}

.faq-question {
  padding: 14px 16px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #1e293b;
}

.faq-question-text {
  font-weight: 600;
}

.faq-category-tag {
  display: inline-block;
  margin-top: 6px;
  background: #f0fdf4;
  color: #15803d;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
}

.faq-answer {
  padding: 0 16px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease, padding 0.2s ease;
  font-size: 13px;
  color: #4b5563;
}

.faq-answer.open {
  padding: 0 16px 14px;
  max-height: 300px;
}

/* ===================== CHAT ===================== */
.chat-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.chat-header-row h2 {
  margin-bottom: 0;
}

.clear-chat-btn {
  width: auto;
  margin-top: 0;
  padding: 8px 14px;
  font-size: 13px;
}

.chat-window {
  background: #fff;
  border-radius: 8px;
  height: 420px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.static-chat-window {
  height: 320px;
  margin-top: 10px;
}

.chat-window .empty-state {
  margin: auto;
  box-shadow: none;
}

.chat-msg {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.4;
}

.chat-msg.user {
  align-self: flex-end;
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 2px;
}

.chat-msg.ai {
  align-self: flex-start;
  background: #f1f5f9;
  color: #1f2937;
  border-bottom-left-radius: 2px;
}

.chat-source-note {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: #94a3b8;
  font-style: italic;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.chat-input-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}

.chat-input-row button {
  width: 120px;
  margin-top: 0;
}

/* ===================== FORMS ===================== */
#ticketSection label,
#adminTicketDetailView label {
  display: block;
  margin-top: 12px;
  margin-bottom: 4px;
  font-size: 13px;
  color: #374151;
}

#ticketSection input,
#ticketSection select,
#ticketSection textarea,
#adminTicketDetailView select,
#adminTicketDetailView textarea {
  width: 100%;
  max-width: 500px;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}

.form-row {
  display: flex;
  gap: 16px;
  max-width: 500px;
  flex-wrap: wrap;
}

.form-col {
  flex: 1;
  min-width: 160px;
}

/* ===================== TICKET LIST ===================== */
.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.ticket-card {
  background: #fff;
  padding: 14px 16px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.ticket-card h4 {
  font-size: 14px;
  color: #1e293b;
  margin-bottom: 4px;
  margin-top: 0;
}

.ticket-card p {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

.ticket-card-desc {
  font-size: 13px;
  color: #374151;
  margin-top: 6px;
}

.ticket-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
}

.badge-category {
  background: #eff6ff;
  color: #2563eb;
}

.priority-low {
  background: #f0fdf4;
  color: #15803d;
}

.priority-medium {
  background: #fef3c7;
  color: #92400e;
}

.priority-high {
  background: #fef2f2;
  color: #b91c1c;
}

.status-open {
  background: #fef3c7;
  color: #92400e;
}

.status-in-progress {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-waiting-for-customer {
  background: #ede9fe;
  color: #6d28d9;
}

.status-resolved {
  background: #d1fae5;
  color: #065f46;
}

.status-closed {
  background: #e5e7eb;
  color: #374151;
}

.status-new {
  background: #fef3c7;
  color: #92400e;
}

.status-reviewed {
  background: #d1fae5;
  color: #065f46;
}

.status-needs-knowledge-article {
  background: #fee2e2;
  color: #b91c1c;
}

.comment-heading {
  margin-top: 22px;
}

.comment-card {
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: #374151;
}

.comment-card span {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}

.action-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.small-btn {
  width: auto;
  margin-top: 0;
  padding: 6px 12px;
  font-size: 12px;
}

.btn-outline {
  background: transparent;
  color: #2563eb;
  border: 1px solid #2563eb;
}

.btn-outline:hover {
  background: #eff6ff;
}

.btn-danger {
  background: transparent;
  color: #ef4444;
  border: 1px solid #ef4444;
}

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

/* ===================== BAR STATS / CHARTS ===================== */
.bar-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
  max-width: 550px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-label {
  width: 140px;
  flex-shrink: 0;
  color: #374151;
}

.bar-track {
  flex: 1;
  background: #e5e7eb;
  border-radius: 6px;
  height: 16px;
  overflow: hidden;
}

.bar-fill {
  background: #2563eb;
  height: 100%;
}

/* ===================== STATES ===================== */
.error-message {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
  max-width: 500px;
}

.success-message {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
  max-width: 500px;
}

.loading-state {
  color: #6b7280;
  font-size: 13px;
  font-style: italic;
  padding: 10px 0;
}

.empty-state {
  color: #9ca3af;
  font-size: 13px;
  padding: 20px;
  text-align: center;
  background: #fff;
  border-radius: 8px;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .sidebar-header {
    width: 100%;
  }

  .nav-menu {
    flex-direction: row;
    flex-wrap: wrap;
    flex: none;
    width: 100%;
    max-height: none;
  }

  .nav-btn {
    flex: 1 1 auto;
    text-align: center;
    font-size: 12px;
  }

  .btn-secondary {
    margin-top: 10px;
  }

  .content {
    padding: 20px;
  }

  .chat-msg {
    max-width: 90%;
  }

  .form-row {
    flex-direction: column;
  }
}
