/* =============================================================
   Apex Workforce — Web Stylesheet
   Mobile-first, soft modern palette. Base adapted from the
   mobile-demo prototype, extended for the full-parity features
   (floor accordions, toggles, salary slip, segmented controls).
============================================================= */

:root {
  --bg:        #f4f6fb;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --border:    #e4e8f0;
  --text:      #1f2937;
  --muted:     #6b7280;

  --primary:   #4f63d2;
  --primary-d: #3b4cae;
  --primary-l: #eef0fb;

  --green:     #16a34a;
  --green-l:   #e7f7ed;
  --red:       #dc2626;
  --red-l:     #fdecec;
  --amber:     #d97706;
  --amber-l:   #fdf3e3;
  --blue:      #2563eb;

  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 1px 3px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.05);
  --shadow-lg: 0 10px 40px rgba(16,24,40,.18);

  --c-worker:    #2563eb;  --c-worker-l:  #e7effe;
  --c-super:     #7c3aed;  --c-super-l:   #f0e9fd;
  --c-designer:  #db2777;  --c-designer-l:#fce7f1;
  --c-other:     #0d9488;  --c-other-l:   #ddf3f0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}

.hidden { display: none !important; }
.muted  { color: var(--muted); }
.small  { font-size: 12.5px; }
.center { text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: var(--radius-sm);
  padding: 11px 16px; font-size: 14.5px; font-weight: 600; cursor: pointer;
  transition: background .15s, transform .05s, box-shadow .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--red-l); color: var(--red); }
.btn-danger:hover { background: #f9dada; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

.icon-btn {
  background: transparent; border: none; cursor: pointer;
  font-size: 20px; color: var(--text); line-height: 1; padding: 6px 8px; border-radius: 8px;
}
.icon-btn:hover { background: var(--surface-2); }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 15px; background: var(--surface);
  color: var(--text); font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-l);
}
textarea { resize: vertical; min-height: 70px; }

/* ---------- Splash ---------- */
.splash {
  min-height: 100vh; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4f63d2 0%, #6d4fd2 100%);
}
.splash .login-logo { margin: 0; }
.splash .muted { color: #e6e9f8; }

/* =============================================================
   LOGIN
============================================================= */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: linear-gradient(135deg, #4f63d2 0%, #6d4fd2 100%);
}
.login-card {
  background: var(--surface); width: 100%; max-width: 380px;
  border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 18px; }
.login-logo {
  width: 56px; height: 56px; background: var(--primary); color: #fff;
  border-radius: 16px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 22px; margin: 0 auto 12px; letter-spacing: 1px;
}
.login-logo.small { width: 38px; height: 38px; font-size: 15px; border-radius: 11px; margin: 0; }
.login-brand h1 { font-size: 21px; }
.login-error { color: var(--red); font-size: 13px; margin-top: 10px; }
.login-hint { margin-top: 16px; text-align: center; font-size: 12px; }

/* =============================================================
   APP SHELL
============================================================= */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 18px;
  border-bottom: 1px solid var(--border); margin-bottom: 12px;
}
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 11px 12px;
  border-radius: var(--radius-sm); color: var(--text); font-weight: 600;
  font-size: 14px; cursor: pointer; text-decoration: none;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--primary-l); color: var(--primary-d); }
.nav-ico { font-size: 17px; width: 22px; text-align: center; }

.content { flex: 1; margin-left: 240px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 14px 20px;
  display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30;
}
.topbar h2 { font-size: 18px; flex: 1; }
#menu-toggle { display: none; }
#settings-btn { display: none; }
.view-container { padding: 20px; max-width: 1100px; width: 100%; }

.bottom-nav { display: none; }
.backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 45; }

/* =============================================================
   CARDS & SECTIONS
============================================================= */
.section-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.section-head h3 { font-size: 16px; }
.section-head .spacer { flex: 1; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }

.cards-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.stat-card .stat-ico {
  width: 40px; height: 40px; border-radius: 11px; display: flex;
  align-items: center; justify-content: center; font-size: 19px; margin-bottom: 10px;
}
.stat-card .stat-val { font-size: 26px; font-weight: 800; }
.stat-card .stat-label { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ico-blue  { background: #e7effe; }
.ico-green { background: var(--green-l); }
.ico-amber { background: var(--amber-l); }
.ico-purple{ background: var(--c-super-l); }

/* Org banner on dashboard */
.org-banner {
  display: flex; align-items: center; gap: 14px; margin-bottom: 20px;
  padding: 18px; border-radius: var(--radius); color: #fff;
  background: linear-gradient(135deg, #4f63d2 0%, #6d4fd2 100%); box-shadow: var(--shadow);
}
.org-banner .avatar { background: rgba(255,255,255,.22); }
.org-banner .ob-name { font-size: 18px; font-weight: 800; }
.org-banner .ob-sub { font-size: 13px; opacity: .9; margin-top: 2px; }

/* =============================================================
   SEARCH / FILTERS
============================================================= */
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-wrap .search-ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 16px; }
.search-input { padding-left: 38px; height: 46px; font-size: 15px; border-radius: 12px; background: var(--surface); }
.search-big { box-shadow: var(--shadow); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  padding: 8px 14px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--border); font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted);
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Group-by-floor toggle row */
.toggle-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 13.5px; color: var(--muted); }

/* =============================================================
   BADGES
============================================================= */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .2px; }
.badge-worker     { background: var(--c-worker-l);   color: var(--c-worker); }
.badge-supervisor { background: var(--c-super-l);     color: var(--c-super); }
.badge-designer   { background: var(--c-designer-l);  color: var(--c-designer); }
.badge-other      { background: var(--c-other-l);     color: var(--c-other); }
.badge-active     { background: var(--green-l); color: var(--green); }
.badge-inactive   { background: #eef0f3; color: var(--muted); }
.badge-floor      { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge-star       { background: #fff6e0; color: #b8860b; }

/* =============================================================
   ROWS
============================================================= */
.row-list { display: flex; flex-direction: column; gap: 10px; }
.emp-row {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 15px; display: flex; align-items: center; gap: 13px; box-shadow: var(--shadow);
}
.emp-row.clickable { cursor: pointer; }
.emp-row.clickable:hover { border-color: var(--primary); }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 15px; color: #fff; flex-shrink: 0;
}
.emp-main { flex: 1; min-width: 0; }
.emp-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.emp-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.emp-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Attendance controls */
.att-options { display: flex; gap: 6px; flex-wrap: wrap; }
.att-opt {
  border: 1px solid var(--border); background: var(--surface); border-radius: 9px;
  padding: 7px 11px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted);
}
.att-opt.sel { background: var(--primary); color: #fff; border-color: var(--primary); }
.att-opt.sel-absent { background: var(--red); color: #fff; border-color: var(--red); }
.att-opt.sel-present{ background: var(--green); color: #fff; border-color: var(--green); }
.att-row .emp-actions { flex-direction: column; align-items: flex-end; }
.hours-input { width: 90px; }

/* Floor accordion */
.floor-group { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow); }
.floor-head {
  display: flex; align-items: center; gap: 10px; padding: 13px 15px; cursor: pointer;
  background: var(--surface-2); font-weight: 700; font-size: 14px;
}
.floor-head .spacer { flex: 1; }
.floor-head .count { color: var(--muted); font-weight: 600; font-size: 13px; }
.floor-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.floor-body .search-input { height: 40px; }
.floor-group.collapsed .floor-body { display: none; }
.chevron { transition: transform .15s; }
.floor-group.collapsed .chevron { transform: rotate(-90deg); }

/* =============================================================
   TABLE (salary)
============================================================= */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: 11px 13px; text-align: left; font-size: 13.5px; white-space: nowrap; }
th { background: var(--surface-2); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
tbody tr { border-top: 1px solid var(--border); }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; }
.net-pos { color: var(--green); font-weight: 700; }
.net-neg { color: var(--red); font-weight: 700; }
.bonus-pos { color: var(--green); font-weight: 600; }
tfoot td { background: var(--surface-2); font-weight: 700; border-top: 2px solid var(--border); }

/* =============================================================
   EMPTY STATES
============================================================= */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .empty-ico { font-size: 44px; margin-bottom: 10px; }
.empty h4 { color: var(--text); margin-bottom: 6px; }

/* =============================================================
   MODAL
============================================================= */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-card { background: var(--surface); border-radius: 18px; width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 20px; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }
.form-actions .btn { flex: 1; }

/* =============================================================
   TOAST
============================================================= */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 13px 22px; border-radius: 12px;
  font-weight: 600; font-size: 14px; z-index: 200; box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease; max-width: 90vw; text-align: center;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; } }

/* Sticky save bar */
.sticky-save {
  position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border);
  padding: 12px 16px; margin: 18px -20px -20px; display: flex; gap: 10px; align-items: center;
  box-shadow: 0 -4px 16px rgba(16,24,40,.06);
}
.sticky-save .save-info { flex: 1; font-size: 13px; color: var(--muted); }
.btn.dirty { background: var(--amber); }
.btn.dirty:hover { background: #b96405; }

/* Toolbar */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.toolbar .field { display: flex; flex-direction: column; }
.toolbar .field label { margin-top: 0; }
.toolbar input, .toolbar select { min-width: 150px; }

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

/* =============================================================
   SETTINGS — toggle switch + segmented + setting rows
============================================================= */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; cursor: pointer; inset: 0; background: #cbd2e0; border-radius: 999px; transition: .2s; }
.switch .slider::before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.setting-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); }
.setting-row:first-of-type { border-top: none; }
.setting-row .sr-main { flex: 1; min-width: 0; }
.setting-row .sr-title { font-weight: 600; font-size: 14.5px; }
.setting-row .sr-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper .step-val { font-weight: 800; font-size: 18px; min-width: 28px; text-align: center; }
.stepper .btn { width: 38px; height: 38px; padding: 0; font-size: 20px; }

/* Segmented (status) control */
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button { border: none; background: var(--surface); padding: 9px 16px; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.segmented button.on-active { background: var(--green); color: #fff; }
.segmented button.on-inactive { background: #eef0f3; color: var(--text); }

/* Mode chips (cash/bank) */
.mode-chips { display: flex; gap: 10px; }
.mode-chips .chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Salary slip */
.slip-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.slip-summary .si { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; }
.slip-summary .si .lbl { font-size: 12px; color: var(--muted); }
.slip-summary .si .val { font-size: 18px; font-weight: 800; margin-top: 3px; }
.day-row { display: flex; align-items: flex-start; gap: 12px; padding: 9px 12px; border-top: 1px solid var(--border); font-size: 13.5px; }
.day-row:first-child { border-top: none; }
.day-row .d-date { flex: 1; white-space: nowrap; }
.day-row .d-detail { text-align: right; }
.audit { font-size: 12px; color: var(--muted); margin-top: 4px; }
.back-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }

/* CSV import drop area */
.csv-box { border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 18px; text-align: center; }

/* =============================================================
   RESPONSIVE
============================================================= */
@media (max-width: 1000px) { .cards-grid { grid-template-columns: repeat(2, 1fr); } }

@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  .app.drawer-open .sidebar { transform: translateX(0); }
  .content { margin-left: 0; }
  #menu-toggle { display: inline-block; }
  #settings-btn { display: inline-block; }
  .view-container { padding: 16px 14px 90px; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface);
    border-top: 1px solid var(--border); z-index: 40; padding: 6px 4px; justify-content: space-around;
  }
  .bn-item { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 600; color: var(--muted); text-decoration: none; padding: 4px 6px; flex: 1; }
  .bn-item span { font-size: 19px; }
  .bn-item.active { color: var(--primary); }
  .grid-2 { grid-template-columns: 1fr; }
  .slip-summary { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 420px) {
  .cards-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card .stat-val { font-size: 22px; }
  .emp-row { flex-wrap: wrap; }
}

/* ---- Register link + trial/subscription banner --------------------------- */
.login-hint a { color: var(--primary); font-weight: 600; text-decoration: none; }
.login-hint a:hover { text-decoration: underline; }

.trial-banner {
  padding: 10px 16px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  border-bottom: 1px solid rgba(0, 0, 0, .06);
}
.trial-banner.hidden { display: none; }
.trial-banner.info   { background: var(--primary-l); color: var(--primary-d); }
.trial-banner.warn   { background: var(--amber-l);   color: var(--amber); }
.trial-banner.danger { background: var(--red-l);     color: var(--red); }
