/* ============================================================
   CENTRO MÉDICO AVELLANEDA - PREMIUM UI KITS
   ============================================================ */

:root {
  /* Palette */
  --primary: #8B1E2D;
  --primary-gradient: linear-gradient(135deg, #8B1E2D 0%, #B91C1C 100%);
  --primary-light: rgba(139, 30, 45, 0.08);

  --bg-main: #f8fafc;
  --card-bg: rgba(255, 255, 255, 0.9);
  --sidebar-bg: rgba(255, 255, 255, 0.95);

  --text-dark: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);

  --glass-border: 1px solid rgba(255, 255, 255, 0.5);
}

body {
  /* Usar fuentes del sistema para carga más rápida */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  background-color: var(--bg-main);
  background-image:
    radial-gradient(at 0% 0%, rgba(139, 30, 45, 0.03) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(59, 130, 246, 0.03) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
      ANIMACIONES
      ============================================================ */

/* Animaciones Suaves */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.4s ease-out forwards;
}

.slide-up {
  animation: slideUp 0.3s ease-out forwards;
}

/* Staggered animation delays for lists */
.stagger-1 {
  animation-delay: 0.1s;
}

.stagger-2 {
  animation-delay: 0.2s;
}

.stagger-3 {
  animation-delay: 0.3s;
}

/* ============================================================
      CARDS & GLASSMORPHISM
      ============================================================ */

.card {
  background: var(--card-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 1rem;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s, box-shadow 0.15s;
  will-change: transform;
}

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

/* ============================================================
      SIDEBAR
      ============================================================ */

.sidebar {
  width: 80px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-right: 1px solid var(--border);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.sidebar-logo {
  color: var(--primary);
  margin-bottom: 2rem;
  filter: drop-shadow(0 4px 6px rgba(139, 30, 45, 0.2));
}

.sidebar-nav {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  gap: 0.5rem;
  /* Increased spacing between items */
}

.sidebar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 0.25rem;
  /* Increased vertical padding */
  width: 72px;
  border-radius: 12px;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s;
  font-size: 0.7rem;
  font-weight: 500;
  gap: 4px;
  margin-bottom: 0;
  text-align: center;
  line-height: 1.1;
}

.sidebar-item span {
  display: block;
  width: 100%;
  text-align: center;
  line-height: 1.1;
  white-space: normal;
  overflow-wrap: break-word;
}

.sidebar-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.sidebar-item.active {
  background: linear-gradient(135deg, rgba(139, 30, 45, 0.1) 0%, rgba(139, 30, 45, 0.05) 100%);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(139, 30, 45, 0.1);
}

/* ============================================================
      LAYOUT & HEADER
      ============================================================ */

.main-content {
  margin-left: 80px;
  min-height: 100vh;
  padding: 2.5rem;
}

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

.page-title {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.025em;
}

.header-info {
  display: flex;
  gap: 1.5rem;
  background: white;
  padding: 0.5rem 1rem;
  border-radius: 99px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* ============================================================
      BUTTONS
      ============================================================ */

.btn {
  padding: 0.6rem 1.2rem;
  border-radius: 0.75rem;
  font-weight: 600;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  height: 42px;
  min-height: 42px;
}

.btn:hover {
  transform: translateY(-1px);
}

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

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 4px 6px -1px rgba(139, 30, 45, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #991B1B 0%, #7F1D1D 100%);
  box-shadow: 0 6px 8px -1px rgba(139, 30, 45, 0.4);
}

.btn-secondary {
  background: white;
  border: 1px solid var(--border);
  color: var(--text-dark);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

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

.btn-sm {
  height: 32px;
  min-height: 32px;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

/* ============================================================
      FORMS
      ============================================================ */

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-dark);
  font-size: 0.9rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: #ffffff;
  transition: all 0.2s;
  font-size: 0.95rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
  transform: translateY(-1px);
}

/* Extra padding for select dropdowns to accommodate arrow */
select.form-control {
  padding-right: 2.5rem;
  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='%23475569' 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.75rem center;
  background-size: 1.25rem;
  appearance: none;
}

/* ============================================================
      TABLES & LISTS
      ============================================================ */

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table th {
  padding: 1rem;
  background: #f8fafc;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-align: left;
}

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

/* Ensure consistent first column alignment */
.table td:first-child,
.table th:first-child {
  padding-left: 1rem;
}

/* Status badge styling */
.table td {
  position: relative;
}

.estado-badge-container {
  display: inline-block;
  white-space: nowrap;
  position: static;
}

.estado-badge-container button {
  white-space: nowrap;
  display: inline-block;
}

.estado-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 140px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  z-index: 1000;
  margin-top: 0.25rem;
}

.estado-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  white-space: nowrap;
  border: none;
  background: none;
  cursor: pointer;
  transition: background-color 0.15s;
}

.estado-menu button:hover {
  background-color: #f3f4f6;
}

.table tbody tr td:first-child {
  padding-left: 1rem;
}

.table tbody tr {
  transition: background 0.1s;
}

.table tbody tr:hover {
  background: #fef2f2;
}

/* Chips */
.chip {
  font-size: 0.75rem;
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  font-weight: 600;
  display: inline-block;
  background: #f1f5f9;
  color: #64748b;
}

.chip-success {
  background: #dcfce7;
  color: #166534;
}

.chip-info {
  background: #dbeafe;
  color: #1e40af;
}

.chip-warning {
  background: #fef3c7;
  color: #92400e;
}

.chip-danger {
  background: #fee2e2;
  color: #991b1b;
}

/* Empty States */
.empty-state-icon {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1rem;
  opacity: 0.5;
}

/* ============================================================
      ALERTS
      ============================================================ */

.alert {
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid transparent;
  box-shadow: var(--shadow-sm);
}

.alert-success {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.alert-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out, visibility 0.3s;
    background: white;
    border-right: 1px solid var(--border);
    visibility: hidden;
    /* Ensure it's hidden */
    z-index: 100;
    /* Ensure on top */
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    visibility: visible;
  }

  .main-content {
    margin-left: 0;
    padding: 1rem;
    width: 100%;
  }

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

  .page-title {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .header-info {
    width: 100%;
    justify-content: space-between;
    padding: 0.5rem;
  }

  /* Ajuste para tablas en móvil */
  .table th,
  .table td {
    padding: 0.75rem 0.5rem;
    font-size: 0.85rem;
  }

  .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }

  /* Optimizar formularios en móvil */
  .flex.justify-between.items-center {
    /* Detectar headers de página */
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .flex.gap-4.flex-1 {
    /* Contenedores de búsqueda */
    flex-direction: column;
  }

  .w-64 {
    /* Inputs de ancho fijo a full width */
    width: 100% !important;
  }
}

/* Fix para evitar scroll horizontal indeseado en móvil */
html,
body {
  overflow-x: hidden;
  width: 100%;
}

.overflow-x-auto {
  -webkit-overflow-scrolling: touch;
}

/* Optimizaciones y animaciones ligeras */
.btn,
.btn-primary,
.btn-secondary,
.btn-outline {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}

tbody tr {
  transition: background-color 0.15s ease;
}