/* Shared stylesheet for every page in this app — the config page
   (public/index.html) and the login page (rendered from src/auth.js).
   Page-specific base-element rules (body, h1, etc.) are scoped under
   .page-config / .page-login so the two pages don't clobber each other;
   everything else here is safe to share as-is. */

:root { color-scheme: light dark; }

/* ---------- Config page (.page-config) ---------- */

body.page-config {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  max-width: 720px;
  margin: 40px auto;
  padding: 0 20px;
  line-height: 1.5;
}
.page-config h1 { font-size: 1.3rem; margin: 0; }

.whoami-bar { display: flex; justify-content: space-between; align-items: center; }

h2 { font-size: 1.05rem; margin: 0; }
label { display: block; font-weight: 600; margin-top: 16px; margin-bottom: 6px; font-size: 0.9rem; }
select, textarea, input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.95rem;
  border-radius: 6px;
  border: 1px solid #8888;
  background: Field;
  color: FieldText;
  box-sizing: border-box;
}
textarea { min-height: 90px; font-family: ui-monospace, monospace; resize: vertical; }
.hint { font-size: 0.85rem; opacity: 0.7; margin-top: 4px; }
.error-text { color: #dc2626; }
.tokens { font-size: 0.85rem; opacity: 0.8; margin-top: 6px; }
.tokens code { background: #8882; padding: 1px 5px; border-radius: 4px; }

button {
  padding: 9px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}
button.primary { background: #2563eb; color: white; }
button.danger { background: transparent; color: #dc2626; border: 1px solid #dc262666; }
button:disabled { opacity: 0.5; cursor: default; }

.page-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 8px; }
.page-header h1 { margin: 0; }
#addTaskBtn { background: #2563eb; color: white; white-space: nowrap; flex-shrink: 0; }

/* Compact task tiles */
.task-tile {
  position: relative;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border: 1px solid #8885;
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 14px;
  cursor: pointer;
}
.task-tile:hover { background: #8881; }
.task-tile-main { min-width: 0; }
.task-tile-title { font-weight: 600; font-size: 0.95rem; }
.task-tile-sub { font-size: 0.85rem; opacity: 0.75; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rule-menu { position: relative; flex-shrink: 0; }
.rule-menu-btn {
  background: transparent; border: none; padding: 4px 8px;
  font-size: 1.2rem; line-height: 1; border-radius: 6px; color: inherit;
}
.rule-menu-btn:hover { background: #8882; }
.rule-menu-dropdown {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 30;
  background: Canvas; border: 1px solid #8886; border-radius: 8px;
  min-width: 140px; padding: 4px; box-shadow: 0 4px 16px #0004;
}
.rule-menu-dropdown[hidden] { display: none; }
/* The drawer's menu sits at the very bottom of the screen — opening
   downward would clip off-viewport, so open it upward instead. */
.drawer-footer .rule-menu-dropdown {
  top: auto; bottom: calc(100% + 4px);
}
.rule-menu-dropdown button {
  display: block; width: 100%; text-align: left; background: transparent;
  border: none; padding: 8px 10px; font-weight: 500; font-size: 0.88rem; color: #dc2626;
}
.rule-menu-dropdown button:hover { background: #dc26621a; }

/* Slide-in detail drawer */
.drawer-overlay {
  position: fixed; inset: 0; background: #0007;
  opacity: 0; visibility: hidden; transition: opacity 0.2s ease;
  z-index: 40;
}
.drawer-overlay.open { opacity: 1; visibility: visible; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh;
  width: min(460px, 92vw);
  background: Canvas; color: CanvasText;
  box-shadow: -8px 0 24px #0006;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 41;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 20px; border-bottom: 1px solid #8884; flex-shrink: 0;
}
.drawer-close {
  background: transparent; border: none; font-size: 1.4rem; line-height: 1;
  padding: 4px 8px; color: inherit;
}
.drawer-close:hover { background: #8882; border-radius: 6px; }
.drawer-body { padding: 4px 20px 20px; overflow-y: auto; flex: 1; }
.drawer-footer {
  display: flex; gap: 10px; align-items: center;
  padding: 16px 20px; border-top: 1px solid #8884; flex-shrink: 0;
}
.rule-status { font-size: 0.85rem; }
.rule-status.ok { color: #16a34a; }
.rule-status.err { color: #dc2626; }
details.sheet-advanced { margin-top: 14px; border: 1px solid #8884; border-radius: 8px; padding: 10px 14px; }
details.sheet-advanced summary { cursor: pointer; font-weight: 600; font-size: 0.88rem; }
details.sheet-advanced label { margin-top: 14px; }
.f-columns { min-height: 130px; }

/* Generic utility */
.hidden { display: none; }

/* ---------- Login page (.page-login) ---------- */

body.page-login {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; margin: 0; padding: 20px; box-sizing: border-box;
}
.page-login .card {
  max-width: 380px; width: 100%; text-align: center;
  border: 1px solid #8885; border-radius: 12px; padding: 36px 28px;
}
.page-login h1 { font-size: 1.2rem; margin: 0 0 8px; }
.page-login p.hint { opacity: 0.7; font-size: 0.9rem; margin: 0 0 24px; }
.page-login a.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 11px 20px; border-radius: 8px; border: 1px solid #8886;
  text-decoration: none; color: inherit; font-weight: 600; font-size: 0.95rem;
}
.page-login a.btn:hover { background: #8881; }
.page-login .error { color: #dc2626; font-size: 0.85rem; margin-top: 18px; }
