/* =======================================================
  NAME:     style.css
  VERSION:  v1.4.4
  UPDATED:  2025-11-02 14:28 by L. Mira
  DESCRIPTION:
    Responsive styles for KSP Member.
    Mobile fixes for Leave/Issue forms (dialog.modal scope):
    - Half-day row inline (label + checkbox)
    - Period radios inline (in same row block)
    - Upload spacing + preview grid
    - Non-sticky actions; hide Cancel (use modal X)
======================================================= */

:root {
  --bg: #f7f3ef;
  --paper: #fff;
  --ink: #3a2f27;
  --muted: #8b7e74;
  --line: #e7dfd8;
  --chip: #efe7df;
  --accent: #6b4a33;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(128, 98, 72, .15);
  --tabbar-h: 72px;
}

* {
  box-sizing: border-box
}

html,
body {
  height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  /* Prevent horizontal scroll */
}

body {
  margin: 0;
  font: 16px/1.6 'Noto Sans Thai', system-ui, -apple-system, Segoe UI, Roboto, 'Helvetica Neue', sans-serif;
  color: var(--ink);
  background: var(--bg);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
}

.page {
  display: none
}

.page.active {
  display: block
}

#content {
  min-height: calc(100vh - var(--tabbar-h) - 48px)
}

.topbar {
  position: relative;
  top: 0;
  z-index: 5;
  background: transparent
}

/* Keep topbar sticky on mobile */
@media (max-width: 980px) {
  .topbar {
    position: sticky
  }
}

/* Desktop tabs (moved to styles/navigation.css) */

main {
  padding: 16px
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px
}

.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px
}

.card h3 {
  margin: 0 0 10px 0
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px
}

.muted {
  color: var(--muted)
}

.list {
  list-style: none;
  padding: 0;
  margin: 0
}

.list li {
  padding: 10px 0;
  border-top: 1px solid var(--line)
}

.list li:first-child {
  border-top: none
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line)
}

.badge {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 50%
}

.badge.ok {
  background: #eaf7ea;
  border-color: #a9d9a9
}

/* Utilities */
.stack-16>*+* {
  margin-top: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.gap-12 {
  gap: 12px;
}

/* Force 16px gap between leave-form & activity, including mobile */
.layout-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.requests-two-col {
  gap: 16px;
}

/* Search */
.search.card {
  padding: 10px 16px;
  margin-bottom: 12px
}

.search input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fbf9f7
}

/* TASKS layout */
.tasks-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 16px
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0
}

.history-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  border-radius: 10px
}

.history-list li:first-child {
  border-top: none
}

.history-list li.active {
  background: #eee2d7
}

.history-list .date {
  font-weight: 600
}

.progress-pill {
  background: #efe7df;
  color: #6b4a33;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 12px;
  min-width: 38px;
  text-align: center;
  font-weight: 600
}

/* Report link */
.report-link {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none
}

.report-link:hover {
  text-decoration: underline
}

.report-link.disabled {
  opacity: .6;
  pointer-events: none;
  cursor: default;
  text-decoration: none
}

.pager {
  display: flex;
  align-items: center;
  gap: 12px
}

.chev {
  font-weight: 600;
  color: #b08b68
}

.pager,
.pager * {
  user-select: none;
}

.pager .chev,
.pager .muted {
  cursor: pointer;
}

.pager .chev.disabled {
  opacity: .45;
  cursor: default;
}

.pager .muted.disabled {
  opacity: .45;
  cursor: default;
}

/* Checklist */
.checklist {
  list-style: none;
  margin: 0;
  padding: 0
}

.checklist li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-top: 1px solid var(--line)
}

.checklist li:first-child {
  border-top: none
}

.iconbox {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center
}

.iconbox svg {
  width: 18px;
  height: 18px
}

.icon-muted line {
  stroke: #d9d1c9;
  stroke-width: 2;
  border-radius: 2px
}

.icon-ok path {
  stroke: #2e7d32;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round
}

/* Overview docs */
.card.docs-overview {
  padding: 12px
}

.docs-list {
  max-height: 312px;
  overflow-y: auto;
  padding: 0;
  margin: 0;
  list-style: none;
}

.docs-list li {
  padding: 10px 12px;
  border-top: 1px solid var(--line)
}

.docs-list li:first-child {
  border-top: none
}

.docs-list::-webkit-scrollbar {
  width: 8px
}

.docs-list::-webkit-scrollbar-thumb {
  background: var(--chip);
  border-radius: 8px
}

/* Profile (moved to styles/profile.css) */
/* see styles/profile.css for avatar, profile-summary and mobile-profile-bar */

/* Forms (moved to styles/forms.css) */
/* includes .form labels/inputs, .card.form layout and request card buttons */
/* Primary buttons */
.primary {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600
}

.primary:hover {
  filter: brightness(.95)
}

.primary:active {
  transform: translateY(1px)
}

.modal .primary,
.report-modal .primary {
  background: var(--accent);
  color: #fff
}

/* Clean buttons */
.actions {
  display: flex;
  gap: 12px;
  margin-top: 8px
}

.clean-btn {
  background: none;
  border: none;
  padding: 0;
  color: #fff;
  cursor: pointer;
  font: inherit
}

.clean-btn:hover {
  color: var(--accent);
  text-decoration: underline
}

/* Mobile Tabbar (moved to styles/navigation.css) */

/* Responsive */
@media (max-width: 980px) {
  .grid {
    grid-template-columns: 1fr
  }

  .layout-2 {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .tasks-grid {
    grid-template-columns: 1fr
  }

  .grid-2 {
    grid-template-columns: 1fr
  }
}

/* Small-screen extra space on profile page */
@media (max-width: 640px) {
  #page-profile {
    padding-bottom: 70px;
  }
}

/* Dialogs, report modal, spinner and A4 iframe (moved to styles/modal.css) */
/* see styles/modal.css for picker/.modal/.report-modal, backdrop, spinner/loader and A4 iframe rules */
/* Form modal shared styles and attachment helpers moved to styles/forms.css */

/* Report modal misc */
.report-modal {
  transition: opacity .28s ease, transform .28s ease
}

.report-modal.closing {
  opacity: 0;
  transform: translateY(-8px) scale(.99)
}

.report-modal[aria-busy="true"] {
  pointer-events: none;
  opacity: .95
}

/* Utilities (moved to styles/utilities.css) */
/* see styles/utilities.css for small helper classes (spacing, display, helpers) */
/* Install panel */
.install-panel {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60
}

.install-panel[hidden] {
  display: none !important
}

/* When install-mode is active we want to show the install panel even if the
  element starts with the `hidden` attribute. This ensures ?install=1 can
  immediately reveal the panel without requiring beforeinstallprompt. */
.install-mode #install-panel[hidden] {
  display: grid !important
}

.install-panel-inner {
  width: min(580px, 94vw);
  background: var(--paper);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px;
  position: relative
}

.install-panel .install-close {
  position: absolute;
  right: 12px;
  top: 10px;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer
}

.install-panel .install-content {
  text-align: center;
  padding: 6px 12px
}

.install-panel .install-content h3 {
  margin: 0 0 8px 0
}

.install-panel .install-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px
}

.install-panel .btn {
  min-width: 120px
}

/* Login (moved to styles/login.css) */
/* see styles/login.css for .login-screen, .login-card and login button rules */

/* Mobile-only patches moved to styles/mobile.css */
/* see styles/mobile.css for phone-specific form and attach-preview rules */