/* app-extra.css — Eng-Life Elementary: login, admin, header, streak calendar. */

/* ===== App header ===== */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; gap: 10px;
  background: var(--glass-bg); border-bottom: 1px solid var(--glass-border);
  position: sticky; top: 0; z-index: 250;
}
.app-header-title { font-weight: 900; font-size: 16px; color: var(--text-primary); }
.app-header-title span { color: var(--accent-purple); }
.app-header-right { display: flex; align-items: center; gap: 10px; }
.app-user { font-size: 13px; font-weight: 700; color: var(--text-secondary); }
.app-logout {
  font-family: inherit; font-size: 12px; font-weight: 800; cursor: pointer;
  color: #fff; background: linear-gradient(135deg, #e74c3c, #c0392b);
  border: none; border-radius: 10px; padding: 6px 12px; text-decoration: none;
}

/* ===== Login ===== */
.login-screen { display: flex; align-items: center; justify-content: center; min-height: 70vh; }
.login-card {
  width: 100%; max-width: 360px; margin: 24px auto; text-align: center;
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  border-radius: 24px; padding: 28px 22px; box-shadow: 0 10px 30px rgba(31,80,50,0.10);
}
.login-logo { font-size: 52px; line-height: 1; }
.login-title {
  font-size: 22px; font-weight: 900; margin: 8px 0 2px;
  background: linear-gradient(135deg, #2ecc71, #9b59b6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.login-sub { font-size: 13px; color: var(--text-secondary); margin: 0 0 18px; }
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-input {
  font-family: inherit; font-size: 15px; width: 100%; box-sizing: border-box;
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--glass-border); background: rgba(255,255,255,0.6); color: var(--text-primary);
}
.login-input:focus { outline: none; border-color: var(--accent-purple); }
.login-error { color: #e74c3c; font-size: 12.5px; font-weight: 700; min-height: 16px; }
.login-btn {
  font-family: inherit; font-size: 15px; font-weight: 800; cursor: pointer;
  width: 100%; border: none; border-radius: 12px; padding: 12px; margin-top: 4px;
}
.login-btn.primary { color: #fff; background: linear-gradient(135deg, #2ecc71, #9b59b6); box-shadow: 0 6px 16px rgba(155,89,182,0.25); }
.login-btn.guest { margin-top: 12px; background: var(--glass-bg); border: 1px solid var(--glass-border); color: var(--text-primary); }
.login-btn:active { transform: scale(0.98); }
.login-guesthint { font-size: 11.5px; color: var(--text-secondary); margin: 8px 0 0; line-height: 1.4; }
.login-adminlink { display: inline-block; margin-top: 16px; font-size: 12.5px; font-weight: 700; color: var(--accent-purple); text-decoration: none; }

/* ===== Home / streak ===== */
.home-wrap { padding: 8px 0 16px; }
.streak-hero {
  text-align: center; padding: 20px; border-radius: 22px; margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(46,204,113,0.14), rgba(155,89,182,0.14));
  border: 1px solid var(--glass-border);
}
.streak-flame { font-size: 44px; line-height: 1; }
.streak-count { font-size: 44px; font-weight: 900; color: var(--text-primary); line-height: 1; }
.streak-label { font-size: 13px; font-weight: 700; color: var(--text-secondary); }
.streak-best { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }

.streak-cal-card { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 18px; padding: 14px; margin-bottom: 16px; }
.streak-cal-title { font-weight: 800; font-size: 15px; color: var(--text-primary); margin-bottom: 10px; }
.streak-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 800; color: var(--text-secondary); padding-bottom: 4px; }
.cal-cell {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--text-secondary);
  border-radius: 9px; background: rgba(255,255,255,0.4);
}
.cal-cell.empty { background: transparent; }
.cal-cell.studied { background: linear-gradient(135deg, #2ecc71, #27ae60); color: #fff; }
.cal-cell.today { outline: 2px solid var(--accent-purple); outline-offset: -2px; }
.streak-cal-hint { font-size: 11.5px; color: var(--text-secondary); margin-top: 10px; text-align: center; }

.guest-note {
  font-size: 12.5px; color: var(--text-primary); line-height: 1.5;
  background: rgba(241,196,15,0.14); border: 1px solid rgba(241,196,15,0.35);
  border-radius: 14px; padding: 12px 14px; margin-bottom: 16px;
}
.home-cta {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  border: none; cursor: pointer; color: #fff; font-family: inherit; font-size: 17px; font-weight: 800;
  background: linear-gradient(135deg, #2ecc71, #9b59b6); border-radius: 18px; padding: 16px;
  box-shadow: 0 8px 22px rgba(155,89,182,0.28);
}
.home-cta span { font-size: 12px; font-weight: 700; opacity: 0.9; }
.home-cta:active { transform: scale(0.98); }

/* ===== Guest-locked grammar units ===== */
.grammar-unit-card.locked { opacity: 0.72; }
.grammar-unit-locked { font-size: 13px; color: var(--text-secondary); padding: 10px 4px; line-height: 1.5; }
.grammar-unit-locked a { color: var(--accent-purple); font-weight: 800; }

/* ===== Admin page ===== */
.admin-wrap { max-width: 560px; margin: 0 auto; padding: 16px; }
.admin-card { margin-top: 6vh; }
.admin-panel { }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.admin-note {
  font-size: 12.5px; color: var(--text-primary); line-height: 1.5;
  background: rgba(241,196,15,0.15); border: 1px solid rgba(241,196,15,0.4);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 16px;
}
.admin-note code { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 5px; }
.admin-section { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 16px; padding: 14px; margin-bottom: 14px; }
.admin-section h3 { margin: 0 0 10px; font-size: 15px; color: var(--text-primary); }
.admin-help { font-size: 12px; color: var(--text-secondary); margin: 0 0 10px; }
.admin-add { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-add .login-input { flex: 1; min-width: 120px; }
.admin-add .login-btn { width: auto; padding: 12px 18px; margin-top: 0; }
.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: rgba(255,255,255,0.5); border: 1px solid var(--glass-border); }
.admin-uname { flex: 1; font-weight: 700; color: var(--text-primary); }
.admin-role { font-size: 11px; font-weight: 800; color: var(--text-secondary); text-transform: uppercase; }
.admin-role.is-admin { color: var(--accent-purple); }
.admin-del { font-family: inherit; font-size: 12px; font-weight: 800; cursor: pointer; color: #e74c3c; background: rgba(231,76,60,0.10); border: 1px solid rgba(231,76,60,0.3); border-radius: 8px; padding: 5px 10px; }
.admin-row-main { flex: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.admin-row-main .admin-uname { flex: none; }
.admin-pass {
  font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: 12.5px; font-weight: 700;
  color: #166534; background: rgba(46, 204, 113, 0.12); border: 1px dashed rgba(46, 204, 113, 0.5);
  border-radius: 8px; padding: 3px 8px; letter-spacing: 0.5px; user-select: all;
}
.admin-copy {
  font-family: inherit; font-size: 12px; font-weight: 800; cursor: pointer;
  color: #1d4ed8; background: rgba(59, 130, 246, 0.10); border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 8px; padding: 4px 10px;
}
.admin-copy:active { transform: scale(0.96); }
.admin-locked { font-size: 15px; opacity: 0.75; padding: 0 6px; cursor: default; }

/* 3-tab nav drives Practice/Lesson — hide the in-page grammar sub-tab bar */
.grammar-subtabs { display: none !important; }

/* ===== Custom modal (replaces native confirm/alert) ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(20, 22, 34, 0.45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity 0.18s ease;
  /* styles.css (legacy) sets .modal-overlay { pointer-events: none } and only
     re-enables it on .active — our modal uses .show, so re-enable it here or
     the modal renders but swallows no clicks. */
  pointer-events: none;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal-card {
  width: 100%; max-width: 360px; text-align: center;
  background: #ffffff; border-radius: 24px; padding: 26px 22px 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  transform: translateY(14px) scale(0.97); transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal-overlay.show .modal-card { transform: none; }
.modal-icon { font-size: 42px; line-height: 1; margin-bottom: 6px; }
.modal-title { font-size: 18px; font-weight: 900; color: #1f2430; margin-bottom: 6px; }
.modal-msg { font-size: 14px; color: #6b7280; line-height: 1.55; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; }
.modal-btn {
  flex: 1; font-family: inherit; font-size: 15px; font-weight: 800; cursor: pointer;
  border: none; border-radius: 14px; padding: 13px;
}
.modal-btn.cancel { background: #eceef3; color: #374151; }
.modal-btn.cancel:hover { background: #e2e5ec; }
.modal-btn.ok { color: #fff; background: linear-gradient(135deg, #2ecc71, #9b59b6); }
.modal-btn.ok.danger { background: linear-gradient(135deg, #ff6b6b, #e74c3c); }
.modal-btn:active { transform: scale(0.98); }

/* ===== Home: book-cover units grid (styled like the Life Elementary cover) ===== */
.home-screen { background: #3d3d3f; }
.home-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 10px; }
.streak-pill {
  font-size: 13px; font-weight: 800; color: #ffcf6b;
  background: rgba(255, 193, 7, 0.12);
  border: 1px solid rgba(251, 146, 60, 0.45); border-radius: 999px; padding: 6px 12px;
}
.streak-pill b { color: #ffb84d; }
.home-hello { font-size: 14px; font-weight: 800; color: #f3efe2; }

.home-book { text-align: center; margin: 4px 0 14px; }
.home-book-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 34px; font-weight: 700; letter-spacing: 10px; line-height: 1.1;
  color: #fff8e7; text-indent: 10px; /* balance the letter-spacing */
}
.home-book-sub {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 12px; letter-spacing: 4px; color: #ffd84d; margin-top: 2px; text-indent: 4px;
}

.home-screen .guest-note {
  color: #f3efe2; background: rgba(255, 216, 77, 0.10); border-color: rgba(255, 216, 77, 0.35);
}

.unit-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; padding-bottom: 10px; }
.unit-tile {
  position: relative; display: flex; flex-direction: column; align-items: center;
  aspect-ratio: 1 / 1.08; text-align: center; cursor: pointer; overflow: hidden;
  border: 3px solid #29292b; box-shadow: 0 0 0 1px #55555a, 0 6px 16px rgba(0,0,0,0.35);
  border-radius: 6px; padding: 12px 8px 10px; color: #fff;
  background:
    radial-gradient(ellipse at 50% 72%, rgba(255,255,255,0.16), transparent 62%),
    linear-gradient(165deg, var(--uc), color-mix(in srgb, var(--uc) 45%, #000 55%));
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.unit-tile:active { transform: scale(0.97); }
.unit-tile::after {
  content: '▶'; position: absolute; right: 8px; bottom: 8px;
  font-size: 10px; opacity: 0.9; color: #fff;
  background: rgba(0,0,0,0.35); width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.unit-tile-num, .unit-tile-name {
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--tc, #FFD84D); text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(0,0,0,0.55), 0 0 12px rgba(0,0,0,0.35);
}
.unit-tile-num { font-size: 15px; font-weight: 700; letter-spacing: 2px; line-height: 1.2; }
.unit-tile-name { font-size: 16px; font-weight: 700; letter-spacing: 0.5px; line-height: 1.15; max-width: 100%; overflow-wrap: break-word; }
.unit-tile-icon {
  font-size: 46px; line-height: 1; flex: 1; display: flex; align-items: center;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.35));
}
.unit-tile.locked { filter: grayscale(0.8); opacity: 0.55; }
.unit-tile.locked::after { content: '🔒'; background: transparent; font-size: 13px; }

/* Fallback for browsers without color-mix() */
@supports not (background: color-mix(in srgb, red, blue)) {
  .unit-tile { background: var(--uc); }
}

/* ===== Help tab (install guide + contact) ===== */
.help-wrap { padding: 20px 16px 32px; max-width: 560px; margin: 0 auto; }
.help-title {
  font-size: 26px; font-weight: 800; text-align: center; margin: 0 0 4px;
  background: linear-gradient(135deg, #2ecc71, #9b59b6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.help-sub { font-size: 13px; color: var(--text-secondary); text-align: center; margin: 0 0 18px; line-height: 1.5; }
.help-card {
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  border-radius: 18px; padding: 16px; margin-bottom: 14px;
}
.help-card-head { font-size: 16px; font-weight: 900; color: var(--text-primary); margin-bottom: 10px; }
.help-steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.help-steps li { font-size: 14px; color: var(--text-primary); line-height: 1.5; }
.help-steps li::marker { font-weight: 800; color: var(--accent-purple); }
.help-share-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px; font-size: 13px;
  background: rgba(0, 122, 255, 0.12); color: #007aff; border: 1px solid rgba(0, 122, 255, 0.3);
}
.help-note { font-size: 12px; color: var(--text-secondary); margin: 10px 0 0; line-height: 1.5; }
.help-contact { text-align: center; }
.help-contact-text { font-size: 13.5px; color: var(--text-primary); line-height: 1.55; margin: 0 0 12px; }
.help-zalo {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 900; letter-spacing: 0.5px;
  color: #fff; background: linear-gradient(135deg, #0068ff, #0091ff);
  border-radius: 14px; padding: 13px 22px; text-decoration: none;
  box-shadow: 0 8px 20px rgba(0, 104, 255, 0.30);
}
.help-zalo:active { transform: scale(0.97); }
.help-zalo-badge {
  font-size: 12px; font-weight: 900; padding: 3px 8px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.25); border: 1px solid rgba(255, 255, 255, 0.4);
}

/* ===== Legacy-CSS interop fixes =====
   styles.css toggles .toast/.modal via ".active"; our ui.js uses ".show".
   Map the .show state or these elements stay invisible / unclickable. */
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
/* Confetti pieces are appended to <body>; without this they intercept taps
   while falling (legacy container had pointer-events:none, pieces don't). */
.confetti { pointer-events: none; }

/* ===== Layout fixes (mobile) ===== */
/* The old pet home was a fixed scene; the units grid must scroll. */
.home-screen { overflow-y: auto; }
/* Kill leftover floating pet-home decorations (🍀 / ✨). */
.home-screen::before, .home-screen::after { content: none; }
/* Side padding so tiles don't touch the screen edges. */
.home-wrap { padding: 12px 16px 28px; }

/* Admin page: body is overflow:hidden app-wide; let the account list scroll. */
.admin-body { overflow-y: auto; }

/* ===== Hover states (desktop / mouse only) ===== */
@media (hover: hover) and (pointer: fine) {
  .unit-tile:not(.locked):hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 0 0 1px #8a8a90, 0 14px 28px rgba(0,0,0,0.5);
  }
  .unit-tile.locked { cursor: not-allowed; }
  .nav-item:hover { color: #9d7bd8; }
  .nav-item.active:hover { color: #7c3aed; }
  .help-zalo:hover,
  .login-btn:hover, .app-logout:hover, .modal-btn.ok:hover, .home-cta:hover,
  .grammar-quiz-btn:hover, .grammar-action-btn:hover, .grammar-next-btn:hover,
  .arr-submit-btn:hover, .admin-del:hover, .admin-copy:hover {
    filter: brightness(1.06);
  }
  .login-btn.guest:hover { background: rgba(255,255,255,0.85); filter: none; }
  .grammar-unit-card:not(.locked):hover { transform: translateY(-2px); }
}

/* ===== Desktop / tablet layout ===== */
@media (min-width: 700px) {
  /* Center the app as a comfortable reading column; the page gradient
     fills the space either side. */
  .app {
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    border-left: 1px solid rgba(255,255,255,0.65);
    border-right: 1px solid rgba(255,255,255,0.65);
    box-shadow: 0 0 60px rgba(31, 80, 50, 0.12);
    background: rgba(255,255,255,0.22);
  }
  .bottom-nav { border-radius: 0; }
  .nav-item { padding: 10px 0 8px; font-size: 12px; }

  .home-wrap { padding: 24px 32px 40px; }
  .home-book-title { font-size: 42px; }
  .home-hello { font-size: 15px; }
  .streak-pill { font-size: 14px; }
  .unit-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }

  .grammar-screen { padding: 28px 32px 80px; }

  .login-card { max-width: 420px; padding: 40px 36px; }
  .login-logo { font-size: 60px; }
  .login-title { font-size: 26px; }
  .modal-card { max-width: 400px; }
  .admin-wrap { max-width: 640px; padding: 24px; }
}

/* Wide desktop: 4 unit columns */
@media (min-width: 1000px) {
  .unit-grid { grid-template-columns: repeat(4, 1fr); }
}
