:root {
  /* Variables por defecto (Neumann - Morado) */
  --primary: #7c3aed;
  --primary-dark: #5b21b6;
  --primary-light: #a78bfa;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --success: #10b981;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --app-max-width: 600px; /* Diseño mobile first, centrado en desktop */
}

/* Tema Naranja (Otra Empresa) */
body[data-tenant="empresa"] {
  --primary: #f97316;
  --primary-dark: #c2410c;
  --primary-light: #fdba74;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: all 0.2s ease-in-out;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg);
  color: var(--text-main);
  min-height: 100vh;
}

/* Page Layout Wrappers */
.page-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

.sidebar-info {
  display: none; /* Hide on mobile */
}

.app-container {
  width: 100%;
  max-width: var(--app-max-width);
  background-color: var(--bg-card);
  min-height: 100vh;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

/* Splash Screen */
#splash {
  position: fixed;
  inset: 0;
  background-color: var(--primary);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
}
#splash img {
  width: 180px; /* Aumentado por defecto */
  filter: brightness(0) invert(1);
  margin-bottom: 20px;
  animation: pulse 2s infinite;
}

body[data-tenant="empresa"] #splash img {
  width: 220px; /* Mucho más grande para IE en Splash */
}

#splash h2 {
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 700;
}
.loader {
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
  margin-top: 20px;
}
@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* Header */
.top-header {
  padding: 24px 20px 16px;
  background: white;
  border-bottom: 1px solid var(--border-color);
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
}
.top-header img {
  width: 140px; /* Aumentado por defecto */
  margin-bottom: 12px;
  transition: transform 0.2s ease;
}

body[data-tenant="empresa"] .top-header img {
  width: 180px; /* Mucho más grande para IE en móvil */
  transform: scale(1.1);
}

.top-header h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-dark);
}
.subtitle {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Sections */
.main-content {
  padding: 24px 20px;
  flex-grow: 1;
}
.step-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-main);
}
.step-section {
  margin-bottom: 32px;
}

/* Mobile support block (fills visual space before selecting a date) */
.mobile-support-card {
  margin-top: 8px;
  padding: 18px 16px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: var(--shadow-md);
}

.mobile-support-card h3 {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 8px;
}

.mobile-support-sub {
  font-size: 13px;
  opacity: 0.92;
  line-height: 1.45;
  margin-bottom: 12px;
}

.mobile-support-list {
  list-style: none;
  display: grid;
  gap: 8px;
}

.mobile-support-list li {
  font-size: 13px;
  line-height: 1.35;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.mobile-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
}

.mobile-support-illustration {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}
.mobile-support-illustration p {
    margin-top: 8px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
  }

.mobile-support-illustration img {
  width: 100%;
  max-width: 250px;
  display: block;
  margin: 0 auto;
  opacity: 0.7;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

.mobile-support-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0);
  font-size: 11px;
  opacity: 0.85;
  letter-spacing: 0.2px;
}

/* Hide helper once user selected a date */
body.has-selected-date .mobile-support-card {
  display: none;
}

/* Date Carousel */
.date-carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 16px;
  scrollbar-width: thin; /* Firefox: makes it visible but subtle */
  scrollbar-color: var(--border-color) transparent;
  cursor: grab; /* Shows hand cursor for dragging */
}
.date-carousel:active {
  cursor: grabbing;
}
.date-carousel::-webkit-scrollbar { 
  height: 6px; 
} 
.date-carousel::-webkit-scrollbar-track {
  background: transparent;
}
.date-carousel::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: var(--radius-full);
}
.date-carousel::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-muted);
}
.date-chip {
  flex: 0 0 auto;
  min-width: 80px;
  background: white;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
  user-select: none;
  -webkit-user-select: none;
}
.date-chip:active { transform: scale(0.95); }
.date-chip .day-name { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.date-chip .day-num { font-size: 20px; font-weight: 800; color: var(--text-main); }
.date-chip .month { font-size: 11px; font-weight: 600; color: var(--text-muted); }

.date-chip.selected {
  border-color: var(--primary);
  background: var(--primary);
}
.date-chip.selected .day-name, .date-chip.selected .day-num, .date-chip.selected .month {
  color: white;
}

/* Time Grid */
.time-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.time-btn {
  background: white;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.time-btn:active { transform: scale(0.95); }
.time-btn:hover { border-color: var(--primary-light); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  justify-content: center;
  align-items: flex-end; /* Slide up on mobile */
}
.modal-content {
  background: white;
  width: 100%;
  max-width: var(--app-max-width);
  max-height: 90vh;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
  .modal-content { border-radius: var(--radius-lg); height: auto; max-height: 85vh; }
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  position: relative;
  text-align: center;
}
.modal-header h2 { font-size: 18px; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.modal-header p { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: #f1f5f9;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Info Modal Specifics */
.info-modal-content {
  border-radius: var(--radius-lg);
  max-width: 500px;
  height: auto;
}
.info-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: var(--bg);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}
.info-icon {
  color: var(--primary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}
.info-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-main);
}
.info-text b { color: var(--primary-dark); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

/* Material Forms */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.row-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.input-group {
  position: relative;
  margin-bottom: 16px;
}
.input-group input, .input-group textarea, .input-group select {
  width: 100%;
  padding: 24px 14px 10px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  outline: none;
}
.input-group input:focus, .input-group textarea:focus, .input-group select:focus {
  border-color: var(--primary);
  background: white;
}
.input-group label {
  position: absolute;
  top: 18px;
  left: 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  pointer-events: none;
  transform-origin: left top;
  transition: transform 0.2s, top 0.2s, font-size 0.2s;
}

/* Material effect: Float label up on focus or when input is not empty */
.input-group input:focus + label,
.input-group input:not(:placeholder-shown) + label,
.input-group textarea:focus + label,
.input-group textarea:not(:placeholder-shown) + label,
.input-group select:focus + label,
.input-group select:valid + label {
  top: 12px;
  font-size: 11px;
  font-weight: 700;
  transform: translateY(-50%);
  color: var(--primary);
}

.input-group select {
  padding-top: 24px;
  padding-bottom: 10px;
  appearance: none; /* remove default arrow */
}
/* Ensure label is correctly placed for select */
.input-group.select-group label {
   top: 12px;
   font-size: 11px;
   font-weight: 700;
   transform: translateY(-50%);
   color: var(--text-muted);
}
.input-group.select-group select:focus + label { color: var(--primary); }

textarea { resize: vertical; min-height: 80px; }

/* Buttons */
.btn-primary {
  width: 100%;
  background: var(--primary);
  color: white;
  border: none;
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  margin-top: 10px;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.7; cursor: not-allowed; }

/* Toast */
#toast {
  position: fixed;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-main);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 14px;
  z-index: 10001;
  opacity: 0;
  transition: all 0.3s;
}
#toast.show {
  bottom: 20px;
  opacity: 1;
}
.success-icon {
  width: 60px;
  height: 60px;
  background: #d1fae5;
  color: var(--success);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: bold;
  margin: 0 auto 16px;
}

/* =========================================
   DESKTOP OPTIMIZATIONS (Sidebar Layout)
   ========================================= */
@media (min-width: 900px) {
  body {
    background-color: #f1f5f9; /* Soft background to highlight the central app */
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  .page-layout {
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: 32px;
    padding: 40px;
    max-width: 1100px;
    width: 100%;
    margin: auto;
  }

  .sidebar-info {
    display: flex;
    flex-direction: column;
    width: 380px;
    background: linear-gradient(145deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
  }

  /* Decorative circle in the background of the sidebar */
  .sidebar-info::after {
    content: '';
    position: absolute;
    bottom: -60px;
    right: -60px;
    width: 250px;
    height: 250px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
  }

  .sidebar-content {
    padding: 40px;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    z-index: 1;
  }

  .sidebar-content img {
    max-width: 240px; /* Aumentado para mayor presencia */
    height: auto;
    margin-bottom: 40px;
    filter: brightness(0) invert(1);
    align-self: flex-start;
  }

  /* Excepción para logos que necesitan ser más grandes (ej. Instituto Empresa) */
  body[data-tenant="empresa"] .sidebar-content img {
    max-width: 280px; 
    transform: scale(1.1); /* Ligero aumento visual sin romper el padding */
    transform-origin: left center;
  }

  .sidebar-text-block h2 {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 12px;
    line-height: 1.2;
  }
  
  .sidebar-text-block p {
    font-size: 15px;
    line-height: 1.6;
    opacity: 0.9;
    margin-bottom: 40px;
  }

  .feature-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .feature-list li {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14.5px;
    font-weight: 600;
  }

  .feature-list .feature-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 800;
    font-size: 13px;
    flex-shrink: 0;
  }

  .sidebar-illustration {
    margin-top: 38px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    width: calc(100% + 48px);
    margin-left: -24px;
  }

  .sidebar-illustration img {
    width: 100%;
    max-width: none;
    display: block;
    margin: 0 auto;
    opacity: 0.62;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
  }

  .sidebar-illustration p {
    margin-top: 8px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
  }

  .sidebar-footer {
    margin-top: auto;
    font-size: 12px;
    font-weight: 500;
    opacity: 0.6;
    padding-top: 40px;
  }

  .app-container {
    flex: 1;
    min-height: auto;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
  }

  .top-header img {
    display: none; /* Hide logo in the main app header since it's already in the sidebar on desktop */
  }

  .top-header {
    text-align: left;
    padding: 32px 32px 16px;
    border-bottom: none;
  }
  
  .top-header h1 { font-size: 24px; }
  
  .main-content {
    padding: 0 32px 32px;
  }

  .mobile-support-card {
    display: none;
  }
}