/* =============================================================
 * Likkan System — global stylesheet
 * Served at /styles.css (lives in public/, so it's NOT bundled or
 * hashed — open it directly in DevTools for live debugging).
 * ============================================================= */

/* -------- Reset (kills the 8px white frame around the page) ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
#root {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
               "Microsoft JhengHei", "PingFang TC",
               "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: #ffffff;
  color: #222;
}

/* -------- Dashboard layout ------------------------------------- */

/* The outer column that holds topbar + main content. */
.likkan-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

/* The blue topbar that runs edge-to-edge at the top. */
.likkan-topbar {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: #1d4e89;
  color: #ffffff;
  flex: 0 0 auto;
}
.likkan-topbar-left {
  display: flex;
  flex-direction: row;
  align-items: center;
}
.likkan-topbar-title {
  margin-left: 12px;
  font-weight: 500;
}

/* Main content area below the topbar. */
.likkan-main {
  flex: 1 1 auto;
  width: 100%;
  padding: 1rem 1.5rem;
  background: #f7f9fc;
}

/* -------- Login page ------------------------------------------- */
.likkan-login {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  width: 100%;
  margin: 0;
  padding: 1rem;
  background: url("/images/login-background.jpg") center / cover no-repeat;
}
.likkan-login-card {
  width: 32rem;
  max-width: 100%;
}
.likkan-login-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
  width: 100%;
}

/* -------- Page chrome (announcements, headings, cards) --------- */
.likkan-greeting {
  margin-bottom: 1rem;
}
.likkan-panel-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 768px) {
  .likkan-panel-grid { grid-template-columns: 1fr 1fr; }
}

/* -------- Page Toolbar (see DIRECTIONS.md §0) ----------------- */
/* All `.likkan-toolbar` instances must have transparent background
 * so the page-level `.likkan-main` (#f7f9fc) shows through.
 * Text inside the toolbar is bold; any PrimeReact buttons sit at
 * `.p-button-sm` size by default (no need to pass size="small"). */
.likkan-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  background: transparent;
  border: 0;
  font-weight: bold;
}
.likkan-toolbar .p-button {
  /* Visually equivalent to PrimeReact Button's size="small". */
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
}
/* (按鈕之間的 gap-2 透過 PrimeReact `pt.start` / `pt.end`
 * 直接給容器加 class，規則寫在每個 Toolbar 實例裡。) */
.likkan-toolbar-filters {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* -------- MessageBox dialog ------------------------------------ */
.likkan-messagebox {
  width: 32rem;
  max-width: 100%;
}
.likkan-messagebox-body {
  padding: 0.5rem 0.25rem;
}
.likkan-messagebox-footer {
  text-align: right;
  margin-top: 12px;
}
.likkan-messagebox-button {
  background: #6b7280;
  color: #ffffff;
  border: none;
  padding: 6px 18px;
  border-radius: 4px;
  cursor: pointer;
}
.likkan-messagebox-button:hover {
  filter: brightness(0.92);
}

/* Severity tints applied via .severity-<name> on the wrapper. */
.likkan-messagebox.severity-warning .likkan-messagebox-button { background: #f59e0b; }
.likkan-messagebox.severity-danger  .likkan-messagebox-button { background: #ef4444; }
.likkan-messagebox.severity-info    .likkan-messagebox-button { background: #3b82f6; }
.likkan-messagebox.severity-success .likkan-messagebox-button { background: #10b981; }

/* -------- Form helpers ----------------------------------------- */
.likkan-row-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.likkan-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  align-items: start;
}
@media (min-width: 768px) {
  .likkan-form-grid-2 { grid-template-columns: 1fr 1fr; }
  .likkan-form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
  .likkan-form-grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
}

.likkan-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.likkan-field label {
  font-weight: 500;
}
.likkan-field input,
.likkan-field textarea {
  width: 100%;
}

/* -------- Sidebar (mobile menu) ------------------------------- */
.likkan-sidebar {
  /* PrimeReact already positions the Sidebar; override its width here. */
  width: 16rem;
}
.likkan-sidebar nav.p-menu {
  border: 0;
  width: 100%;
}

/* -------- ItemNumberInput ------------------------------------- */
.likkan-stepper {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.likkan-stepper-btn {
  width: 28px;
  height: 28px;
  padding: 0;
}
.likkan-stepper-input {
  width: 70px;
  text-align: center;
}

/* -------- Moving-items grid (Orderform) ----------------------- */
.likkan-moving-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  border-bottom: 1px solid #e5e7eb;
}

/* -------- Signature pad (Orderform) --------------------------- */
.likkan-signature-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.likkan-signature-frame {
  border: 1px dashed #888;
  background: #ffffff;
  border-radius: 4px;
  padding: 8px;
}

/* -------- DataTable action column ----------------------------- */
.likkan-row-actions-inline {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* -------- Utility --------------------------------------------- */
.likkan-hidden { display: none; }
.likkan-fullbleed {
  min-height: 100vh;
  width: 100%;
  margin: 0;
}

/* -------- Data Detail Modal ----------------------------------- */
/* Spec is defined in DIRECTIONS.md §0 (詞彙表).
 * Width = 100% of the dialog mask with 20px breathing room on both
 * sides. Capped at 1000px for ultra-wide viewports. */
.p-dialog.likkan-detail-modal {
  width: calc(100% - 40px);
  max-width: 1000px;
}

/* -------- DataTable defaults (see DIRECTIONS.md §0) ----------- */
/* 套用規則：用在系統內所有 PrimeReact <DataTable>。
 *   1. 表頭白底（蓋掉 PrimeReact 內建淺灰）
 *   2. wrapper 加陰影 + 圓角
 *   3. 點選行為在 React 端用 onSelectionChange 過濾 null 處理
 *      （這個 CSS 只負責視覺，行為要配合元件） */
.p-datatable .p-datatable-thead > tr > th {
  background: #ffffff;
}
.p-datatable > .p-datatable-wrapper {
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}
