/* Modern Design System & Theme Tokens - TailAdmin Style */
:root {
  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Colors - TailAdmin Inspired */
  /* Primary Blue/Indigo */
  --primary: #3c50e0;
  /* Indigo-like Blue */
  --primary-hover: #4F61E2;
  --primary-light: #eff4fb;
  /* Very light blue for backgrounds/accents */

  /* Backgrounds */
  --bg-app: #f1f5f9;
  /* Slate-100/50 mix - Main Background */
  --bg-surface: #ffffff;
  /* Card/Panel Background */
  --bg-sidebar: #1c2434;
  /* Dark Sidebar (Classic Admin) */
  --bg-sidebar-active: #333a48;
  /* Slightly lighter for active mix */

  /* Text */
  --text-primary: #1c2434;
  /* Dark Slate/Black */
  --text-secondary: #64748b;
  /* Slate-500 */
  --text-tertiary: #94a3b8;
  /* Slate-400 */
  --text-on-dark: #dee4ee;
  /* For sidebar text */

  /* Semantic Colors */
  --success: #219653;
  /* Green */
  --success-bg: #dcfce7;
  --warning: #FFA70B;
  /* Orange */
  --danger: #D34053;
  /* Red */
  --danger-bg: #fee2e2;
  --info: #3c50e0;

  /* Borders */
  --border: #e2e8f0;
  /* Slate-200 */
  --border-light: #f1f5f9;
  --border-dark: #cbd5e1;

  /* Shadows - Subtle & Clean */
  --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-card: 0px 8px 13px -3px rgba(0, 0, 0, 0.07);

  /* Radius */
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 0.5rem;
  /* 8px - Main Card Radius */
  --radius-xl: 0.75rem;
  --radius-full: 9999px;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 1.875rem;
  /* ~30px */
  --space-8: 2rem;
}

[data-theme="dark"] {
  --bg-app: #1a222c;
  /* Dark Box */
  --bg-surface: #24303f;
  /* Dark Surface */
  --bg-sidebar: #24303f;
  /* Matches surface in full dark mode */

  --text-primary: #ffffff;
  --text-secondary: #aeb7c0;
  --text-tertiary: #64748b;
  --text-on-dark: #ffffff;

  --border: #2e3a47;
  --border-light: #24303f;

  --primary-light: rgba(60, 80, 224, 0.15);
  /* Transparent primary for dark mode */
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}

button {
  font-family: inherit;
}

/* Utilities */
.text-xs {
  font-size: 0.75rem;
}

.text-sm {
  font-size: 0.875rem;
}

.text-base {
  font-size: 1rem;
}

.text-lg {
  font-size: 1.125rem;
  font-weight: 600;
}

.text-xl {
  font-size: 1.25rem;
  font-weight: 600;
}

.text-2xl {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.font-medium {
  font-weight: 500;
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

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

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

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

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

/* Components: Buttons (Flat & Clean) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.6rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.2;
}

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

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 6px rgba(60, 80, 224, 0.25);
  /* Subtle colored shadow */
}

.btn-secondary {
  background-color: transparent;
  border-color: var(--primary);
  color: var(--primary);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--primary);
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-app);
  color: var(--text-primary);
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}

.btn-danger:hover {
  background-color: #b91c1c;
}

/* Inputs (Clean Border) */
.form-group {
  margin-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  display: block;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1.125rem;
  font-size: 0.95rem;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Cards (Clean & Flat) */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  /* Defaulting to small radius */
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
}

/* Re-override card for more TailAdmin look: larger radius actually common now */
.card {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Tables (Striped/Clean) */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-weight: 600;
  text-align: left;
  padding: 0.8rem 1rem;
  font-size: 0.9rem;
}

.table td {
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 1rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

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

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  line-height: 1;
}

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

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

.badge-status.inactive {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-admin {
  background: var(--primary-light);
  color: var(--primary);
}

/* Utilities */
.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: var(--space-2);
}

.gap-4 {
  gap: var(--space-4);
}

/* Spinner */
.spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

  to {
    transform: rotate(360deg);
  }
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  z-index: 1100;
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.modal-overlay.open {
  display: flex !important;
  opacity: 1;
}

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  position: relative;
  border: 1px solid var(--border-light);
  transform: translateY(10px);
  transition: transform 0.2s ease-out;
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* Specific Sizes */
.modal-sm {
  max-width: 480px;
}

.modal-lg {
  max-width: 800px;
}

.modal-xl {
  max-width: 1100px;
}

/* Side Panel (Slide-over) */
.side-panel-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 1040;
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.side-panel-overlay.open {
  display: block !important;
  opacity: 1;
}

.side-panel {
  position: fixed;
  top: 0;
  right: -100%;
  /* Hide off-screen initially */
  bottom: 0;
  width: 100%;
  max-width: 450px;
  background: var(--bg-surface);
  box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.side-panel.open {
  right: 0;
}

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

.side-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

.side-panel-actions {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  background: var(--bg-surface);
}

/* Responsive adjustment for side panel */
@media (max-width: 640px) {
  .side-panel {
    max-width: 100%;
  }
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .modal {
    max-height: 100vh;
    border-radius: 0;
    height: 100%;
  }

  .modal-overlay {
    padding: 0;
  }
}