/* ========================================
   shadcn/ui inspired styles for Support Bot
   ======================================== */

/* CSS Variables - shadcn color palette */
:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 5.9% 10%;
  --radius: 0.5rem;

  /* Semantic colors */
  --success: 142 76% 36%;
  --success-foreground: 0 0% 100%;
  --warning: 38 92% 50%;
  --warning-foreground: 0 0% 0%;
  --info: 221 83% 53%;
  --info-foreground: 0 0% 100%;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: hsl(var(--info));
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: hsl(221 83% 43%);
}

/* Layout utilities */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Spacing */
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-0\.5 { padding-top: 0.125rem; padding-bottom: 0.125rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.ml-auto { margin-left: auto; }

/* Typography */
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.text-4xl { font-size: 2.25rem; line-height: 2.5rem; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.tracking-tight { letter-spacing: -0.025em; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.uppercase { text-transform: uppercase; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Colors */
.text-muted { color: hsl(var(--muted-foreground)); }
.text-primary { color: hsl(var(--primary)); }
.text-success { color: hsl(var(--success)); }
.text-warning { color: hsl(var(--warning)); }
.text-destructive { color: hsl(var(--destructive)); }
.text-info { color: hsl(var(--info)); }
.text-white { color: white; }

/* Legacy color classes for compatibility */
.text-gray-500 { color: hsl(var(--muted-foreground)); }
.text-gray-600 { color: hsl(240 3.8% 46.1%); }
.text-gray-700 { color: hsl(240 5.2% 33.9%); }
.text-red-600 { color: hsl(var(--destructive)); }
.text-green-600 { color: hsl(var(--success)); }
.text-blue-600 { color: hsl(var(--info)); }
.text-yellow-600 { color: hsl(var(--warning)); }

/* Backgrounds */
.bg-background { background: hsl(var(--background)); }
.bg-muted { background: hsl(var(--muted)); }
.bg-card { background: hsl(var(--card)); }
.bg-primary { background: hsl(var(--primary)); }
.bg-secondary { background: hsl(var(--secondary)); }

/* Legacy background classes */
.bg-white { background: hsl(var(--background)); }
.bg-gray-50 { background: hsl(var(--muted)); }
.bg-gray-100 { background: hsl(var(--secondary)); }
.bg-blue-600 { background: hsl(var(--info)); }
.bg-green-100 { background: hsl(142 76% 94%); }
.bg-yellow-100 { background: hsl(38 92% 94%); }
.bg-red-100 { background: hsl(0 84% 94%); }

/* Width & Layout */
.w-full { width: 100%; }
.max-w-xs { max-width: 20rem; }
.max-w-sm { max-width: 24rem; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }
.max-w-2xl { max-width: 42rem; }
.min-h-screen { min-height: 100vh; }

/* Borders */
.border { border: 1px solid hsl(var(--border)); }
.border-b { border-bottom: 1px solid hsl(var(--border)); }
.border-t { border-top: 1px solid hsl(var(--border)); }
.rounded { border-radius: calc(var(--radius) - 2px); }
.rounded-md { border-radius: calc(var(--radius)); }
.rounded-lg { border-radius: calc(var(--radius) + 2px); }
.rounded-xl { border-radius: calc(var(--radius) + 4px); }
.rounded-full { border-radius: 9999px; }

/* Shadows */
.shadow-sm { box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); }
.shadow { box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1); }
.shadow-md { box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); }
.shadow-lg { box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); }

/* ========================================
   Components
   ======================================== */

/* Card */
.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
}

.card-header {
  padding: 1.5rem 1.5rem 0;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: hsl(var(--foreground));
}

.card-description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

.card-content {
  padding: 1.5rem;
}

.card-footer {
  padding: 0 1.5rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Stat Card */
.stat-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: all 0.2s ease;
}

.stat-card:hover {
  border-color: hsl(var(--ring));
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

/* Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring));
}

.btn:disabled {
  pointer-events: none;
  opacity: 0.5;
}

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.btn-primary:hover {
  background: hsl(240 5.9% 20%);
}

.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--border));
}

.btn-secondary:hover {
  background: hsl(240 4.8% 90%);
}

.btn-outline {
  background: transparent;
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}

.btn-outline:hover {
  background: hsl(var(--accent));
}

.btn-ghost {
  background: transparent;
  color: hsl(var(--foreground));
}

.btn-ghost:hover {
  background: hsl(var(--accent));
}

.btn-success {
  background: hsl(var(--success));
  color: hsl(var(--success-foreground));
}

.btn-success:hover {
  background: hsl(142 76% 30%);
}

.btn-danger {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.btn-danger:hover {
  background: hsl(0 84% 50%);
}

.btn-sm {
  height: 2rem;
  padding: 0 0.75rem;
  font-size: 0.8125rem;
}

.btn-lg {
  height: 2.75rem;
  padding: 0 2rem;
  font-size: 1rem;
}

.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
}

/* Input */
.input {
  display: flex;
  width: 100%;
  height: 2.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  color: hsl(var(--foreground));
  transition: all 0.2s ease;
}

.input::placeholder {
  color: hsl(var(--muted-foreground));
}

.input:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.1);
}

.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Textarea */
.textarea {
  display: flex;
  width: 100%;
  min-height: 5rem;
  padding: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  font-family: inherit;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  color: hsl(var(--foreground));
  resize: vertical;
  transition: all 0.2s ease;
}

.textarea:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.1);
}

/* Select */
.select {
  display: flex;
  height: 2.5rem;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-size: 0.875rem;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  color: hsl(var(--foreground));
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1rem;
  transition: all 0.2s ease;
}

.select:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.1);
}

/* Label */
.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  margin-bottom: 0.5rem;
}

/* Form Group */
.form-group {
  margin-bottom: 1rem;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.25rem;
  border-radius: 9999px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.badge-default {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.badge-new {
  background: hsl(38 92% 90%);
  color: hsl(38 92% 30%);
  border-color: hsl(38 92% 80%);
}

.badge-waiting {
  background: hsl(221 83% 93%);
  color: hsl(221 83% 40%);
  border-color: hsl(221 83% 85%);
}

.badge-approved {
  background: hsl(142 76% 90%);
  color: hsl(142 76% 30%);
  border-color: hsl(142 76% 80%);
}

.badge-rejected {
  background: hsl(0 84% 92%);
  color: hsl(0 84% 40%);
  border-color: hsl(0 84% 85%);
}

.badge-executed {
  background: hsl(142 76% 90%);
  color: hsl(142 76% 25%);
  border-color: hsl(142 76% 75%);
}

.badge-closed {
  background: hsl(220 13% 91%);
  color: hsl(220 9% 46%);
  border-color: hsl(220 13% 80%);
}

.badge-failed {
  background: hsl(0 84% 92%);
  color: hsl(0 84% 35%);
  border-color: hsl(0 84% 80%);
}

/* Alert */
.alert {
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.alert-info {
  background: hsl(221 83% 96%);
  border-color: hsl(221 83% 85%);
  color: hsl(221 83% 35%);
}

.alert-success {
  background: hsl(142 76% 94%);
  border-color: hsl(142 76% 80%);
  color: hsl(142 76% 30%);
}

.alert-warning {
  background: hsl(38 92% 94%);
  border-color: hsl(38 92% 80%);
  color: hsl(38 92% 30%);
}

.alert-error {
  background: hsl(0 84% 95%);
  border-color: hsl(0 84% 85%);
  color: hsl(0 84% 40%);
}

/* ========================================
   Header / Navigation
   ======================================== */

.header {
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  letter-spacing: -0.025em;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo:hover {
  color: hsl(var(--foreground));
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  border-radius: var(--radius);
  text-decoration: none;
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--accent));
  text-decoration: none;
}

.nav-link.active {
  color: hsl(var(--foreground));
  background: hsl(var(--secondary));
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
}

.user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ========================================
   Table
   ======================================== */

.table-wrapper {
  overflow-x: auto;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 500;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted));
  border-bottom: 1px solid hsl(var(--border));
  white-space: nowrap;
}

.table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: middle;
}

.table tbody tr {
  transition: background 0.15s ease;
}

.table tbody tr:hover {
  background: hsl(var(--muted) / 0.5);
}

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

.table-clickable tbody tr {
  cursor: pointer;
}

/* ========================================
   Ticket / Message Styles
   ======================================== */

.ticket-info {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.ticket-info-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ticket-info-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ticket-info-value {
  font-size: 0.875rem;
  color: hsl(var(--foreground));
}

.message {
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.message-customer {
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
}

.message-support {
  background: hsl(221 83% 96%);
  border: 1px solid hsl(221 83% 90%);
  margin-left: 2rem;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

.message-body {
  font-size: 0.875rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Draft editor */
.draft-editor {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
}

.draft-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: hsl(var(--muted));
  border-bottom: 1px solid hsl(var(--border));
}

.draft-content {
  padding: 1rem;
}

.draft-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: hsl(var(--muted));
  border-top: 1px solid hsl(var(--border));
}

/* ========================================
   Login Page
   ======================================== */

.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  background: linear-gradient(135deg, hsl(var(--muted)) 0%, hsl(var(--background)) 100%);
}

.login-card {
  width: 100%;
  max-width: 24rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 10px 40px -10px rgb(0 0 0 / 0.15);
  overflow: hidden;
}

.login-header {
  padding: 2rem 2rem 1.5rem;
  text-align: center;
}

.login-logo {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  letter-spacing: -0.025em;
}

.login-subtitle {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

.login-form {
  padding: 0 2rem 2rem;
}

/* ========================================
   Empty States
   ======================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-bottom: 0.5rem;
}

.empty-state-description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  max-width: 20rem;
}

/* ========================================
   Pagination
   ======================================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  margin-top: 1.5rem;
}

.pagination-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  text-decoration: none;
  transition: all 0.15s ease;
}

.pagination-btn:hover {
  background: hsl(var(--accent));
  text-decoration: none;
}

.pagination-btn.active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

.pagination-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ========================================
   Filters
   ======================================== */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}

/* ========================================
   Page Header
   ======================================== */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: hsl(var(--foreground));
}

.page-description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

/* ========================================
   HTMX States
   ======================================== */

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-flex;
}

.htmx-request.htmx-indicator {
  display: inline-flex;
}

/* Loading spinner */
.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid hsl(var(--muted));
  border-top-color: hsl(var(--primary));
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Skeleton loading */
.skeleton {
  background: linear-gradient(
    90deg,
    hsl(var(--muted)) 25%,
    hsl(var(--muted) / 0.5) 50%,
    hsl(var(--muted)) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
  .container {
    padding: 0 1rem;
  }

  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .hide-mobile {
    display: none !important;
  }

  .show-mobile {
    display: block !important;
  }

  .table-wrapper {
    margin: 0 -1rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .page-title {
    font-size: 1.5rem;
  }

  /* Mobile card layout for tables */
  .table-mobile-cards .table thead {
    display: none;
  }

  .table-mobile-cards .table tbody tr {
    display: block;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--card));
  }

  .table-mobile-cards .table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.5rem 0;
    border-bottom: none;
  }

  .table-mobile-cards .table tbody td::before {
    content: attr(data-label);
    font-weight: 500;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    text-transform: uppercase;
    flex-shrink: 0;
    margin-right: 1rem;
  }

  /* Ticket detail mobile */
  .ticket-info {
    grid-template-columns: 1fr;
  }

  .message-support {
    margin-left: 0;
  }

  /* Filters mobile */
  .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group .select {
    width: 100%;
  }

  /* Form mobile */
  .form-row {
    flex-direction: column;
  }

  /* Buttons mobile */
  .btn-group-mobile {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .btn-group-mobile .btn {
    width: 100%;
    justify-content: center;
  }

  /* Card padding mobile */
  .card-content {
    padding: 1rem;
  }

  .card-header {
    padding: 1rem 1rem 0;
  }

  /* Stat cards mobile */
  .stat-card {
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  /* Draft section mobile */
  .draft-actions {
    flex-direction: column;
  }

  .draft-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Login mobile */
  .login-header {
    padding: 1.5rem 1.5rem 1rem;
  }

  .login-form {
    padding: 0 1.5rem 1.5rem;
  }
}

@media (max-width: 640px) {
  .grid-cols-2,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }

  /* Even smaller screens */
  .container {
    padding: 0 0.75rem;
  }

  .py-8 {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }

  .mb-6 {
    margin-bottom: 1rem;
  }

  .gap-6 {
    gap: 1rem;
  }
}

/* Touch-friendly tap targets */
@media (pointer: coarse) {
  .btn {
    min-height: 44px;
  }

  .input, .select, .textarea {
    min-height: 44px;
  }

  .nav-link {
    padding: 0.75rem 1rem;
  }

  .table td {
    padding: 0.875rem 1rem;
  }
}

/* ========================================
   Utility: Display
   ======================================== */

.block { display: block; }
.inline-block { display: inline-block; }
.inline-flex { display: inline-flex; }
.hidden { display: none; }

/* Utility: Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

/* Utility: Cursor */
.cursor-pointer { cursor: pointer; }

/* Utility: Selection */
.select-none { user-select: none; }

/* ========================================
   Toast Notifications
   ======================================== */

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.15), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  min-width: 280px;
  max-width: 400px;
}

.toast-success {
  border-left: 4px solid hsl(var(--success));
}

.toast-success .toast-icon {
  color: hsl(var(--success));
}

.toast-error {
  border-left: 4px solid hsl(var(--destructive));
}

.toast-error .toast-icon {
  color: hsl(var(--destructive));
}

.toast-info {
  border-left: 4px solid hsl(var(--info));
}

.toast-info .toast-icon {
  color: hsl(var(--info));
}

.toast-icon {
  font-size: 1.125rem;
  font-weight: 600;
  flex-shrink: 0;
}

.toast-message {
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  line-height: 1.4;
}

/* ========================================
   Animations
   ======================================== */

.animate-slide-in {
  animation: slideIn 0.3s ease-out;
}

.animate-fade-out {
  animation: fadeOut 0.3s ease-out forwards;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Button loading state */
.btn-loading {
  position: relative;
  pointer-events: none;
}

.btn-loading .spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Fixed positioning utilities */
.fixed { position: fixed; }
.bottom-4 { bottom: 1rem; }
.right-4 { right: 1rem; }
.z-50 { z-index: 50; }

/* Flexbox utilities */
.flex-row-reverse { flex-direction: row-reverse; }
.flex-shrink-0 { flex-shrink: 0; }

/* Spacing utilities */
.space-y-4 > * + * { margin-top: 1rem; }
.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }

/* Width utilities */
.w-8 { width: 2rem; }
.h-8 { height: 2rem; }
.max-w-85 { max-width: 85%; }

/* Chat bubble colors */
.bg-blue-50 { background-color: #eff6ff; }
.bg-blue-100 { background-color: #dbeafe; }
.bg-green-50 { background-color: #f0fdf4; }
.border-blue-100 { border-color: #dbeafe; }
.border-green-100 { border-color: #dcfce7; }
.text-blue-500 { color: #3b82f6; }
.text-blue-800 { color: #1e40af; }
.text-green-500 { color: #22c55e; }
.text-green-700 { color: #15803d; }
.text-green-800 { color: #166534; }
.text-gray-400 { color: #9ca3af; }
.text-gray-800 { color: #1f2937; }

/* Purple badge for needs_human */
.bg-purple-100 { background-color: #f3e8ff; }
.text-purple-800 { color: #6b21a8; }

/* Priority row styles */
.priority-urgent { background-color: #fef2f2 !important; border-left: 4px solid #dc2626 !important; }
.priority-high { background-color: #fffbeb !important; border-left: 4px solid #f59e0b !important; }
.priority-normal { border-left: 4px solid transparent; }
.priority-low { opacity: 0.7; border-left: 4px solid #d1d5db; }

.priority-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.priority-badge-urgent { background: #fee2e2; color: #991b1b; }
.priority-badge-high { background: #fef3c7; color: #92400e; }
.priority-badge-normal { background: #f3f4f6; color: #4b5563; }
.priority-badge-low { background: #f9fafb; color: #9ca3af; }

.category-icon { font-size: 16px; margin-right: 4px; }
.risk-flags { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.risk-flag { font-size: 12px; padding: 1px 6px; border-radius: 4px; background: #fef2f2; color: #991b1b; }

/* Quoted text in messages */
.message-quote {
    display: block;
    border-left: 2px solid #d1d5db;
    padding-left: 0.5rem;
    margin: 0.25rem 0;
}

/* Line clamp utility for truncating text */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Mobile ticket cards - ensure clickability */
.md\:hidden a.block,
.lg\:hidden a.block {
    display: block;
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
}

/* Ticket item touch states */
.ticket-item {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
}
