/* ===== EduAyuda — prototipo ===== */
:root {
  --brand: #4f46e5;
  --brand-2: #7c73ff;
  --brand-soft: #eef0ff;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --bg: #ffffff;
  --bg-outer: #eceef5;
  --card: #ffffff;
  --line: #e7e8f0;
  --text: #14162b;
  --muted: #757892;
  --shadow: 0 10px 30px rgba(30, 27, 90, .10);
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand-soft: #23234a;
    --green-soft: #12341f;
    --amber-soft: #3a2a0c;
    --bg: #14152a;
    --bg-outer: #0a0b16;
    --card: #1c1e38;
    --line: #2b2d4d;
    --text: #eceeffe6;
    --muted: #9a9cc0;
    --shadow: 0 12px 34px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
/* El atributo hidden SIEMPRE gana (evita que los modales queden tapando la pantalla) */
[hidden] { display: none !important; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-outer);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ---- Contenedor tipo teléfono ---- */
.app {
  position: relative;
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
  overflow: hidden;
}
@media (min-width: 500px) {
  body { display: flex; align-items: center; justify-content: center; padding: 24px 0; }
  .app {
    width: 460px;
    flex: 0 0 auto;
    height: min(880px, calc(100dvh - 48px));
    min-height: auto;
    border-radius: 34px;
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
  }
}

/* ---- Pantallas ---- */
.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.scroll { flex: 1; overflow-y: auto; padding: 16px 18px 26px; }
.has-tabbar .scroll { padding-bottom: 84px; }

/* ---- Barras superiores ---- */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 14px; min-height: 56px;
}
.topbar.solid { border-bottom: 1px solid var(--line); }
.topbar h2 { font-size: 18px; font-weight: 700; }
.icon-btn {
  border: none; background: var(--brand-soft); color: var(--brand);
  width: 38px; height: 38px; border-radius: 12px; font-size: 24px; line-height: 1;
  cursor: pointer; font-weight: 700;
}

/* ---- Botones ---- */
.btn {
  display: block; width: 100%; border: none; border-radius: 14px;
  padding: 15px; font-size: 16px; font-weight: 700; cursor: pointer;
  margin-top: 12px; font-family: inherit;
}
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 8px 18px rgba(79, 70, 229, .35); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost { background: transparent; color: var(--muted); box-shadow: none; }

/* ---- Bienvenida ---- */
.welcome { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 30px 26px 40px; text-align: center; }
.logo-badge {
  width: 84px; height: 84px; border-radius: 26px; margin: 0 auto 18px;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; font-size: 44px;
  box-shadow: 0 14px 30px rgba(79, 70, 229, .45);
}
.welcome-title { font-size: 34px; font-weight: 800; letter-spacing: -.5px; }
.welcome-sub { color: var(--muted); margin: 10px 0 22px; font-size: 16px; line-height: 1.5; }
.welcome-list { list-style: none; text-align: left; display: grid; gap: 12px; margin-bottom: 26px; }
.welcome-list li { background: var(--card); border: 1px solid var(--line); padding: 14px 16px; border-radius: 14px; font-size: 15px; }
.welcome-foot { color: var(--muted); font-size: 12.5px; margin-top: 14px; }

/* ---- Formularios ---- */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13.5px; font-weight: 600; color: var(--text); }
.field input, .field select, .field textarea {
  font-family: inherit; font-size: 15px; color: var(--text);
  background: var(--card); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 13px 14px; width: 100%; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }
.field textarea { min-height: 96px; resize: vertical; }
.hint { font-size: 12.5px; color: var(--muted); }
.form-error { color: #e11d48; font-size: 13.5px; font-weight: 600; min-height: 0; }
.form-error:empty { display: none; }
.form-desc { color: var(--muted); font-size: 14.5px; margin-bottom: 14px; line-height: 1.5; }

/* ---- Inicio ---- */
.home-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 18px 8px;
}
.greet-hi { color: var(--muted); font-size: 15px; }
.greet-name { font-size: 22px; font-weight: 800; }
.avatar, .avatar-lg {
  background: linear-gradient(140deg, var(--brand), var(--brand-2)); color: #fff;
  display: grid; place-items: center; font-weight: 800; border: none; cursor: pointer;
}
.avatar { width: 42px; height: 42px; border-radius: 50%; font-size: 17px; }
.avatar-lg { width: 76px; height: 76px; border-radius: 50%; font-size: 30px; margin: 0 auto 12px; }
.avatar.has-photo, .avatar-lg.has-photo { padding: 0; overflow: hidden; }
.avatar img, .avatar-lg img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.btn-foto {
  background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer; margin: 2px auto 6px;
}
.ac-badges { font-size: 12px; color: var(--muted); margin-top: 3px; }
.d-foto { text-align: center; margin: 8px 0 4px; color: var(--muted); font-size: 13px; }
.d-foto img { width: 150px; height: 150px; object-fit: cover; border-radius: 16px; border: 1px solid var(--line); }
.searchbar {
  display: flex; align-items: center; gap: 8px; color: var(--muted);
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 15px; font-size: 15px; margin-bottom: 16px;
}
.banner {
  display: flex; align-items: center; gap: 12px; font-size: 13px; line-height: 1.5;
  background: var(--brand-soft); border-radius: 14px; padding: 13px 15px; margin-bottom: 20px;
}
.banner-emoji { font-size: 22px; }
.section-title { font-size: 16px; font-weight: 800; margin: 6px 0 12px; display: flex; align-items: center; gap: 8px; }

/* ---- Chips ---- */
.chip { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.chip-brand { background: var(--brand-soft); color: var(--brand); }

/* ---- Grid de categorías ---- */
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 22px; }
.cat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 16px 14px; cursor: pointer; text-align: left; transition: transform .1s;
}
.cat-card:active { transform: scale(.97); }
.cat-emoji { font-size: 30px; }
.cat-name { font-weight: 700; font-size: 15px; margin-top: 10px; }
.cat-desc { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

/* ---- Lista de tipos ---- */
.tipo-list, .orders-list { display: grid; gap: 12px; }
.tipo-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 15px 16px; cursor: pointer; display: flex; gap: 12px; align-items: flex-start;
}
.tipo-card:active { transform: scale(.99); }
.tipo-dot { font-size: 16px; margin-top: 2px; }
.tipo-info { flex: 1; }
.tipo-name { font-weight: 700; font-size: 15px; }
.tipo-desc { color: var(--muted); font-size: 13px; margin-top: 3px; line-height: 1.45; }
.tipo-arrow { color: var(--muted); font-size: 22px; }

/* ---- Badge de modo ---- */
.modo-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; padding: 7px 12px; border-radius: 999px; margin-bottom: 14px; }
.modo-ia { background: var(--green-soft); color: var(--green); }
.modo-revision { background: var(--amber-soft); color: var(--amber); }

/* ---- Confirmación ---- */
.confirm { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 30px 26px; text-align: center; }
.confirm-icon { font-size: 62px; margin-bottom: 8px; }
.confirm-msg { color: var(--muted); font-size: 15px; line-height: 1.55; margin: 8px 0 22px; }
.confirm-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 6px 16px; margin-bottom: 12px; }
.row { display: flex; justify-content: space-between; padding: 12px 0; font-size: 14.5px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: none; }
.row span { color: var(--muted); }

/* ---- Pedidos ---- */
.order-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 15px 16px; }
.order-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.order-name { font-weight: 700; font-size: 15px; }
.order-cat { color: var(--muted); font-size: 12.5px; }
.order-status { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.st-ok { background: var(--green-soft); color: var(--green); }
.st-wait { background: var(--amber-soft); color: var(--amber); }
.order-when { color: var(--muted); font-size: 12px; margin-top: 8px; }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty-emoji { font-size: 44px; display: block; margin-bottom: 12px; }

/* ---- Perfil ---- */
.profile-head { text-align: center; padding: 20px 0 22px; }
.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 8px; text-align: center; }
.stat b { display: block; font-size: 24px; font-weight: 800; color: var(--brand); }
.stat span { font-size: 12px; color: var(--muted); }
.profile-actions { margin-top: 20px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 12px; margin-top: 18px; }

/* ---- Tab bar ---- */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 66px;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 600; font-family: inherit;
}
.tab .ti { font-size: 21px; }
.tab.active { color: var(--brand); }

/* ===================== PANEL ADMIN ===================== */
.admin-body { background: var(--bg-outer); min-height: 100dvh; }

.admin-login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.admin-login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: 32px 26px; width: 100%; max-width: 380px; text-align: center; box-shadow: var(--shadow);
}
.admin-login-card .logo-badge { margin-bottom: 16px; }
.admin-login-card h1 { font-size: 24px; font-weight: 800; }
.admin-login-card .form { margin-top: 20px; text-align: left; }

.admin-panel { max-width: 820px; margin: 0 auto; padding: 22px 18px 60px; }
.admin-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.admin-head h1 { font-size: 24px; font-weight: 800; }
.btn-mini {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 10px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-mini-danger { color: #e11d48; border-color: #f3b8c4; }
.btn-borrar {
  display: block; width: 100%; border: 1.5px solid #e11d48; background: transparent; color: #e11d48;
  border-radius: 14px; padding: 13px; font-size: 15px; font-weight: 700; cursor: pointer; margin-top: 14px; font-family: inherit;
}
.btn-borrar:active { background: rgba(225, 29, 72, .08); }

.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.astat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 8px; text-align: center; }
.astat-ico { font-size: 18px; }
.astat b { display: block; font-size: 22px; font-weight: 800; color: var(--brand); }
.astat span { font-size: 11.5px; color: var(--muted); }

.admin-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.vtab { flex: 1; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 12px; padding: 11px; font-size: 14.5px; font-weight: 700; cursor: pointer; font-family: inherit; }
.vtab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.admin-filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.fchip {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 8px 15px; font-size: 13.5px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.fchip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.fchip.refresh { margin-left: auto; font-size: 17px; padding: 8px 13px; }

.admin-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.admin-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 15px 16px; cursor: pointer; transition: transform .1s, border-color .1s;
}
.admin-card.pend { border-left: 4px solid var(--amber); }
.admin-card:hover { transform: translateY(-2px); border-color: var(--brand); }
.ac-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.ac-tag { font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.ac-num { color: var(--muted); font-size: 12.5px; font-weight: 700; }
.ac-tipo { font-weight: 700; font-size: 15.5px; }
.ac-cat { color: var(--muted); font-size: 13px; margin-top: 2px; }
.ac-alumno { font-size: 13px; margin-top: 10px; }
.ac-when { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* Modal detalle */
.admin-modal { position: fixed; inset: 0; background: rgba(10, 11, 22, .55); display: grid; place-items: center; padding: 16px; z-index: 50; }
.admin-modal-card {
  background: var(--bg); border: 1px solid var(--line); border-radius: 22px;
  padding: 24px 22px; width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto; position: relative; box-shadow: var(--shadow);
}
.modal-close {
  position: absolute; top: 14px; right: 14px; border: none; background: var(--brand-soft); color: var(--brand);
  width: 34px; height: 34px; border-radius: 10px; font-size: 15px; cursor: pointer; font-weight: 700;
}
.d-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.d-tipo { font-size: 21px; font-weight: 800; }
.d-alumno { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 16px 0; display: grid; gap: 6px; font-size: 14px; }
.wa-btn { display: inline-block; margin-top: 6px; background: #25d366; color: #04331b; text-decoration: none; font-weight: 700; font-size: 13.5px; padding: 9px 14px; border-radius: 10px; text-align: center; }
.d-sub { font-size: 14px; font-weight: 800; margin: 16px 0 8px; }
.d-datos { display: grid; gap: 8px; }
.d-row { display: flex; justify-content: space-between; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.d-row span { color: var(--muted); }
.d-row b { text-align: right; }
.d-textarea {
  width: 100%; min-height: 130px; resize: vertical; font-family: inherit; font-size: 15px; color: var(--text);
  background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 13px 14px; outline: none;
}
.d-textarea:focus { border-color: var(--brand); }

.ia-resp {
  white-space: pre-wrap; word-wrap: break-word;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 15px; font-size: 14.5px; line-height: 1.6; color: var(--text);
  max-height: 54dvh; overflow-y: auto;
}
.ia-note {
  background: var(--green-soft); color: var(--green); font-size: 13px; font-weight: 600;
  padding: 9px 12px; border-radius: 10px; margin-bottom: 8px;
}
.ver-resp { color: var(--brand); }

@media (max-width: 520px) {
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Pantalla simple: pedir ayuda ===== */
.pedir-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 20px 18px; }
.pedir-title { font-size: 20px; font-weight: 800; }
.pedir-sub { color: var(--muted); font-size: 14px; margin: 6px 0 16px; line-height: 1.5; }
#pedir-form textarea { min-height: 140px; }
.order-msg { color: var(--text); font-size: 14px; margin-top: 8px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.order-fecha { font-size: 13px; color: var(--muted); margin-top: 8px; font-weight: 600; }
.order-nota { font-size: 13.5px; margin-top: 8px; background: var(--brand-soft); color: var(--text); padding: 9px 11px; border-radius: 10px; line-height: 1.5; }
.prog-wrap { display: flex; align-items: center; gap: 9px; margin-top: 10px; }
.prog-bar { flex: 1; height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.prog-fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width .3s; }
.prog-txt { font-size: 12.5px; font-weight: 800; color: var(--brand); min-width: 36px; text-align: right; }
