/* ================================================================
   CPA TURNOS — Design System v3.0
   Professional UI Kit with Light/Dark themes
   ================================================================ */

/* ========= GOOGLE FONTS ========= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ========= THEME TOKENS ========= */
:root {
  /* Colors - Light */
  --bg: #f8fafc;
  --bg-secondary: #f1f5f9;
  --fg: #0f172a;
  --fg-secondary: #334155;
  --card: #ffffff;
  --card-hover: #fefefe;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --muted: #64748b;
  --muted-light: #94a3b8;
  
  /* Primary - Celeste Claro / Sky Blue */
  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --primary-light: #e0f2fe;
  --primary-fg: #ffffff;
  --primary-soft: rgba(14, 165, 233, 0.08);
  
  /* Secondary */
  --secondary: #f1f5f9;
  --secondary-hover: #e2e8f0;
  --secondary-fg: #334155;
  
  /* Semantic */
  --success: #10b981;
  --success-light: #d1fae5;
  --success-fg: #065f46;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --warning-fg: #92400e;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --danger-fg: #991b1b;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --info-fg: #1e40af;
  
  /* Inputs */
  --input-bg: #ffffff;
  --input-fg: #0f172a;
  --input-placeholder: #94a3b8;
  --input-border: #cbd5e1;
  --input-focus: #0ea5e9;
  --input-focus-ring: rgba(14, 165, 233, 0.2);
  
  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-primary: 0 4px 14px rgba(14, 165, 233, 0.25);
  --shadow-primary-hover: 0 8px 24px rgba(14, 165, 233, 0.35);
  
  /* Radius */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  
  /* 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-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
}

html.dark {
  --bg: #0a0a0f;
  --bg-secondary: #111118;
  --fg: #e2e8f0;
  --fg-secondary: #94a3b8;
  --card: #13131b;
  --card-hover: #1a1a24;
  --border: #1e2533;
  --border-hover: #2d3748;
  --muted: #64748b;
  --muted-light: #475569;
  
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-light: rgba(14, 165, 233, 0.15);
  --primary-fg: #0f172a;
  --primary-soft: rgba(56, 189, 248, 0.1);
  
  --secondary: #1e2533;
  --secondary-hover: #2d3748;
  --secondary-fg: #e2e8f0;
  
  --input-bg: #13131b;
  --input-fg: #e2e8f0;
  --input-placeholder: #475569;
  --input-border: #1e2533;
  --input-focus: #38bdf8;
  --input-focus-ring: rgba(56, 189, 248, 0.25);
  
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
  --shadow-primary: 0 4px 14px rgba(56, 189, 248, 0.2);
  --shadow-primary-hover: 0 8px 24px rgba(56, 189, 248, 0.3);
}

/* ========= BASE RESET ========= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  line-height: 1.6;
}

img, svg, video, canvas, audio, iframe, embed, object {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
}

/* ========= TYPOGRAPHY ========= */
.text-muted-foreground { color: var(--muted); }
.text-foreground { color: var(--fg); }
.bg-background { background: var(--bg); }
.border-border { border-color: var(--border); }

.text-xl { 
  font-size: clamp(1.125rem, 2vw, 1.375rem); 
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.3;
}

.text-lg { 
  font-size: clamp(1rem, 1.8vw, 1.125rem); 
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.4;
}

.text-sm { font-size: 0.875rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

/* ========= LAYOUT ========= */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.page-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.5rem);
}

/* ========= CARDS ========= */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.card-elev {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
}

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

.card-body {
  padding: clamp(1.25rem, 3vw, 1.75rem);
}

/* ========= FORMS ========= */
.input {
  width: 100%;
  background: var(--input-bg);
  color: var(--input-fg);
  border: 1.5px solid var(--input-border);
  padding: 0.7rem 0.875rem;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  line-height: 1.5;
  outline: none;
  transition: all var(--transition-fast);
}

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

.input:hover {
  border-color: var(--border-hover);
}

.input:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px var(--input-focus-ring);
}

textarea.input {
  resize: vertical;
  min-height: 100px;
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}

/* ========= BUTTONS ========= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.125rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.5;
  transition: all var(--transition-fast);
  white-space: nowrap;
  border: 1.5px solid transparent;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: var(--shadow-primary-hover);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

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

.btn-outline:hover {
  background: var(--secondary);
  border-color: var(--border-hover);
}

.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--fg);
}

.btn-icon:hover {
  background: var(--secondary);
}

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

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

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

.btn-success:hover {
  background: #059669;
  border-color: #059669;
}

/* ========= LIST ROWS ========= */
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.row:hover {
  border-color: var(--border-hover);
  background: var(--secondary);
}

.item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 0.75rem;
  transition: all var(--transition-fast);
}

.item:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

/* ========= BADGES ========= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.badge-pending {
  background: var(--warning-light);
  color: var(--warning-fg);
  border: 1px solid var(--warning);
}

.badge-confirmed {
  background: var(--success-light);
  color: var(--success-fg);
  border: 1px solid var(--success);
}

.badge-canceled {
  background: var(--danger-light);
  color: var(--danger-fg);
  border: 1px solid var(--danger);
}

/* ========= CHIPS ========= */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.chip.pending {
  background: var(--warning-light);
  color: var(--warning-fg);
  border: 1px solid var(--warning);
}

.chip.confirmed {
  background: var(--success-light);
  color: var(--success-fg);
  border: 1px solid var(--success);
}

.chip.canceled {
  background: var(--danger-light);
  color: var(--danger-fg);
  border: 1px solid var(--danger);
}

/* ========= TOAST ========= */
.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius-lg);
  background: var(--fg);
  color: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 1000;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s ease-out;
}

.toast.hidden {
  display: none;
}

.toast.success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.toast.error {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.toast.warning {
  background: var(--warning);
  color: var(--warning-fg);
  border-color: var(--warning);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========= LOADER ========= */
.loader {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

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

/* ========= THEME TOGGLE ========= */
.toggle {
  width: 48px;
  height: 26px;
  background: var(--secondary);
  border-radius: var(--radius-full);
  position: relative;
  border: 1.5px solid var(--border);
  transition: all var(--transition-fast);
}

.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: white;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}

input.peer:checked + .toggle {
  background: var(--primary);
  border-color: var(--primary);
}

input.peer:checked + .toggle::after {
  transform: translateX(22px);
}

/* ========= HEADER ========= */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}

.app-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--fg);
}

.app-header h1 i {
  color: var(--primary);
}

/* ========= FOOTER ========= */
.app-footer {
  margin-top: 3rem;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.app-footer .footer-brand {
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--fg);
  font-size: 0.9375rem;
}

.app-footer .footer-links {
  margin: 0.75rem 0;
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.app-footer .footer-links a {
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: color var(--transition-fast);
  font-size: 0.875rem;
}

.app-footer .footer-links a:hover {
  color: var(--primary);
}

.app-footer .footer-links i {
  font-size: 1rem;
}

.app-footer .footer-dev {
  font-size: 0.8125rem;
  margin-top: 0.75rem;
  color: var(--muted-light);
}

/* ========= OVERLAY DE CARGA ========= */
#loading-overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  backdrop-filter: blur(4px);
}

#loading-overlay::before {
  content: '';
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

#loading-overlay .loading-text {
  margin-top: 1rem;
  color: white;
  font-weight: 600;
  font-size: 0.9375rem;
}

/* ========= KEY-VALUE GRID ========= */
.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1rem 1.25rem;
  align-items: start;
  margin: 1.25rem 0;
}

.kv dt {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kv dd {
  margin: 0;
  font-weight: 500;
  color: var(--fg);
  font-size: 0.9375rem;
  word-break: break-word;
}

@media (max-width: 520px) {
  .kv {
    grid-template-columns: 1fr;
    gap: 0.375rem;
  }
  .kv dt {
    font-weight: 600;
    margin-top: 0.75rem;
  }
  .kv dt:first-child {
    margin-top: 0;
  }
}

/* ========= DIVIDER ========= */
.divider {
  height: 1px;
  background: var(--border);
  margin: 1.25rem 0;
}

/* ========= MUTED TEXT ========= */
.muted {
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.6;
}

/* ========= HIDDEN ========= */
.hidden { display: none; }

/* ========= RESPONSIVE ========= */
@media (max-width: 640px) {
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .card {
    padding: 1rem;
    border-radius: var(--radius-lg);
  }
  
  .input {
    padding: 0.625rem 0.75rem;
    font-size: 16px;
  }
  
  .btn {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
  }
  
  .app-footer {
    margin-top: 2rem;
    padding: 1.25rem 1rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  
  .app-footer .footer-links {
    gap: 1rem;
    flex-direction: column;
  }
  
  .app-footer .footer-brand {
    font-size: 0.8125rem;
  }
  
  .app-footer .footer-dev {
    font-size: 0.75rem;
  }
}

@media (max-width: 400px) {
  .input {
    padding: 0.5rem 0.625rem;
    font-size: 16px;
    border-radius: var(--radius-sm);
  }
  
  .btn {
    font-size: 0.8125rem;
    padding: 0.5rem 0.875rem;
    border-radius: var(--radius-sm);
  }
}

/* ========= ANIMATIONS ========= */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeIn 0.5s ease-out forwards;
}

.animate-in-delay-1 {
  animation: fadeIn 0.5s ease-out 0.1s forwards;
  opacity: 0;
}

.animate-in-delay-2 {
  animation: fadeIn 0.5s ease-out 0.2s forwards;
  opacity: 0;
}

.animate-in-delay-3 {
  animation: fadeIn 0.5s ease-out 0.3s forwards;
  opacity: 0;
}

/* ========= UTILITY CLASSES ========= */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.peer:checked ~ .peer-checked\:block {
  display: block;
}

/* ========= SCROLLBAR ========= */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* ========= SELECTION ========= */
::selection {
  background: var(--primary);
  color: var(--primary-fg);
}

/* ========= MICRO UTILIDADES (reemplazan Tailwind CDN) ========= */
/* Layout */
.flex        { display: flex; }
.inline-flex { display: inline-flex; }
.grid        { display: grid; }
.block       { display: block; }

/* Flex / Grid helpers */
.items-center    { align-items: center; }
.items-start     { align-items: flex-start; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-wrap       { flex-wrap: wrap; }
.flex-col        { flex-direction: column; }
.flex-1          { flex: 1 1 0%; }
.gap-1   { gap: 0.25rem; }
.gap-2   { gap: 0.5rem; }
.gap-3   { gap: 0.75rem; }
.gap-4   { gap: 1rem; }
.gap-6   { gap: 1.5rem; }
.gap-8   { gap: 2rem; }

/* Espaciado */
.p-4  { padding: 1rem; }
.p-6  { padding: 1.5rem; }
.px-4 { padding-inline: 1rem; }
.py-6 { padding-block: 1.5rem; }
.pb-16 { padding-bottom: 4rem; }
.mb-2  { margin-bottom: 0.5rem; }
.mb-4  { margin-bottom: 1rem; }
.mx-auto { margin-inline: auto; }

/* Sizing */
.w-full  { width: 100%; }
.h-auto  { height: auto; }
.min-h-screen { min-height: 100vh; }

/* Bordes */
.rounded-xl { border-radius: var(--radius-xl); }

/* Listas */
.list-disc { list-style-type: disc; }
.list-decimal { list-style-type: decimal; }
.pl-5 { padding-left: 1.25rem; }
.space-y-2 > * + * { margin-top: 0.5rem; }

/* Texto */
.text-2xl {
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

/* Interacción */
.cursor-pointer { cursor: pointer; }

/* Accesibilidad */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
