/* District admin — English control panel stylesheet */

:root {
  --navy: #12305c;
  --navy-2: #1b3a6b;
  --blue: #1d4e89;
  --ink: #1f2937;
  --muted: #64748b;
  --tint: #f2f6fb;
  --line: #dbe4f0;
  --ok: #0e7a4a;
  --ok-bg: #e8f6ef;
  --err: #b3261e;
  --err-bg: #fdecea;
  --warn: #a16207;
  --warn-bg: #fdf3d7;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--tint); color: var(--ink); line-height: 1.55; }
a { color: var(--blue); }
h1, h2, h3 { color: var(--navy); line-height: 1.3; }
h1 { font-size: 1.5rem; margin: 0 0 .4rem; }
h2 { font-size: 1.15rem; margin: 0 0 .7rem; }
.muted { color: var(--muted); }

/* ---------------- auth ---------------- */
/* [hidden] must win over any display rule below (auth-screen is flex). */
[hidden] { display: none !important; }

.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.2rem; background: linear-gradient(160deg, var(--navy), var(--blue)); }
.auth-card { background: #fff; width: 100%; max-width: 430px; border-radius: 14px; padding: 1.8rem 1.7rem; box-shadow: 0 18px 50px rgba(0,0,0,.25); }
.auth-brand { display: flex; gap: .8rem; align-items: center; margin-bottom: 1.1rem; }
.auth-brand strong { display: block; color: var(--navy); }
.auth-brand span { font-size: .85rem; color: var(--muted); }
.auth-badge, .topbar-logo { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 10px; background: var(--navy); color: #fff; font-weight: 800; flex: none; }
.auth-hint { color: var(--muted); font-size: .9rem; margin-top: 0; }
.auth-links { font-size: .92rem; margin-bottom: 0; }

/* ---------------- fields ---------------- */
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .9rem; font-size: .88rem; }
.field > span { font-weight: 600; color: var(--navy); }
.field input, .field select, .field textarea {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 8px; padding: .52rem .7rem; width: 100%;
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(29,78,137,.32); border-color: var(--blue); }
.field-hint { color: var(--muted); font-size: .8rem; }
.form-error { color: var(--err); background: var(--err-bg); border: 1px solid #f5c6c2; border-radius: 8px; padding: .5rem .7rem; font-size: .9rem; margin: .2rem 0 .8rem; }
.form-error:empty, .form-ok:empty { display: none; }
.form-ok { color: var(--ok); background: var(--ok-bg); border: 1px solid #bfe7d3; border-radius: 8px; padding: .5rem .7rem; font-size: .9rem; margin: .2rem 0 .8rem; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 1rem; }

/* ---------------- buttons ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid transparent; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; font-size: .93rem; padding: .52rem 1.05rem; text-decoration: none; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--blue); }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { background: var(--tint); }
.btn-danger { background: #fff; color: var(--err); border-color: #f0b8b4; }
.btn-danger:hover { background: var(--err-bg); }
.btn-sm { padding: .3rem .7rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn.is-busy { pointer-events: none; }
.btn-link { background: none; border: 0; color: var(--blue); cursor: pointer; font: inherit; font-weight: 600; padding: 0; }
.btn-link:hover { text-decoration: underline; }
.actions-cell { display: flex; gap: .45rem; flex-wrap: wrap; }

/* ---------------- topbar / layout ---------------- */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1.1rem; position: sticky; top: 0; z-index: 30; flex-wrap: wrap; }
.topbar-left { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.topbar-logo { background: rgba(255,255,255,.14); width: 38px; height: 38px; border-radius: 8px; font-size: .85rem; }
.topbar-title { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.topbar-title strong { font-size: .98rem; }
.topbar-title span { font-size: .78rem; color: #b9cdea; }
.topbar-right { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.who { font-size: .85rem; color: #cfdcf0; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.district-switch { display: flex; align-items: center; gap: .45rem; font-size: .85rem; color: #cfdcf0; }
.district-switch select { font: inherit; border-radius: 8px; border: 1px solid rgba(255,255,255,.3); background: #fff; color: var(--ink); padding: .32rem .5rem; max-width: 220px; }

.layout { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 60px); }
.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 1rem .7rem; display: flex; flex-direction: column; gap: .15rem; }
.side-link { display: block; padding: .55rem .8rem; border-radius: 8px; color: var(--navy); font-weight: 600; font-size: .93rem; text-decoration: none; }
.side-link:hover { background: var(--tint); text-decoration: none; }
.side-link.is-active { background: var(--navy); color: #fff; }
.side-toggle { display: none; }
.content { padding: 1.4rem 1.5rem 3rem; max-width: 1080px; width: 100%; }
.loading-line { color: var(--muted); font-size: .9rem; margin-bottom: .8rem; }

/* ---------------- cards / stats ---------------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem 1.3rem; margin-bottom: 1.2rem; box-shadow: 0 1px 2px rgba(18,48,92,.05); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .9rem; }
.card-head h2 { margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem; margin-bottom: 1.2rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat b { display: block; font-size: 1.7rem; color: var(--navy); line-height: 1.15; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.is-warn b { color: var(--warn); }

/* ---------------- tables ---------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; padding: .5rem .6rem; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.data td { padding: .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:hover td { background: var(--tint); }
.tag { display: inline-block; border-radius: 999px; padding: .05rem .55rem; font-size: .76rem; font-weight: 700; }
.tag-ok { background: var(--ok-bg); color: var(--ok); }
.tag-warn { background: var(--warn-bg); color: var(--warn); }
.tag-err { background: var(--err-bg); color: var(--err); }
.tag-mute { background: var(--tint); color: var(--muted); }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--tint); display: block; }
.name-cell { display: flex; align-items: center; gap: .6rem; }
.empty { text-align: center; color: var(--muted); background: var(--tint); border: 1px dashed var(--line); border-radius: var(--radius); padding: 1.4rem; }

/* ---------------- filters / pager ---------------- */
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { margin: 0; flex: 1 1 170px; }
.filters .field.grow { flex: 2 1 240px; }
.pager { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: 1rem; }
.page-link { border: 1px solid var(--line); background: #fff; color: var(--navy); border-radius: 8px; padding: .3rem .7rem; font-size: .88rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.page-link:hover { background: var(--tint); }
.page-link.is-current { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------------- tabs ---------------- */
.tabs { display: flex; gap: .4rem; border-bottom: 2px solid var(--line); margin-bottom: 1.1rem; flex-wrap: wrap; }
.tab { background: none; border: 0; font: inherit; font-weight: 700; color: var(--muted); padding: .5rem .9rem; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tab.is-active { color: var(--blue); border-bottom-color: var(--blue); }

/* ---------------- gallery ---------------- */
.album-grid-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.album-a { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.album-a .cover { aspect-ratio: 4/3; background: var(--tint); display: flex; align-items: center; justify-content: center; font-size: 2rem; color: var(--muted); }
.album-a .cover img { width: 100%; height: 100%; object-fit: cover; }
.album-a .meta { padding: .8rem .9rem 1rem; }
.album-a h3 { font-size: 1rem; margin: 0 0 .2rem; }
.photo-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .7rem; }
.photo-box { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.photo-box img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.photo-box .pb-body { padding: .45rem .5rem .55rem; display: flex; flex-direction: column; gap: .35rem; }
.photo-box input { font: inherit; font-size: .82rem; border: 1px solid var(--line); border-radius: 6px; padding: .25rem .4rem; width: 100%; }

.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 1.1rem; text-align: center; background: var(--tint); margin-bottom: 1rem; }
.dropzone input[type=file] { max-width: 100%; }

/* ---------------- toasts ---------------- */
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; max-width: min(92vw, 380px); }
.toast { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 8px; padding: .7rem .9rem; box-shadow: 0 8px 24px rgba(18,48,92,.18); font-size: .92rem; animation: slide .18s ease; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- responsive ---------------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: .6rem; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side-toggle { display: inline-flex; margin-left: auto; }
  .sidebar .side-link { display: none; }
  .sidebar.is-open .side-link { display: block; width: 100%; }
  .content { padding: 1.1rem 1rem 2.5rem; }
  .row-2, .row-3 { grid-template-columns: 1fr; }
}
