/* =============================================================================
   AESTHETIC OS — Sistema de diseño global
   Luxury Medical · Paleta personalizable por clínica
   Para cambiar la identidad visual de una clínica: sobrescribir solo estas
   variables en un <style> scope por tenant. El código nunca cambia.
   ============================================================================= */

/* ── Google Fonts ──────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400&family=Inter:wght@300;400;500;600&display=swap');

/* ── Variables de diseño ────────────────────────────────────────────────────── */
:root {
  /* Paleta principal */
  --color-bg:             #FAFAF8;  /* fondo principal, blanco cálido */
  --color-surface:        #FFFFFF;  /* tarjetas y paneles */
  --color-surface-2:      #F5F3EF;  /* fondos secundarios, sidebar */
  --color-accent:         #C9A96E;  /* dorado champagne — acción principal */
  --color-accent-dark:    #A67C52;  /* dorado oscuro — hover y énfasis */
  --color-accent-light:   #F0E6D3;  /* dorado muy suave — fondos de highlight */
  --color-text-primary:   #1A1A1A;  /* texto principal */
  --color-text-secondary: #6B6B6B;  /* labels y texto secundario */
  --color-text-muted:     #A0A0A0;  /* texto muy tenue */
  --color-border:         #E8E4DC;  /* bordes suaves */
  --color-border-focus:   #C9A96E;  /* borde en foco (= accent) */
  --color-success:        #5A8A6A;  /* verde oliva — estados positivos */
  --color-success-bg:     #EEF4F0;  /* fondo de éxito */
  --color-danger:         #C0392B;  /* rojo — alertas y eliminaciones */
  --color-danger-bg:      #FDECEA;  /* fondo de error */
  --color-warning:        #B8860B;  /* ámbar — advertencias */
  --color-warning-bg:     #FDF8E7;  /* fondo de advertencia */

  /* Tipografía */
  --font-heading: 'Cormorant Garamond', Georgia, serif;
  --font-body:    'Inter', system-ui, sans-serif;

  /* Espaciado base */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  /* Sombras */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 12px 32px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.06);
  --shadow-xl:  0 24px 48px rgba(0,0,0,0.14);

  /* Transiciones */
  --transition: 200ms ease;
  --transition-slow: 300ms ease;
}

/* ── Reset y base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family:      var(--font-body);
  background-color: var(--color-bg);
  color:            var(--color-text-primary);
  font-size:        14px;
  line-height:      1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
  font-family:  var(--font-heading);
  font-weight:  500;
  line-height:  1.25;
  color:        var(--color-text-primary);
}

h1 { font-size: 2rem;   letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; letter-spacing: -0.01em; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem;   font-family: var(--font-body); font-weight: 600; }

/* Garantiza Cormorant Garamond en páginas que también cargan Tailwind */
body h1, body h2, body h3, body h5 { font-family: var(--font-heading) !important; }

a { color: var(--color-accent-dark); text-decoration: none; }
a:hover { color: var(--color-accent); }

/* ── Layout base ────────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.app-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--color-surface-2);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.app-main {
  flex: 1;
  overflow-y: auto;
  background: var(--color-bg);
}

.page-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 1.25rem 1.75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-content {
  padding: 1.75rem;
  max-width: 1200px;
}

/* ── Botones ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.125rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

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

.btn-accent {
  background: var(--color-accent);
  color: #FFFFFF;
  border-color: var(--color-accent);
}
.btn-accent:hover:not(:disabled) {
  background: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
  color: #FFFFFF;
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: transparent;
  color: var(--color-text-primary);
  border-color: var(--color-border);
}
.btn-outline:hover:not(:disabled) {
  background: var(--color-surface-2);
  border-color: var(--color-accent);
  color: var(--color-accent-dark);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--color-surface-2);
  color: var(--color-text-primary);
}

.btn-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-color: #f5c6c2;
}
.btn-danger:hover:not(:disabled) {
  background: var(--color-danger);
  color: white;
}

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.75rem; }
.btn-lg { padding: 0.7rem 1.5rem; font-size: 0.9375rem; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--color-surface-2); color: var(--color-text-primary); }

/* ── Inputs ─────────────────────────────────────────────────────────────────── */
.input {
  width: 100%;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text-primary);
  background: var(--color-surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.input:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(201,169,110,0.15);
}
.input::placeholder { color: var(--color-text-muted); }
.input:disabled { background: var(--color-surface-2); color: var(--color-text-secondary); }

textarea.input { resize: vertical; min-height: 80px; }
select.input { cursor: pointer; }

.input-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.375rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 1.125rem 1.375rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-body { padding: 1.375rem; }

.card-hover {
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  cursor: pointer;
}
.card-hover:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-accent);
  transform: translateY(-1px);
}

/* ── Tabla ──────────────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead tr { background: var(--color-surface-2); }
th {
  padding: 0.625rem 1rem;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
}
td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-primary);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--color-surface-2); }

/* ── Badges / Pills ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge-accent  { background: var(--color-accent-light); color: var(--color-accent-dark); }
.badge-success { background: var(--color-success-bg);   color: var(--color-success); }
.badge-danger  { background: var(--color-danger-bg);    color: var(--color-danger); }
.badge-warning { background: var(--color-warning-bg);   color: var(--color-warning); }
.badge-neutral { background: var(--color-surface-2);    color: var(--color-text-secondary); }

/* ── Modal (glassmorphism) ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}

.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  margin: auto;
  animation: modal-in 200ms ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-body    { padding: 1.5rem; }
.modal-footer  { padding: 1rem 1.5rem; border-top: 1px solid var(--color-border);
                 display: flex; gap: 0.625rem; justify-content: flex-end; }

/* ── Alertas ────────────────────────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.alert-error   { background: var(--color-danger-bg);  color: var(--color-danger);  border: 1px solid #f5c6c2; }
.alert-success { background: var(--color-success-bg); color: var(--color-success); border: 1px solid #b8d4bf; }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid #e8d48a; }
.alert-info    { background: var(--color-accent-light); color: var(--color-accent-dark); border: 1px solid #e0ccaa; }

/* ── Separadores decorativos ────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 1.5rem 0;
}

.section-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

/* ── Sidebar (luxury medical) ───────────────────────────────────────────────── */
.sidebar-logo {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-logo-mark {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.sidebar-logo-icon {
  width: 2rem;
  height: 2rem;
  background: var(--color-accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-name {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
}

.sidebar-logo-subtitle {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  margin-top: 0.125rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: all var(--transition);
  margin-bottom: 0.125rem;
}

.sidebar-nav-link:hover {
  background: var(--color-accent-light);
  color: var(--color-accent-dark);
}

.sidebar-nav-link.active {
  background: var(--color-accent-light);
  color: var(--color-accent-dark);
  font-weight: 500;
}

.sidebar-nav-link svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-nav-link:hover svg,
.sidebar-nav-link.active svg {
  opacity: 1;
}

.sidebar-user {
  padding: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.25rem;
}

.sidebar-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--color-accent-light);
  color: var(--color-accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 600;
  flex-shrink: 0;
}

/* ── Upload zone ────────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--color-surface);
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}

/* ── Paso del protocolo ─────────────────────────────────────────────────────── */
.position-dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: var(--color-border);
  transition: all var(--transition);
  flex-shrink: 0;
}
.position-dot.done    { background: var(--color-success); }
.position-dot.current { background: var(--color-accent); transform: scale(1.4); }

/* ── Utilidades ─────────────────────────────────────────────────────────────── */
.hidden  { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

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

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end  { justify-content: flex-end; }
.gap-1  { gap: 0.25rem; }
.gap-2  { gap: 0.5rem; }
.gap-3  { gap: 0.75rem; }
.gap-4  { gap: 1rem; }
.gap-6  { gap: 1.5rem; }

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

.mt-1 { margin-top: 0.25rem; } .mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; } .mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; } .mt-8 { margin-top: 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; }

.w-full  { width: 100%; }
.flex-1  { flex: 1; }
.min-w-0 { min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }

@media (max-width: 768px) {
  .app-sidebar { width: 100%; height: auto; position: static; }
  .app-shell   { flex-direction: column; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
