/* MediConnect - Estilos Globales */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overscroll-behavior: none;
  background: #f8fafc;
}

/* App Shell */
#app { max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; background: #fff; box-shadow: 0 0 40px rgba(0,0,0,.12); }

/* Scrollbar oculto para móvil */
::-webkit-scrollbar { display: none; }
* { -ms-overflow-style: none; scrollbar-width: none; }

/* Animaciones de página */
.page { display: none; min-height: 100vh; }
.page.active { display: flex; flex-direction: column; }
/* Página de chat — layout fijo para móvil */
#page-chat.active {
  height: 100vh;
  height: 100dvh;
  min-height: unset;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: #fff;
  z-index: 10;
}
.slide-in { animation: slideIn 0.3s ease; }
.slide-out { animation: slideOut 0.3s ease; }
.fade-in { animation: fadeIn 0.4s ease; }

@keyframes slideIn { from { transform: translateX(100%); opacity:0; } to { transform: translateX(0); opacity:1; } }
@keyframes slideOut { from { transform: translateX(0); opacity:1; } to { transform: translateX(-100%); opacity:0; } }
@keyframes fadeIn { from { opacity:0; transform: translateY(12px); } to { opacity:1; transform: translateY(0); } }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }
@keyframes bounce { 0%,100%{transform:translateY(-25%);animation-timing-function:cubic-bezier(.8,0,1,1)} 50%{transform:none;animation-timing-function:cubic-bezier(0,0,.2,1)} }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ripple { to { transform: scale(4); opacity: 0; } }

/* Bottom Nav */
.bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; background: #fff; border-top: 1px solid #e2e8f0; z-index: 100; padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 10px 0 8px; cursor: pointer; transition: all .2s; position: relative; color: #94a3b8; }
.bottom-nav-item.active { color: #1a3687; }
.bottom-nav-item i { font-size: 20px; margin-bottom: 3px; }
.bottom-nav-item span { font-size: 10px; font-weight: 500; }
.bottom-nav-item::after { content:''; position:absolute; top:0; left:50%; transform:translateX(-50%); width:0; height:2px; background:#1a3687; transition: width .3s; border-radius: 0 0 2px 2px; }
.bottom-nav-item.active::after { width: 40%; }

/* Chat Bubble */
.chat-bubble { max-width: 82%; padding: 10px 14px; border-radius: 18px; margin: 3px 0; animation: fadeIn 0.3s ease; word-wrap: break-word; line-height: 1.45; font-size: 14.5px; }
.chat-bubble.user { background: #1a3687; color: #fff; border-bottom-right-radius: 4px; margin-left: auto; }
.chat-bubble.bot { background: #f1f5f9; color: #1e293b; border-bottom-left-radius: 4px; margin-right: auto; }
.chat-bubble.bot .typing-dot { display: inline-block; width: 7px; height: 7px; background: #94a3b8; border-radius: 50%; margin: 0 2px; animation: bounce 1s infinite; }
.chat-bubble.bot .typing-dot:nth-child(2) { animation-delay: .15s; }
.chat-bubble.bot .typing-dot:nth-child(3) { animation-delay: .3s; }

/* Cards */
.doctor-card { background: #fff; border-radius: 16px; padding: 16px; margin: 10px 0; border: 1.5px solid #e2e8f0; transition: all .2s; cursor: pointer; position: relative; overflow: hidden; }
.doctor-card:active { transform: scale(.98); }
.doctor-card.selected { border-color: #1a3687; background: #eef2ff; }
.doctor-card .available-badge { position: absolute; top: 12px; right: 12px; width: 10px; height: 10px; border-radius: 50%; }
.doctor-card .available-badge.online { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.doctor-card .available-badge.offline { background: #94a3b8; }

/* Buttons */
.btn-primary { background: linear-gradient(135deg, #1a3687, #1e4db7); color: #fff; border: none; border-radius: 14px; padding: 15px 24px; font-size: 15px; font-weight: 600; cursor: pointer; width: 100%; transition: all .2s; letter-spacing: .3px; }
.btn-primary:active { transform: scale(.97); opacity: .9; }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; transform: none; }
.btn-secondary { background: #f1f5f9; color: #334155; border: 1.5px solid #e2e8f0; border-radius: 14px; padding: 13px 20px; font-size: 15px; font-weight: 500; cursor: pointer; width: 100%; transition: all .2s; }
.btn-secondary:active { transform: scale(.97); }
.btn-danger { background: #fee2e2; color: #dc2626; border: 1.5px solid #fecaca; border-radius: 14px; padding: 13px 20px; font-size: 15px; font-weight: 600; cursor: pointer; transition: all .2s; }

/* Input */
.input-field { width: 100%; padding: 14px 16px; border: 1.5px solid #e2e8f0; border-radius: 12px; font-size: 15px; outline: none; transition: border-color .2s; background: #fff; color: #1e293b; }
.input-field:focus { border-color: #1a3687; box-shadow: 0 0 0 3px rgba(26,54,135,.12); }
.input-label { font-size: 13px; font-weight: 600; color: #475569; margin-bottom: 6px; display: block; }

/* Avatar */
.avatar { width: 48px; height: 48px; border-radius: 50%; background: linear-gradient(135deg, #1a3687, #2156c9); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px; font-weight: 700; flex-shrink: 0; }
.avatar.lg { width: 72px; height: 72px; font-size: 26px; }
.avatar.sm { width: 36px; height: 36px; font-size: 14px; }

/* Stars */
.stars { display: flex; gap: 3px; }
.star { font-size: 16px; color: #f59e0b; cursor: pointer; transition: transform .15s; }
.star:active { transform: scale(1.3); }
.star.empty { color: #cbd5e1; }

/* Toast */
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); padding: 12px 20px; border-radius: 12px; font-size: 14px; font-weight: 500; z-index: 9999; animation: fadeIn .3s ease; max-width: 90%; text-align: center; }
.toast.success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.toast.error { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.toast.info { background: #e8edff; color: #1a3687; border: 1px solid #c7d3f0; }

/* Status Badge */
.status-badge { padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.status-badge.pending { background: #fef9c3; color: #a16207; }
.status-badge.waiting { background: #e8edff; color: #1a3687; }
.status-badge.in_progress { background: #dcfce7; color: #15803d; }
.status-badge.completed { background: #f1f5f9; color: #475569; }
.status-badge.cancelled { background: #fee2e2; color: #dc2626; }

/* Header */
.app-header { background: #fff; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #f1f5f9; position: sticky; top: 0; z-index: 50; }
.app-header h2 { font-size: 18px; font-weight: 700; color: #1e293b; margin: 0; }
.back-btn { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; background: #f8fafc; border-radius: 10px; cursor: pointer; transition: all .2s; }
.back-btn:active { transform: scale(.9); }

/* Specialty Chip */
.specialty-chip { padding: 8px 16px; border-radius: 20px; border: 1.5px solid #e2e8f0; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: all .2s; color: #475569; background: #fff; }
.specialty-chip.selected, .specialty-chip:active { background: #1a3687; color: #fff; border-color: #1a3687; }

/* Schedule toggle */
.schedule-toggle { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid #f1f5f9; }
.toggle-switch { position: relative; width: 46px; height: 26px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #cbd5e1; border-radius: 26px; cursor: pointer; transition: .3s; }
.slider:before { content:''; position: absolute; width: 20px; height: 20px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .3s; }
.toggle-switch input:checked + .slider { background: #1a3687; }
.toggle-switch input:checked + .slider:before { transform: translateX(20px); }

/* Video Call */
.video-container { background: #0f172a; border-radius: 16px; overflow: hidden; position: relative; }
.video-controls { display: flex; gap: 16px; justify-content: center; padding: 16px; }
.video-btn { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all .2s; border: none; font-size: 20px; }
.video-btn:active { transform: scale(.9); }
.video-btn.mute { background: #334155; color: #fff; }
.video-btn.mute.active { background: #dc2626; }
.video-btn.end { background: #dc2626; color: #fff; }
.video-btn.cam { background: #334155; color: #fff; }

/* Skeleton loader */
.skeleton { background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 8px; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* Notification dot */
.notif-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; background: #ef4444; border-radius: 50%; border: 2px solid #fff; }

/* Loading spinner */
.spinner { width: 24px; height: 24px; border: 3px solid #c7d3f0; border-top-color: #1a3687; border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto; }

/* Gradient header hero — Paleta MSP Ecuador (azul institucional) */
.hero-gradient {
  background: linear-gradient(150deg, #1a3687 0%, #1e4db7 45%, #2563eb 80%, #3b82f6 100%);
  position: relative;
  overflow: hidden;
}

/* Chat input area — SIEMPRE visible, pegada al fondo */
.chat-input-area {
  flex-shrink: 0;
  background: #fff;
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 2px solid #e2e8f0;
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 60;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}
.chat-input {
  flex: 1;
  padding: 10px 16px;
  border: 1.5px solid #e2e8f0;
  border-radius: 24px;
  font-size: 15px;
  outline: none;
  resize: none;
  max-height: 100px;
  min-height: 46px;
  height: 46px;
  transition: border-color .2s;
  line-height: 1.5;
  background: #f1f5f9;
  color: #1e293b;
  display: block;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
}
.chat-input:focus { border-color: #1a3687; background: #fff; box-shadow: 0 0 0 3px rgba(26,54,135,0.12); }
.chat-input::placeholder { color: #94a3b8; }
.send-btn { width: 44px; height: 44px; min-width: 44px; background: #1a3687; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all .2s; border: none; flex-shrink: 0; }
.send-btn:active { transform: scale(.9); }
.send-btn i { color: #fff; font-size: 16px; }
.send-btn:disabled { background: #94a3b8; cursor: not-allowed; }

/* Ripple effect */
.ripple { position: relative; overflow: hidden; }
.ripple::after { content:''; position: absolute; width: 5px; height: 5px; background: rgba(255,255,255,.3); border-radius: 50%; transform: scale(1); animation: ripple .6s linear; top: 50%; left: 50%; }

/* Safe area */
.pb-safe { padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }
.pt-safe { padding-top: env(safe-area-inset-top); }

/* Modal overlay */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .2s ease; }
.modal-sheet { background: #fff; border-radius: 24px 24px 0 0; width: 100%; max-width: 480px; padding: 24px; max-height: 90vh; overflow-y: auto; animation: slideUp .3s ease; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* Misc */
.divider { height: 1px; background: #f1f5f9; margin: 12px 0; }
.section-title { font-size: 13px; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: .8px; margin-bottom: 12px; }
.card { background: #fff; border-radius: 16px; padding: 16px; border: 1px solid #f1f5f9; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.badge-count { background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
