@import url("style.css");

/* style.css sets html,body{height:100%} and body{overflow:hidden} for the
   main app, which is a fixed-viewport shell where inner panels scroll
   instead of the page. These are plain content pages (especially admin.php
   with long tables), so that combination silently blocked all page
   scrolling — override both back to normal document flow. */
html { height: auto; }
body {
  height: auto; min-height: 100vh; overflow-y: auto; overflow-x: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 20px 0; box-sizing: border-box;
}

.authWrap { width: 100%; max-width: 380px; padding: 0 16px; box-sizing: border-box; }
.authCard { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.authCard h1 { margin: 0 0 6px; font-size: 1.3rem; color: var(--text); }
.authCard .muted { color: var(--text-dim); margin: 0 0 16px; font-size: 0.85rem; }
.authCard .muted.small { margin-top: 16px; margin-bottom: 0; }
.authCard form { display: flex; flex-direction: column; gap: 14px; }
.authCard label { display: flex; flex-direction: column; gap: 5px; font-size: 0.82rem; color: var(--text-dim); }

/* 16px min font-size on inputs stops iOS Safari from auto-zooming the page
   on focus; 12px vertical padding keeps the tappable area comfortably
   above the ~44px touch-target guideline. */
.authCard input, .adminWrap input, .adminWrap select {
  padding: 12px 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg-elev-2); color: var(--text); font-family: var(--sans);
  font-size: 16px; width: 100%; box-sizing: border-box;
}
.authCard input:focus, .adminWrap input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.authCard .btn { margin-top: 4px; }
.authError { background: rgba(224,101,79,0.12); border: 1px solid var(--bad); color: var(--bad); padding: 10px 12px; border-radius: 6px; font-size: 0.85rem; margin-bottom: 14px; word-break: break-word; }
.authCard a { color: var(--accent); }

/* Comfortable tap targets everywhere in these PHP-rendered pages, not just
   in the main app (which already sizes .btn generously). */
.authCard .btn, .adminWrap .btn { min-height: 44px; padding: 10px 16px; font-size: 0.95rem; }

.adminWrap { max-width: 900px; margin: 0 auto; padding: 20px 16px 40px; box-sizing: border-box; }
.adminWrap h1 { color: var(--text); font-size: 1.3rem; }
.adminWrap h2 { font-size: 1rem; }
.adminWrap > p.muted { word-break: break-word; }
.adminWrap table { width: 100%; border-collapse: collapse; margin-bottom: 0; font-size: 0.85rem; }
.adminWrap th, .adminWrap td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--text); }
.adminWrap th { color: var(--text-dim); font-weight: 600; }
.adminWrap .card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 20px; }
.adminWrap .keyNew { font-family: var(--mono); background: var(--bg-elev-2); padding: 2px 6px; border-radius: 4px; word-break: break-all; }
.badge-ok { color: var(--ok); }
.badge-bad { color: var(--bad); }
.badge-warn { color: var(--warn); }

.tableScroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.keygenForm { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.keygenForm label { display: flex; flex-direction: column; gap: 5px; font-size: 0.82rem; color: var(--text-dim); flex: 1 1 160px; }
.keygenForm input { min-width: 0; }
.keygenForm .btn { flex: 0 0 auto; }

.actionCell form + form { margin-left: 8px; }

/* Below this width, tables become stacked cards instead of scrolling
   sideways — one record per card, with the column name shown inline via
   the data-label attribute already present on every <td>. */
@media (max-width: 700px) {
  .tableScroll table, .tableScroll thead, .tableScroll tbody, .tableScroll th, .tableScroll td, .tableScroll tr {
    display: block;
  }
  .tableScroll thead tr { position: absolute; left: -9999px; top: -9999px; }
  .tableScroll tbody tr {
    border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: var(--bg-elev-2);
  }
  .tableScroll tbody td {
    border-bottom: none; padding: 6px 0 6px 42%; position: relative; min-height: 20px;
  }
  .tableScroll tbody td::before {
    content: attr(data-label); position: absolute; left: 0; top: 6px; width: 38%;
    font-weight: 600; color: var(--text-dim); font-size: 0.78rem;
  }
  .tableScroll tbody td.actionCell, .tableScroll tbody td[data-label="Action"] {
    padding-left: 0;
  }
  .tableScroll tbody td.actionCell::before, .tableScroll tbody td[data-label="Action"]::before {
    content: none;
  }
  .actionCell form, .tableScroll tbody td[data-label="Action"] form { display: block !important; margin: 6px 0 0 !important; }
  .actionCell form .btn, .tableScroll tbody td[data-label="Action"] form .btn { width: 100%; }
}

@media (max-width: 420px) {
  .authCard { padding: 20px; }
  .adminWrap .card { padding: 14px; }
}
