
:root {
  /* Shadcn-inspired Design System */

  /* Spacing Scale */
  --spacing-1: 0.25rem;   /* 4px */
  --spacing-2: 0.5rem;    /* 8px */
  --spacing-3: 0.75rem;   /* 12px */
  --spacing-4: 1rem;      /* 16px */
  --spacing-5: 1.25rem;   /* 20px */
  --spacing-6: 1.5rem;    /* 24px */
  --spacing-8: 2rem;      /* 32px */
  --spacing-10: 2.5rem;   /* 40px */
  --spacing-12: 3rem;     /* 48px */
  --spacing-16: 4rem;     /* 64px */
  --spacing-20: 5rem;     /* 80px */
  --spacing-24: 6rem;     /* 96px */

  /* Border Radius */
  --radius-sm: 0.125rem;  /* 2px */
  --radius-md: 0.375rem;  /* 6px */
  --radius-lg: 0.5rem;    /* 8px */
  --radius-xl: 0.75rem;   /* 12px */
  --radius-2xl: 1rem;     /* 16px */

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* Typography */
  --font-sans:  -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Source Code Pro', monospace;

  /* Font Sizes */
  --text-xs: 0.75rem;     /* 12px */
  --text-sm: 0.875rem;    /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.25rem;     /* 20px */
  --text-2xl: 1.5rem;     /* 24px */
  --text-3xl: 1.875rem;   /* 30px */
  --text-4xl: 2.25rem;    /* 36px */
  --text-5xl: 3rem;       /* 48px */

  /* Font Weights */
  --font-light: 300;
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* Line Heights */
  --leading-none: 1;
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 2;

  /* Light Theme Colors */
  --background: 0 0% 100%;
  --foreground: 0 0% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 0 0% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 0 0% 3.9%;
  --primary: 0 0% 9%;
  --primary-foreground: 0 0% 98%;
  --secondary: 0 0% 96.1%;
  --secondary-foreground: 0 0% 9%;
  --muted: 0 0% 90%;
  --muted-foreground: 0 0% 45.1%;
  --accent: 0 0% 96.1%;
  --accent-foreground: 0 0% 9%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --success: 142.1 76.2% 36.3%;
  --success-foreground: 355.7 100% 97.3%;
  --warning: 32.2 94.6% 43.7%;
  --warning-foreground: 210 40% 98%;
  --border: 0 0% 89.8%;
  --input: 0 0% 89.8%;
  --ring: 0 0% 3.9%;
  --radius: 0.5rem;
}

[data-theme="dark"] {
  --background: 0 0% 3.9%;
  --foreground: 0 0% 98%;
  --card: 0 0% 3.9%;
  --card-foreground: 0 0% 98%;
  --popover: 0 0% 3.9%;
  --popover-foreground: 0 0% 98%;
  --primary: 0 0% 98%;
  --primary-foreground: 0 0% 9%;
  --secondary: 0 0% 14.9%;
  --secondary-foreground: 0 0% 98%;
  --muted: 0 0% 8%;
  --muted-foreground: 0 0% 63.9%;
  --accent: 0 0% 14.9%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 62.8% 30.6%;
  --destructive-foreground: 0 0% 98%;
  --success: 142.1 70.6% 45.3%;
  --success-foreground: 0 0% 98%;
  --warning: 32.2 94.6% 43.7%;
  --warning-foreground: 210 40% 98%;
  --border: 0 0% 14.9%;
  --input: 0 0% 14.9%;
  --ring: 0 0% 83.1%;
}

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

* {
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  line-height: var(--leading-normal);
  color: hsl(var(--foreground));
  background-color: hsl(var(--background));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
  margin-bottom: var(--spacing-4);
  color: hsl(var(--foreground));
}

h1 {
  font-size: var(--text-4xl);
  line-height: var(--leading-none);
  margin-bottom: var(--spacing-8);
}

h2 {
  font-size: var(--text-3xl);
  margin-bottom: var(--spacing-6);
}

h3 {
  font-size: var(--text-2xl);
  margin-bottom: var(--spacing-4);
}

h4 {
  font-size: var(--text-xl);
  margin-bottom: var(--spacing-4);
}

h5 {
  font-size: var(--text-lg);
  margin-bottom: var(--spacing-3);
}

h6 {
  font-size: var(--text-base);
  margin-bottom: var(--spacing-3);
}

p {
  margin-bottom: var(--spacing-4);
  color: hsl(var(--foreground));
}

ul, ol {
  margin-bottom: var(--spacing-4);
  padding-left: var(--spacing-6);
}

ul {
  list-style-type: disc;
}

ol {
  list-style-type: decimal;
}

li {
  margin-bottom: var(--spacing-2);
}



/* Button Base Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  border-radius: var(--radius-md);
  padding: var(--spacing-2) var(--spacing-4);
  transition: all 0.2s ease-in-out;
  cursor: pointer;
  border: 1px solid transparent;
  background-color: transparent;
  color: hsl(var(--foreground));
  text-decoration: none;
  line-height: var(--leading-none);
  position: relative;
  overflow: hidden;
}

.btn:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

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

/* Button Variants */
.btn-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

.btn-primary:hover:not(:disabled) {
  background-color: hsl(var(--primary) / 0.9);
}

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

.btn-secondary:hover:not(:disabled) {
  background-color: hsl(var(--secondary) / 0.8);
}

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

.btn-ghost:hover:not(:disabled) {
  background-color: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

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

.btn-destructive:hover:not(:disabled) {
  background-color: hsl(var(--destructive) / 0.9);
}

/* Button Sizes */
.btn-sm {
  padding: var(--spacing-1) var(--spacing-3);
  font-size: var(--text-xs);
}





/* Theme Toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  padding: var(--spacing-2);
  border-radius: var(--radius-md);
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  background: hsl(var(--muted) / 0.8);
}

.theme-toggle-icon {
  width: var(--spacing-4);
  height: var(--spacing-4);
  color: hsl(var(--foreground));
  transition: transform 0.2s ease;
}

.theme-toggle[data-theme="dark"] .theme-toggle-icon {
  transform: rotate(180deg);
}

/* Refresh Button */
.refresh-button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-2);
  border-radius: var(--radius-md);
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  cursor: pointer;
  transition: all 0.2s ease;
  width: 32px;
  height: 32px;
}

.refresh-button:hover {
  background: hsl(var(--muted) / 0.8);
  transform: scale(1.05);
}

.refresh-button:active {
  transform: scale(0.95);
}

.refresh-icon {
  width: var(--spacing-4);
  height: var(--spacing-4);
  transition: transform 0.3s ease;
  color: hsl(var(--foreground));
}

.refresh-button.refreshing .refresh-icon {
  animation: spin 1s linear infinite;
}

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

/* Form Elements */
input, textarea, select {
  display: block;
  width: 100%;
  padding: var(--spacing-3) var(--spacing-4);
  font-size: var(--text-sm);
  font-family: inherit;
  line-height: var(--leading-normal);
  color: hsl(var(--foreground));
  background-color: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

input:disabled, textarea:disabled, select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

textarea {
  min-height: var(--spacing-10);
  resize: none;
}

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right var(--spacing-3) center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

.model-link {
  color: hsl(var(--primary));
  display: inline-flex;
  font-size: var(--text-xs);
  margin-top: var(--spacing-2);
  text-decoration: none;
  transition: color 0.2s ease;
}

.model-link:hover {
  color: hsl(var(--primary) / 0.8);
  text-decoration: underline;
}

/* Layout Components */
.content {
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  max-width: 1200px;
  min-height: 100dvh;
  width: 100%;
  padding: 0 var(--spacing-4);
}

.card {
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-6);
  transition: all 0.2s ease;
}

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







.hidden {
  opacity: 0;
  pointer-events: none;
}

.remove {
  display: none;
  height: 0;
  width: 0;
}

.icon {
  transform: scale(2);
  width: var(--spacing-16);
}



/* Admin Layout */
.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--spacing-6);
}

/* Form Header with Prominent Status Toggle */
.form-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: var(--spacing-6);
  padding: var(--spacing-4);
  background: hsl(var(--muted) / 0.3);
  border-radius: var(--radius-md);
  border: 1px solid hsl(var(--border));
}

.endpoint-status-toggle {
  display: flex;
  align-items: center;
}

.status-switch-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  position: relative;
}

.status-switch-text {
  color: hsl(var(--foreground));
  font-weight: var(--font-semibold);
  font-size: var(--text-lg);
}

.status-switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

.status-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: hsl(var(--destructive));
  transition: 0.3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: hsl(var(--success));
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.slider-text {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: var(--font-bold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: opacity 0.3s;
}

.slider-text.on {
  left: 8px;
  color: white;
  opacity: 0;
}

.slider-text.off {
  right: 8px;
  color: white;
  opacity: 1;
}

input:checked + .slider .slider-text.on {
  opacity: 1;
}

input:checked + .slider .slider-text.off {
  opacity: 0;
}

/* Dark theme adjustments for switches */
[data-theme="dark"] .slider-text.off {
  color: hsl(var(--muted-foreground));
}

[data-theme="dark"] .slider {
  background-color: hsl(var(--muted));
  border-color: hsl(var(--border));
}

[data-theme="dark"] .slider:before {
  background-color: hsl(var(--background));
}

.status-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--spacing-5);
  height: var(--spacing-5);
  border-radius: 50%;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: help;
  transition: all 0.2s ease;
}

.status-toggle-icon:hover {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.status-tooltip {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 1000;
  margin-top: var(--spacing-2);
  padding: var(--spacing-3);
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all 0.2s ease;
  pointer-events: none;
  min-width: 250px;
  max-width: 300px;
  word-wrap: break-word;
}

.status-switch-container:hover .status-tooltip,
.status-toggle-label:hover .status-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-8);
  padding-bottom: var(--spacing-4);
  border-bottom: 1px solid hsl(var(--border));
}

.form-actions-container {
  margin-top: var(--spacing-6);
  padding: var(--spacing-6);
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.1);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.admin-actions {
  display: flex;
  gap: var(--spacing-3);
  justify-content: flex-end;
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  gap: var(--spacing-1);
  margin-bottom: var(--spacing-8);
  background: hsl(var(--muted) / 0.2);
  border-radius: var(--radius-lg);
  padding: var(--spacing-1);
  border: 1px solid hsl(var(--border));
}

.tab-btn {
  background: none;
  border: 1px solid transparent;
  padding: var(--spacing-3) var(--spacing-6);
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: var(--font-medium);
  color: hsl(var(--muted-foreground));
  border-radius: var(--radius-md);
  position: relative;
  font-size: var(--text-sm);
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-btn:hover {
  background: hsl(var(--muted) / 0.6);
  color: hsl(var(--foreground));
  transform: translateY(-1px);
}

.tab-btn.active {
  background: hsl(var(--background));
  color: hsl(var(--primary));
  box-shadow: var(--shadow-md);
  font-weight: var(--font-medium);
  border: 1px solid hsl(var(--border));
}

.tab-btn.active:hover {
  transform: none;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Stats Cards */
.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-6);
  margin-bottom: var(--spacing-8);
}

.stat-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: var(--spacing-6);
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-value {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: hsl(var(--primary));
  margin-bottom: var(--spacing-2);
}

.stat-label {
  color: hsl(var(--muted-foreground));
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
}

/* Table Styles */
.table-container {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: var(--spacing-4);
  text-align: left;
  border-bottom: 1px solid hsl(var(--border));
}

th {
  background: hsl(var(--muted) / 0.5);
  font-weight: var(--font-semibold);
  color: hsl(var(--foreground));
}

tr:hover {
  background: hsl(var(--muted) / 0.3);
}

/* Flex-based Endpoints Layout */
.endpoints-container {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.endpoints-header {
  display: flex;
  background: hsl(var(--muted) / 0.5);
  border-bottom: 1px solid hsl(var(--border));
}

.endpoint-header-item {
  padding: var(--spacing-2) var(--spacing-3);
  font-weight: var(--font-semibold);
  color: hsl(var(--foreground));
  flex: 1;
}

.endpoint-header-item:first-child {
  flex: 1.2;
}

.endpoint-header-item:nth-child(2) {
  flex: 1.5;
}

.endpoint-header-item:nth-child(5) {
  flex: 0.5;
}

.endpoint-header-item:last-child {
  flex: 2;
}

.endpoints-list {
  display: flex;
  flex-direction: column;
}

.endpoint-row {
  display: flex;
  border-bottom: 1px solid hsl(var(--border));
  transition: background-color 0.2s ease;
}

.endpoint-row:hover {
  background: hsl(var(--muted) / 0.3);
}

.endpoint-row:last-child {
  border-bottom: none;
}

.endpoint-cell {
  padding: var(--spacing-2) var(--spacing-3);
  display: flex;
  align-items: center;
  flex: 1;
}

.endpoint-cell:first-child {
  flex: 1.2;
  font-weight: var(--font-medium);
}

.endpoint-cell:nth-child(2) {
  flex: 1.5;
  min-width: 0;
}

.endpoint-cell:nth-child(2) .api-path {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.endpoint-cell:nth-child(4) {
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.endpoint-cell:nth-child(5) {
  flex: 0.5;
  justify-content: center;
}

.endpoint-cell:last-child {
  flex: 2;
  gap: var(--spacing-2);
}

.no-endpoints {
  text-align: center;
  padding: var(--spacing-10);
  color: hsl(var(--muted-foreground));
}

/* Flex-based Logs Layout */
.logs-container {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.logs-header {
  display: flex;
  background: hsl(var(--muted) / 0.5);
  border-bottom: 1px solid hsl(var(--border));
}

.log-header-item {
  padding: var(--spacing-2) var(--spacing-3);
  font-weight: var(--font-semibold);
  color: hsl(var(--foreground));
  flex: 1;
}

.log-header-item:first-child {
  flex: 1.5;
}

.log-header-item:nth-child(2) {
  flex: 1.2;
}

.log-header-item:nth-child(3) {
  flex: 1.2;
  min-width: 0;
}

.log-header-item:nth-child(4) {
  flex: 0.8;
}

.log-header-item:nth-child(5) {
  flex: 1;
}

.log-header-item:nth-child(6) {
  flex: 0.8;
}

.log-header-item:last-child {
  flex: 1;
}

.logs-list {
  display: flex;
  flex-direction: column;
}

.log-row {
  display: flex;
  border-bottom: 1px solid hsl(var(--border));
  transition: background-color 0.2s ease;
  cursor: pointer;
}

.log-row:hover {
  background: hsl(var(--muted) / 0.3);
}

.log-row:last-child {
  border-bottom: none;
}

.log-cell {
  padding: var(--spacing-2) var(--spacing-3);
  display: flex;
  align-items: center;
  flex: 1;
}

.log-cell:first-child {
  flex: 1.5;
  font-size: var(--text-sm);
}

.log-cell:nth-child(2) {
  flex: 1.2;
  font-weight: var(--font-medium);
}

.log-cell:nth-child(3) {
  flex: 1.2;
  min-width: 0;
}

.log-cell:nth-child(3) {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-cell:nth-child(4) {
  flex: 0.8;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.log-cell:nth-child(5) {
  flex: 1;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.log-cell:nth-child(6) {
  flex: 0.8;
  justify-content: center;
}

.log-cell:last-child {
  flex: 1;
  justify-content: center;
}

.no-logs {
  text-align: center;
  padding: var(--spacing-10);
  color: hsl(var(--muted-foreground));
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--spacing-1) var(--spacing-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-enabled {
  background: hsl(var(--success) / 0.1);
  color: hsl(var(--success));
}

.status-disabled {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
}

/* Form Styles */
.form-container {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: var(--shadow-sm);
  overflow: visible;
}

#endpoint-form {
  padding: var(--spacing-6);
  padding-bottom: 0;
}

#endpoint-form .accordion-content {
  padding: var(--spacing-4);
}

#endpoint-form .accordion-content.collapsed {
  padding: 0;
  transition: all .3s ease, padding .1s ease .2s;
}

/* Accordion Styles */
.accordion-section {
  margin-bottom: var(--spacing-4);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  overflow: visible;
}

.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-4);
  background: hsl(var(--muted) / 0.3);
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 1px solid hsl(var(--border));
}

.accordion-header:hover {
  background: hsl(var(--muted) / 0.5);
}

.accordion-header h3 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: hsl(var(--foreground));
}

.accordion-icon {
  font-size: var(--text-sm);
  color: hsl(var(--muted-foreground));
  transition: transform 0.2s ease;
}

.accordion-content {
  background: hsl(var(--background));
  transition: all 0.3s ease;
  max-height: 2000px;
  opacity: 1;
  overflow-y: auto;
}

/* Context-specific sizing - must come BEFORE collapsed state */
.accordion-item .accordion-content {
  max-height: 500px;
}

/* Collapsed state - MUST come last to override all max-height values */
.accordion-content.collapsed,
.accordion-item .accordion-content.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  overflow: hidden;
}

.form-group {
  margin-bottom: var(--spacing-4);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-6);
}

label {
  display: flex;
  align-items: center;
  margin-bottom: var(--spacing-2);
  font-weight: var(--font-medium);
  color: hsl(var(--foreground));
}

.label-with-tooltip {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--spacing-1);
}

.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--spacing-4);
  height: var(--spacing-4);
  border-radius: 50%;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  cursor: help;
  transition: all 0.2s ease;
}

.tooltip-icon:hover {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.tooltip {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1000;
  margin-top: var(--spacing-1);
  padding: var(--spacing-3);
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all 0.2s ease;
  pointer-events: none;
  max-width: 300px;
  word-wrap: break-word;
}

.label-with-tooltip:hover .tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  overflow: visible;
}

.switch-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  position: relative;
  overflow: visible;
  z-index: 1;
}

.switch-text {
  color: hsl(var(--foreground));
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
}

.switch-container .label-with-tooltip .tooltip {
  position: absolute;
  left: 0;
  right: auto;
  top: 100%;
  margin-top: var(--spacing-2);
  z-index: 1001;
  width: 300px;
}

.switch-container .label-with-tooltip:hover .tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Messages */
.error, .success {
  padding: var(--spacing-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-6);
  font-size: var(--text-sm);
}

.error {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
  border: 1px solid hsl(var(--destructive) / 0.2);
}

.success {
  background: hsl(var(--success) / 0.1);
  color: hsl(var(--success));
  border: 1px solid hsl(var(--success) / 0.2);
}

/* API Path styling */
.api-path {
  cursor: pointer;
  padding: var(--spacing-1) var(--spacing-2);
  border-radius: var(--radius-sm);
  transition: background-color 0.2s ease;
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: hsl(var(--muted) / 0.5);
  color: hsl(var(--muted-foreground));
}

.api-path:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

/* Logs Header Actions */
.logs-header-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--spacing-6);
  padding: var(--spacing-4);
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* Responsive Design */
@media (max-width: 768px) {
  .admin-container {
    padding: var(--spacing-4);
  }

  .admin-header {
    flex-direction: column;
    gap: var(--spacing-4);
    align-items: flex-start;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .logs-header-actions {
    justify-content: center;
  }

  .stats-container {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 0 var(--spacing-2);
  }

  /* Mobile endpoints layout */
  .endpoints-header {
    display: none;
  }

  .endpoint-row {
    flex-direction: column;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-3);
    padding: var(--spacing-4);
  }

  .endpoint-cell {
    padding: var(--spacing-2) 0;
    border-bottom: 1px solid hsl(var(--border));
    justify-content: space-between;
  }

  .endpoint-cell:last-child {
    border-bottom: none;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: var(--spacing-2);
    margin-top: var(--spacing-2);
  }

  .endpoint-cell::before {
    content: attr(data-label);
    font-weight: var(--font-semibold);
    color: hsl(var(--muted-foreground));
    font-size: var(--text-sm);
    margin-right: var(--spacing-2);
  }

  .endpoint-cell:last-child::before {
    content: none;
  }

  /* Mobile logs layout */
  .logs-header {
    display: none;
  }

  .log-row {
    flex-direction: column;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-3);
    padding: var(--spacing-4);
    cursor: pointer;
  }

  .log-cell {
    padding: var(--spacing-2) 0;
    border-bottom: 1px solid hsl(var(--border));
    justify-content: space-between;
  }

  .log-cell:last-child {
    border-bottom: none;
    justify-content: flex-start;
    margin-top: var(--spacing-2);
  }

  .log-cell::before {
    content: attr(data-label);
    font-weight: var(--font-semibold);
    color: hsl(var(--muted-foreground));
    font-size: var(--text-sm);
    margin-right: var(--spacing-2);
  }

  .log-cell:last-child::before {
    content: none;
  }
}

/* Theme transition */
body {
  transition: background-color 0.2s ease, color 0.2s ease;
}

* {
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}



/* Unified Switch Component */
.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: hsl(var(--destructive));
  transition: 0.3s;
  border-radius: 34px;
  border: 1px solid transparent;
}

.switch .slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .slider {
  background-color: hsl(var(--success));
  border-color: hsl(var(--success));
}

.switch input:checked + .slider:before {
  transform: translateX(26px);
}

.switch .slider-text {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 8px;
  font-weight: var(--font-bold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: opacity 0.3s;
  user-select: none;
  pointer-events: none;
}

.switch .slider-text.on {
  left: 8px;
  color: white;
  opacity: 0;
}

.switch .slider-text.off {
  right: 8px;
  color: white;
  opacity: 1;
}

.switch input:checked + .slider .slider-text.on {
  opacity: 1;
}

.switch input:checked + .slider .slider-text.off {
  opacity: 0;
}

/* Switch Sizes */
.switch--small {
  width: 40px;
  height: 22px;
  margin-bottom: 0;
}

.switch--small .slider:before {
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
}

.switch--small input:checked + .slider:before {
  transform: translateX(18px);
}

.switch--small .slider-text {
  font-size: 5px;
}

.switch--small .slider-text.off {
  font-size: 5px;
}

.switch--small .slider-text.on {
  left: 6px;
}

.switch--small .slider-text.off {
  right: 6px;
}

/* Status Switch Special Styling */
.switch.status-switch {
  margin-left: auto;
  margin-bottom: 0;
}

.switch.status-switch .slider {
  background-color: hsl(var(--destructive));
  border-color: hsl(var(--destructive));
}

.switch.status-switch input:checked + .slider {
  background-color: hsl(var(--success));
  border-color: hsl(var(--success));
}

/* Dark theme adjustments for switches */
[data-theme="dark"] .switch .slider-text.off {
  color: hsl(var(--muted-foreground));
}

[data-theme="dark"] .switch .slider {
  background-color: hsl(var(--muted));
  border-color: hsl(var(--border));
}

[data-theme="dark"] .switch .slider:before {
  background-color: hsl(var(--background));
}

/* Log Modal Accordion Styles */
.accordion-item {
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  margin-bottom: 20px;
  overflow: hidden;
}

.accordion-item .accordion-header {
  align-items: center;
  background: hsl(var(--secondary));
  border: none;
  color: hsl(var(--foreground));
  font-size: 14px;
  font-weight: 500;
  padding: 12px 16px;
  width: 100%;
}

.accordion-item .accordion-header:hover {
  background: hsl(var(--secondary) / 0.8);
}

.accordion-item .accordion-icon {
  font-size: 12px;
}



/* Enhanced Conversation History Styles */
.log-conversation {
  background: hsl(var(--muted) / 0.1);
  border-radius: 8px;
  margin-bottom: 16px;
  max-height: 500px;
  overflow-y: auto;
  padding: 16px;
}

.message-item {
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 12px 16px;
  position: relative;
  transition: all 0.2s ease;
}

.message-item:last-child {
  margin-bottom: 0;
}

/* User message styling */
.message-item.user {
  background: hsl(var(--muted) / 0.3);
  border-left: 3px solid hsl(var(--primary));
}

/* Assistant message styling */
.message-item.assistant {
  background: hsl(var(--secondary) / 0.5);
  border-left: 3px solid hsl(var(--muted-foreground));
}

/* Latest response special styling */
.message-item.latest-response {
  background: hsl(var(--success) / 0.1);
  border: 2px solid hsl(var(--success));
  border-left: 4px solid hsl(var(--success));
}

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

.message-role {
  font-weight: 600;
  text-transform: uppercase;
}

.message-item.user .message-role {
  color: hsl(var(--primary));
}

.message-item.assistant .message-role {
  color: hsl(var(--muted-foreground));
}

.message-item.latest-response .message-role {
  color: hsl(var(--success));
}

/* Latest response badge */
.latest-badge {
  background: hsl(var(--success));
  border-radius: 4px;
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  text-transform: uppercase;
}

.message-content {
  color: hsl(var(--foreground));
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Hide message index numbers */
.message-index {
  display: none;
}

/* No data styling */
.no-data {
  color: hsl(var(--muted-foreground));
  font-style: italic;
  padding: 20px;
  text-align: center;
}

/* Responsive improvements for log modal */
@media (max-width: 768px) {
  .log-conversation {
    max-height: 300px;
    padding: 12px;
  }
  
  .message-item {
    margin-bottom: 8px;
    padding: 8px 12px;
  }
  
  .accordion-header {
    padding: 10px 12px;
  }
  
  .accordion-content {
    padding: 12px;
  }
  
  .latest-badge {
    font-size: 9px;
    padding: 1px 6px;
  }
}

[data-theme="dark"] .switch input:checked + .slider {
  background-color: hsl(var(--success));
  border-color: hsl(var(--success));
}

[data-theme="dark"] .switch.status-switch .slider {
  background-color: hsl(var(--destructive));
  border-color: hsl(var(--destructive));
}

[data-theme="dark"] .switch.status-switch input:checked + .slider {
  background-color: hsl(var(--success));
  border-color: hsl(var(--success));
}

.accordion-section .switch-container .tooltip {
  z-index: 1002;
}

/* Upward tooltip specifically for the "Show reasoning" switch at bottom of accordion */
#advanced-content .checkbox-group .switch-container .tooltip {
  bottom: 100%;
  margin-bottom: var(--spacing-1);
  margin-top: 0;
  top: auto;
  transform: translateY(4px);
}

#advanced-content .checkbox-group .switch-container .label-with-tooltip:hover .tooltip {
  transform: translateY(0);
}

/* Responsive tooltip positioning */
@media (max-width: 600px) {
  .switch-container .tooltip {
    left: auto;
    right: 0;
  }
}

/* Modal Styles */
.modal {
  animation: fadeIn 0.2s;
  background-color: hsl(var(--foreground) / 0.8);
  display: none;
  height: 100%;
  left: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--spacing-8) var(--spacing-4);
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
}

.modal.show {
  align-items: flex-start;
  display: flex;
  justify-content: center;
  min-height: 100%;
}

.modal-content {
  background-color: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  margin: auto;
  max-width: 800px;
  min-height: fit-content;
  position: relative;
  width: 90%;
}

.modal-header {
  align-items: center;
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  justify-content: space-between;
  padding: var(--spacing-5);
}

.modal-header h2 {
  color: hsl(var(--foreground));
  font-size: var(--text-xl);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  font-size: var(--text-xl);
  padding: 0;
  transition: color 0.2s;
}

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

.modal-body {
  padding: var(--spacing-5);
}

.test-config {
  background-color: hsl(var(--muted));
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-5);
  padding: var(--spacing-4);
}

.test-config h3 {
  color: hsl(var(--foreground));
  font-size: var(--text-sm);
  margin: 0 0 var(--spacing-3) 0;
  text-transform: uppercase;
}

.config-summary {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
}

.config-item {
  color: hsl(var(--muted-foreground));
  font-size: var(--text-sm);
}

.config-item strong {
  color: hsl(var(--foreground));
  display: inline-block;
  min-width: 100px;
}

.config-item pre {
  background-color: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  color: hsl(var(--foreground));
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  margin: var(--spacing-1) 0;
  max-height: 100px;
  overflow-y: auto;
  padding: var(--spacing-2);
  white-space: pre-wrap;
}

.test-actions {
  display: flex;
  gap: var(--spacing-3);
  margin: var(--spacing-5) 0;
}

.loading-spinner {
  align-items: center;
  display: flex;
  gap: var(--spacing-3);
  justify-content: center;
  padding: var(--spacing-5);
}

.spinner {
  animation: spin 1s linear infinite;
  border: 3px solid hsl(var(--border));
  border-radius: 50%;
  border-top-color: hsl(var(--primary));
  height: 24px;
  width: 24px;
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.test-results {
  background-color: hsl(var(--muted));
  border-radius: var(--radius-md);
  margin-top: var(--spacing-5);
  padding: var(--spacing-4);
}

.test-results h3 {
  color: hsl(var(--foreground));
  font-size: var(--text-base);
  margin: 0 0 var(--spacing-3) 0;
}



.result-content {
  background-color: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  max-height: 300px;
  overflow-y: auto;
  padding: var(--spacing-4);
}

.result-content pre {
  color: hsl(var(--foreground));
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Streaming content styles */
.streaming-content {
  position: relative;
}

.streaming-content::after {
  animation: blink 1s infinite;
  color: hsl(var(--primary));
  content: '█';
  font-family: var(--font-mono);
  margin-left: 2px;
}

.streaming-content.completed::after {
  display: none;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Performance Metrics Styles */
.performance-metrics {
  background-color: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  margin-top: var(--spacing-5);
  padding: var(--spacing-4);
}

.performance-metrics h4 {
  color: hsl(var(--foreground));
  font-size: var(--text-sm);
  margin: 0 0 var(--spacing-4) 0;
  text-transform: uppercase;
}

.metric-grid {
  display: grid;
  gap: var(--spacing-4);
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.metric {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-1);
}

.metric-label {
  color: hsl(var(--muted-foreground));
  font-size: var(--text-xs);
  text-transform: uppercase;
}

.metric-value {
  color: hsl(var(--foreground));
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
}

/* Console-like styling for performance logs */
@media (min-width: 768px) {
  .metric-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}



.modal-footer {
    border-top: 1px solid hsl(var(--border));
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 20px;
}

#admin-token-input {
    font-family: monospace;
    width: 100%;
}

#admin-logout-btn {
    margin-left: auto;
}

/* Log Details Modal Styles */
.log-details-grid {
    display: grid;
    gap: var(--spacing-6);
    grid-template-columns: 1fr 1fr;
    margin-bottom: var(--spacing-6);
}

@media (max-width: 768px) {
    .log-details-grid {
        grid-template-columns: 1fr;
    }
}

.log-meta, .log-tokens {
    background-color: hsl(var(--muted));
    border-radius: var(--radius-md);
    padding: var(--spacing-3);
}

.log-meta h3, .log-tokens h3 {
    color: hsl(var(--foreground));
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    margin: 0 0 var(--spacing-3) 0;
}

.log-field {
    display: flex;
    justify-content: space-between;
}

.log-field label {
    color: hsl(var(--muted-foreground));
    font-weight: var(--font-medium);
    font-size: var(--text-sm);
}

.log-field span {
    color: hsl(var(--foreground));
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    text-align: right;
}

.log-content {
    margin-top: var(--spacing-6);
}

.log-content h3 {
    color: hsl(var(--foreground));
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    margin: var(--spacing-4) 0 var(--spacing-2) 0;
}

.log-content h3:first-child {
    margin-top: 0;
}

.log-text-content {
    color: hsl(var(--foreground));
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: 1.4;
    max-height: 250px;
    overflow-y: auto;
    padding: var(--spacing-3);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.log-text-content.error {
    background-color: hsl(var(--destructive) / 0.1);
    border-color: hsl(var(--destructive) / 0.3);
    color: hsl(var(--destructive));
}

.log-text-content:empty::before {
    color: hsl(var(--muted-foreground));
    content: "No data available";
    font-style: italic;
}

/* Textarea auto-resize styling */
textarea.autosize {
  overflow-y: hidden;
  transition: height 0.1s ease;
}
