/* ==========================================================================
   SorobanDojo — Admin Panel styles
   Reuses the CSS variables defined in style.css (--navy, --gold, --red, …)
   ========================================================================== */

.admin-body{
  background: var(--cream);
  min-height: 100vh;
}

/* ---------- Shell / Sidebar ------------------------------------------- */
.admin-shell{
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

.admin-sidebar{
  background: var(--navy);
  color: #fff;
  padding: 22px 16px 22px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.admin-brand{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
  border-bottom: 1px solid var(--line-dark);
}
.admin-brand .logo-mark{ width: 34px; height: 34px; flex-shrink: 0; }
.admin-brand-text .name{
  font-family: 'Shippori Mincho', serif;
  font-size: 14.5px;
  letter-spacing: .03em;
  color: #fff;
}
.admin-brand-text .tag{
  font-size: 10.5px;
  color: var(--gold);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-top: 2px;
}

.admin-nav{
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.admin-nav a{
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.72);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.admin-nav a svg{ width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.admin-nav a:hover{ background: rgba(255,255,255,.06); color: #fff; }
.admin-nav a.active{ background: var(--red); color: #fff; }
.admin-nav a.active svg{ opacity: 1; }
.admin-nav a.admin-logout{ margin-top: 10px; border-top: 1px solid var(--line-dark); padding-top: 16px; }

/* ---------- Main / Topbar ---------------------------------------------- */
.admin-main{ display: flex; flex-direction: column; min-width: 0; }

.admin-topbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 16px 28px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.admin-topbar h1{
  font-family: 'Shippori Mincho', serif;
  font-size: 20px;
  color: var(--navy);
  flex: 1;
}
.admin-topbar-user{ display: flex; align-items: center; gap: 10px; }
.admin-user-name{ font-size: 13.5px; font-weight: 600; color: var(--ink); }
.admin-user-avatar{
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gold); color: var(--navy-deep);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.admin-burger{ display: none; background: none; border: none; cursor: pointer; padding: 6px; }
.admin-burger span{ display: block; width: 22px; height: 2px; background: var(--navy); margin: 4px 0; border-radius: 2px; }

.admin-content{ padding: 26px 28px 60px; flex: 1; }

/* ---------- Stat cards --------------------------------------------------- */
.admin-stats{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card{
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::before{
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--bar-color, var(--gold));
}
.stat-card .stat-label{
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; margin-bottom: 8px;
}
.stat-card .stat-value{ font-size: 30px; font-weight: 800; color: var(--navy); line-height: 1; }
.stat-card .stat-sub{ font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.stat-card.c-green{ --bar-color: #2E9E5B; }
.stat-card.c-blue{ --bar-color: #2E6FE0; }
.stat-card.c-orange{ --bar-color: var(--gold); }
.stat-card.c-red{ --bar-color: var(--red); }

/* ---------- Panels / cards ------------------------------------------------ */
.admin-panel{
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 22px;
}
.admin-panel-head{
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 12px; flex-wrap: wrap;
}
.admin-panel-head h2{ font-size: 16px; color: var(--navy); font-family: 'Shippori Mincho', serif; }
.admin-panel-head .view-all{ font-size: 13px; color: var(--red); font-weight: 600; }

/* ---------- Tables --------------------------------------------------------- */
.admin-table-wrap{ overflow-x: auto; }
table.admin-table{ width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.admin-table th{
  text-align: left; padding: 10px 12px; color: var(--muted);
  font-weight: 600; text-transform: uppercase; font-size: 11.5px; letter-spacing: .04em;
  border-bottom: 2px solid var(--line); white-space: nowrap;
}
table.admin-table td{ padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.admin-table tr:last-child td{ border-bottom: none; }
table.admin-table tr:hover td{ background: var(--cream-2); }
table.admin-table td.nowrap, table.admin-table th.nowrap{ white-space: nowrap; }
.admin-table .muted{ color: var(--muted); }

/* status pills */
.pill{
  display: inline-block; padding: 4px 11px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; text-transform: capitalize; letter-spacing: .01em;
}
.pill-new{ background: #FDECEC; color: var(--red-dark); }
.pill-contacted, .pill-read{ background: #FFF3DC; color: #9A6B10; }
.pill-enrolled, .pill-replied{ background: #E4F6EA; color: #1E7A44; }
.pill-archived{ background: #EDEDF2; color: var(--muted); }
.pill-active{ background: #E4F6EA; color: #1E7A44; }
.pill-suspended{ background: #FDECEC; color: var(--red-dark); }

.role-badge{
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}
.role-badge.role-admin{ background: #FFF3DC; color: #9A6B10; }
.role-badge.role-teacher{ background: #E7EEFB; color: #2E4E9E; }
.role-badge.role-parent{ background: #EAF6EC; color: #237A44; }

/* ---------- Parent panel: student switcher (sidebar) -------------------- */
.student-switcher{
  padding: 14px 18px 16px; margin: 0 0 6px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.student-switcher label{
  display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: rgba(255,255,255,.5); margin-bottom: 6px;
}
.student-switcher select{
  width: 100%; padding: 9px 10px; border-radius: 7px; border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08); color: #fff; font-family: 'Poppins', sans-serif;
  font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.student-switcher select option{ color: var(--ink); }

.belt-chip{
  display: inline-block; font-size: 12px; font-weight: 600; padding: 4px 10px;
  border-radius: 999px; background: #F3EFE6; color: var(--navy); white-space: nowrap;
}

/* ---------- Modal (Prompt 02/17: teacher registration dialog) ---------- */
.modal-overlay{
  position: fixed; inset: 0; background: rgba(20,24,38,.55); backdrop-filter: blur(2px);
  display: none; align-items: flex-start; justify-content: center; z-index: 1000;
  padding: 5vh 16px; overflow-y: auto;
}
.modal-overlay.open{ display: flex; }
.modal-card{
  background: var(--paper, #fff); border-radius: 12px; width: 100%; max-width: 560px;
  padding: 26px 26px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.35); position: relative;
  animation: modal-pop .16s ease-out;
}
@keyframes modal-pop{ from{ opacity:0; transform: translateY(-8px) scale(.98);} to{ opacity:1; transform: translateY(0) scale(1);} }
.modal-card .admin-panel-head{ margin-bottom: 18px; padding: 0; border: none; }
.modal-close{
  position: absolute; top: 16px; right: 16px; width: 30px; height: 30px; border-radius: 50%;
  border: none; background: var(--cream-2); color: var(--ink); font-size: 18px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover{ background: var(--line); }
.modal-trigger-row{ display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.assign-list{
  max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; background: var(--cream-2);
}
.assign-list label{
  display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500;
  padding: 6px 2px; margin: 0; cursor: pointer;
}
.assign-list label input{ width: auto; margin: 0; accent-color: var(--red); cursor: pointer; }
.assign-list .muted-row{ color: var(--muted); font-size: 13px; padding: 4px 2px; }

/* ---------- Checkbox groups (e.g. lesson "Components covered") --------- */
.admin-form .field-row-2{ margin-bottom: 16px; }
.checkbox-row{ display: flex; gap: 10px; flex-wrap: wrap; }
.checkbox-pill{
  display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 13.5px;
  color: var(--ink); background: var(--paper); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 14px 9px 12px; cursor: pointer; user-select: none;
  transition: border-color .15s, background .15s;
}
.checkbox-pill:hover{ border-color: var(--gold); background: var(--cream-2); }
.checkbox-pill input[type=checkbox]{
  width: 17px; height: 17px; margin: 0; accent-color: var(--red); cursor: pointer; flex-shrink: 0;
}
.checkbox-pill:has(input:checked){ border-color: var(--red); background: #FDF2F1; color: var(--red-dark); }

/* ---------- Forms ------------------------------------------------------ */
.admin-form .field{ margin-bottom: 16px; }
.admin-form label{ display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.admin-form input[type=text],
.admin-form input[type=search],
.admin-form input[type=password],
.admin-form input[type=email],
.admin-form input[type=date],
.admin-form select,
.admin-form textarea{
  width: 100%; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--paper); font-family: 'Poppins', sans-serif;
  font-size: 14px; color: var(--ink);
}
.admin-form textarea{ min-height: 96px; resize: vertical; }
.admin-form input:focus, .admin-form select:focus, .admin-form textarea:focus{
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(227,168,59,.18);
}
/* Consistent search-box treatment across every admin filter bar (parents,
   registrations, students, teachers, audit log, ...) — a plain magnifying-
   glass icon so search inputs no longer render with mismatched browser
   default styling on pages that used a differently-named wrapper. */
.admin-form input[type=search]{
  padding-left: 38px;
  background-repeat: no-repeat;
  background-position: 13px center;
  background-size: 15px 15px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A8578' stroke-width='2'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
}
.admin-form input[type=search]::-webkit-search-cancel-button{ -webkit-appearance: none; }
.admin-filter-bar{ display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.admin-filter-bar .field{ margin-bottom: 0; min-width: 180px; }
.admin-filter-bar .field.grow{ flex: 1; min-width: 220px; }

/* ---------- Detail view ------------------------------------------------- */
.detail-grid{ display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 22px; }
.detail-item .dt-label{ font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.detail-item .dt-value{ font-size: 14.5px; color: var(--ink); font-weight: 500; word-break: break-word; }
.detail-item .dt-value.empty{ color: var(--muted); font-weight: 400; font-style: italic; }

/* ---------- Buttons (admin-scoped extras) ------------------------------- */
.btn-sm{ padding: 8px 16px; font-size: 12.5px; }
.btn-ghost{ background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover{ background: var(--cream-2); }
.btn-danger{ background: var(--red); color: #fff; border: none; }
.btn-danger:hover{ background: var(--red-dark); }
.admin-form .btn{ border: none; cursor: pointer; }

.flash-banner.admin{ margin-bottom: 20px; }

/* pagination */
.admin-pagination{ display: flex; gap: 6px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.admin-pagination a, .admin-pagination span{
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 8px; border-radius: 6px;
  border: 1px solid var(--line); font-size: 13px; color: var(--ink);
}
.admin-pagination a:hover{ background: var(--cream-2); }
.admin-pagination .current{ background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- Login page --------------------------------------------------- */
.admin-login-wrap{
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-deep) 100%);
  padding: 24px;
}
.admin-login-card{
  background: var(--paper); border-radius: 10px; padding: 40px 36px;
  width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.admin-login-card .admin-login-logo{ display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; }
.admin-login-card .admin-login-logo .name{ font-family: 'Shippori Mincho', serif; font-size: 18px; color: var(--navy); letter-spacing: .04em; }
.admin-login-card .admin-login-logo .tag{ font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.admin-login-card h2{ text-align: center; font-size: 15px; color: var(--muted); font-weight: 500; margin-bottom: 26px; }
.admin-login-card .btn{ width: 100%; text-align: center; justify-content: center; padding: 12px; font-size: 14.5px; }
.admin-hint{ margin-top: 18px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; }

/* ---------- Settings: sub-tabs ------------------------------------------- */
.settings-tabs{
  display: flex; gap: 6px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}
.settings-tabs a{
  padding: 10px 16px; font-size: 13.5px; font-weight: 600;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.settings-tabs a:hover{ color: var(--ink); }
.settings-tabs a.active{ color: var(--red); border-bottom-color: var(--red); }

/* ---------- Settings: logo uploader -------------------------------------- */
.logo-uploader{ display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.logo-preview{
  width: 84px; height: 84px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--cream-2); display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.logo-preview img{ max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-uploader .hint{ font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- Settings: repeatable rows (contact numbers / social links) --- */
.repeat-rows{ display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.repeat-row{
  display: grid; gap: 10px; align-items: end;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) 40px;
  background: var(--cream-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px;
}
.repeat-row .field{ margin-bottom: 0; }
.repeat-row .remove-row{
  width: 36px; height: 36px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--paper); color: var(--red); font-size: 18px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.repeat-row .remove-row:hover{ background: #FDECEC; }
.add-row-btn{
  display: inline-flex; align-items: center; gap: 6px; background: none;
  border: 1px dashed var(--line); color: var(--ink); font-size: 13px; font-weight: 600;
  border-radius: 6px; padding: 9px 14px; cursor: pointer;
}
.add-row-btn:hover{ border-color: var(--gold); color: var(--red); }

/* ---------- Settings: toggle switch --------------------------------------- */
.toggle-field{ display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.toggle-switch{ position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-switch input{ opacity: 0; width: 0; height: 0; }
.toggle-switch .slider{
  position: absolute; inset: 0; background: #D8D3C8; border-radius: 999px; cursor: pointer;
  transition: background .15s ease;
}
.toggle-switch .slider::before{
  content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .15s ease;
}
.toggle-switch input:checked + .slider{ background: #2E9E5B; }
.toggle-switch input:checked + .slider::before{ transform: translateX(18px); }
.toggle-field .toggle-label{ font-size: 13.5px; font-weight: 600; color: var(--ink); }

.field-hint{ font-size: 12px; color: var(--muted); margin-top: 5px; }
.field-with-select{ display: grid; grid-template-columns: 130px 1fr; gap: 8px; }
.api-block{ border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; margin-bottom: 18px; }
.api-block:last-child{ margin-bottom: 0; }
.api-block-head{ display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.api-block-head h3{ font-size: 14.5px; color: var(--navy); font-family: 'Shippori Mincho', serif; }

/* ---------- Responsive --------------------------------------------------- */
@media (max-width: 900px){
  .admin-shell{ grid-template-columns: 1fr; }
  .admin-sidebar{
    position: fixed; left: 0; top: 0; width: 240px; height: 100vh;
    transform: translateX(-100%); transition: transform .2s ease; z-index: 40;
  }
  .admin-shell.sidebar-open .admin-sidebar{ transform: translateX(0); }
  .admin-burger{ display: block; }
  .admin-content{ padding: 20px 16px 50px; }
  .admin-topbar{ padding: 14px 16px; }
}
