:root {
  --bg: #0A0A14;
  --surface: #12121F;
  --surface2: #1A1A2E;
  --surface3: #222238;
  --accent: #6C63FF;
  --green: #00D4AA;
  --red: #FF6B6B;
  --amber: #FFB547;
  --text: #F0EEFF;
  --text2: #9090B8;
  --text3: #5A5A7A;
  --border: rgba(108,99,255,0.15);
  --r: 14px;
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* LOGIN */
#login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 0%, rgba(108,99,255,0.15) 0%, transparent 60%), var(--bg);
}

.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-title {
  font-family: 'Syne', sans-serif;
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}
.login-sub { color: var(--text2); font-size: 13px; margin-bottom: 32px; }

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 28px;
  width: 100%;
  max-width: 380px;
}

.field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
  display: block;
}

.field-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.field-input:focus { border-color: var(--accent); }
.field-input::placeholder { color: var(--text3); }

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 700;
  padding: 13px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.9; }

/* APP */
#app { display: none; min-height: 100vh; flex-direction: column; }

/* SIDEBAR */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-logo {
  font-family: 'Syne', sans-serif;
  font-size: 16px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.sidebar-sub { font-size: 11px; color: var(--text3); margin-bottom: 28px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text2);
  margin-bottom: 4px;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(108,99,255,0.15); color: var(--accent); }
.nav-item .nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-spacer { flex: 1; }

.terapeuta-info {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.terapeuta-name { font-size: 13px; font-weight: 600; }
.terapeuta-email { font-size: 11px; color: var(--text3); margin-top: 2px; }
.logout-link { font-size: 11px; color: var(--text3); cursor: pointer; margin-top: 8px; display: block; }
.logout-link:hover { color: var(--red); }

/* MAIN */
.main { flex: 1; padding: 32px; overflow-y: auto; }

.page-section { display: none; }
.page-section.active { display: block; }

.page-title {
  font-family: 'Syne', sans-serif;
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 4px;
}
.page-sub { color: var(--text2); font-size: 14px; margin-bottom: 28px; }

/* STATS ROW */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
}
.stat-card .s-icon { font-size: 28px; margin-bottom: 8px; }
.stat-card .s-val {
  font-family: 'Syne', sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
}
.stat-card .s-label { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* CARDS */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  margin-bottom: 16px;
}
.card-title {
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 16px;
}

/* TABLE */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(108,99,255,0.04); }

/* BADGES */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-pending { background: rgba(255,181,71,0.15); color: var(--amber); border: 1px solid rgba(255,181,71,0.3); }
.badge-approved { background: rgba(0,212,170,0.15); color: var(--green); border: 1px solid rgba(0,212,170,0.3); }
.badge-denied { background: rgba(255,107,107,0.15); color: var(--red); border: 1px solid rgba(255,107,107,0.3); }
.badge-expired { background: rgba(90,90,122,0.2); color: var(--text3); border: 1px solid var(--border); }

/* BUTTONS */
.btn-approve {
  background: rgba(0,212,170,0.15);
  border: 1px solid rgba(0,212,170,0.3);
  color: var(--green);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
  margin-right: 6px;
}
.btn-approve:hover { background: rgba(0,212,170,0.25); }

.btn-deny {
  background: rgba(255,107,107,0.1);
  border: 1px solid rgba(255,107,107,0.3);
  color: var(--red);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
}
.btn-deny:hover { background: rgba(255,107,107,0.2); }

.btn-sm {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
}
.btn-sm:hover { border-color: var(--accent); color: var(--text); }

/* PATIENT CARD */
.patient-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.patient-row:last-child { border-bottom: none; }

.patient-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #9B6BFF);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.patient-info { flex: 1; min-width: 0; }
.patient-name { font-size: 14px; font-weight: 600; }
.patient-meta { font-size: 12px; color: var(--text2); margin-top: 3px; }

.patient-stats { display: flex; gap: 16px; text-align: center; }
.p-stat-val { font-family: 'Syne', sans-serif; font-size: 16px; font-weight: 700; }
.p-stat-label { font-size: 10px; color: var(--text3); margin-top: 1px; }

/* EMPTY */
.empty {
  text-align: center;
  padding: 40px;
  color: var(--text2);
}
.empty .e-icon { font-size: 40px; margin-bottom: 12px; }

/* SPINNER */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--surface3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ALERT */
.alert {
  background: rgba(255,181,71,0.1);
  border: 1px solid rgba(255,181,71,0.3);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--amber);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 30px;
  color: var(--text);
  font-size: 13px;
  padding: 10px 20px;
  z-index: 300;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: rgba(0,212,170,0.4); color: var(--green); }
.toast.error { border-color: rgba(255,107,107,0.4); color: var(--red); }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 28px;
  width: 100%;
  max-width: 460px;
}
.modal-title { font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 800; margin-bottom: 16px; }
.modal-btns { display: flex; gap: 10px; margin-top: 20px; }
.modal-btns .btn-primary { margin: 0; }


/* ══════════════════════════════════════════════════════════
   RESPONSIVE DESIGN — PANEL CLINICA DESKTOP (768px+)
══════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .layout { flex-direction: column; }
  .sidebar { 
    width: 100%; height: auto; position: relative; 
    border-right: none; border-bottom: 1px solid var(--border); 
    padding: 16px; flex-direction: row; flex-wrap: wrap; 
    justify-content: center; align-items: center; gap: 8px;
  }
  .sidebar-logo, .sidebar-sub { flex-basis: 100%; text-align: center; margin-bottom: 4px; }
  .sidebar-sub { margin-bottom: 12px; }
  .nav-item { width: auto; font-size: 12px; padding: 8px 12px; flex: 1 1 auto; justify-content: center; margin-bottom: 0; }
  .nav-item .nav-icon { font-size: 16px; width: auto; }
  .terapeuta-info { flex-basis: 100%; display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
  .logout-link { margin-top: 0; }
  .sidebar-spacer { display: none; }
  
  .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .main { padding: 16px; margin-left: 0 !important; width: 100% !important; }
  .page-section { padding: 16px; margin-left: 0 !important; width: 100% !important; }
  
  .table { display: block; overflow-x: auto; white-space: nowrap; }
}
}

@media (min-width: 768px) {

  body { background: #05050A; }

  #app {
    display: flex;
    flex-direction: row;
    width: 100%;
    min-height: 100vh;
    padding-bottom: 0;
  }

  /* Sidebar */
  .bottom-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    height: 100vh;
    transform: none !important;
    max-width: none !important;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 6px;
    padding: 28px 12px;
    border-radius: 0;
    border-right: 1px solid var(--border);
    border-bottom: none;
    background: var(--surface);
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    z-index: 200;
  }

  .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 14px;
    padding: 13px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text2);
    width: 100%;
    text-align: left;
  }

  .nav-label {
    display: inline-block;
    font-size: 14px;
    font-weight: 600;
  }

  .nav-icon {
    font-size: 20px;
    width: 26px;
    flex-shrink: 0;
    text-align: center;
  }

  .nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text);
  }

  .nav-item.active {
    background: rgba(108,99,255,0.18);
    color: var(--accent);
  }

  /* Header */
  .header {
    margin-left: 240px;
    width: calc(100% - 240px);
    box-sizing: border-box;
  }

  /* Contenido */
  .page-section {
    margin-left: 240px;
    width: calc(100% - 240px);
    max-width: none;
    padding: 36px 48px;
    min-height: 100vh;
    box-sizing: border-box;
  }

  .main {
    margin-left: 240px;
    padding: 36px 48px;
  }

  /* Grids dashboard */
  .dash-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
  }

  /* Login */
  .login-card { max-width: 440px; }

  /* Modales */
  .modal {
    max-width: 480px;
    margin: 0 auto;
    border-radius: 20px;
    height: auto;
    max-height: 88vh;
    bottom: auto;
    top: 50%;
    transform: translateY(-50%) scale(0.9);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    visibility: hidden;
  }
  .modal.open {
    transform: translateY(-50%) scale(1);
    opacity: 1;
    visibility: visible;
  }
}

@media (min-width: 1200px) {
  .bottom-nav { width: 260px; }
  .header { margin-left: 260px; width: calc(100% - 260px); }
  .main { margin-left: 260px; padding: 40px 64px; }
  .page-section { margin-left: 260px; width: calc(100% - 260px); padding: 40px 64px; }
  .dash-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 480px) {
  body {
    padding: 10px !important;
  }
  .container, .panel-body, .modal-content {
    width: 95% !important;
    margin: 5px auto !important;
    padding: 15px !important;
  }
  input, button {
    font-size: 14px !important;
    padding: 12px !important;
  }
  .bottom-nav {
    height: 60px !important;
  }
  #sos-btn {
    width: 90px !important;
    height: 90px !important;
  }
}



/* FIX RESPONSIVE TOTAL PARA PANEL CLINICA */
@media (max-width: 768px) {
  body { padding: 0 !important; }
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: relative;
    border-right: none; border-bottom: 1px solid var(--border);
    padding: 12px; flex-direction: row; flex-wrap: wrap;
    justify-content: space-between; align-items: center;
  }
  .sidebar-logo { flex-basis: 100%; text-align: center; margin-bottom: 4px; }
  .sidebar-sub { flex-basis: 100%; text-align: center; margin-bottom: 8px; display: none; }
  .nav-item { padding: 8px; font-size: 0; justify-content: center; width: auto; flex: 1; }
  .nav-item .nav-icon { font-size: 20px; }
  .nav-item.active { background: transparent; color: var(--accent); }
  .terapeuta-info { display: none; }
  .main { padding: 12px; margin-left: 0; width: 100%; }
  .stats-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-card .s-val { font-size: 20px; }
  
  .table { display: block; overflow-x: auto; white-space: nowrap; width: 100%; }
  
  .login-card { max-width: 95%; padding: 20px; margin: 0 auto; }
  #login-screen { padding: 12px; }
}
