/* ============================================================
   iClock Mobile — mobile-first PWA styles (Corporate Light theme)
============================================================ */

:root {
  --bg:          #F5F7FB;
  --surface:     #FFFFFF;
  --surface-2:   #FAFBFE;
  --ink:         #0F172A;
  --ink-muted:   #475569;
  --ink-subtle:  #94A3B8;
  --border:      #E2E8F0;
  --border-soft: #EEF2F7;
  --navy:        #0F2D5C;
  --navy-strong: #0A2147;
  --accent:      #2563EB;
  --accent-soft: #EFF4FF;
  --success:     #059669;
  --success-soft:#D1FAE5;
  --warn:        #D97706;
  --warn-soft:   #FEF3C7;
  --danger:      #DC2626;
  --danger-soft: #FEE2E2;
  --shadow-sm:   0 1px 2px rgba(15,23,42,.06);
  --shadow-md:   0 8px 24px rgba(15,23,42,.08);
  --shadow-lg:   0 20px 50px rgba(15,23,42,.10);
  --radius:      16px;
  --radius-sm:   10px;
  --tabbar-h:    72px;
  --header-h:    56px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  font-size: 15px; line-height: 1.5;
  min-height: 100vh;
}

body {
  min-height: 100vh;
  min-height: 100dvh; /* dynamic viewport on iOS */
  padding-bottom: var(--tabbar-h);
}

a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ===== Top header ===== */
.hdr {
  background: var(--surface); border-bottom: 1px solid var(--border);
  height: var(--header-h);
  padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
  padding-top: env(safe-area-inset-top);
}
.hdr__title { font-weight: 700; font-size: 16px; color: var(--ink); letter-spacing: -0.01em; }
.hdr__title small { display:block; font-weight:400; font-size:11px; color:var(--ink-subtle); margin-top:1px; }
.hdr__btn {
  background: transparent; border: 0; padding: 8px 10px;
  color: var(--ink-muted); border-radius: 8px; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
}
.hdr__btn:active { background: var(--bg); }

/* ===== Page containers ===== */
.page { padding: 16px; max-width: 560px; margin: 0 auto; }
.stack > * + * { margin-top: 12px; }

/* ===== Card ===== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card--navy { background: linear-gradient(135deg, var(--navy) 0%, #1B3F80 60%, var(--accent) 120%); color: #FFF; border: 0; }
.card--navy h1, .card--navy h2, .card--navy h3 { color: #FFF; }
.card h3 { margin: 0 0 10px; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.card h3 small { font-weight: 400; color: var(--ink-subtle); font-size: 12px; margin-left: 6px; }

.muted { color: var(--ink-muted); font-size: 13px; }
.tiny  { font-size: 11.5px; color: var(--ink-subtle); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
}
.pill--in    { background: var(--success-soft); color: #065F46; }
.pill--out   { background: var(--accent-soft); color: var(--navy); }
.pill--leave { background: var(--warn-soft); color: #92400E; }
.pill--abs   { background: var(--danger-soft); color: #991B1B; }
.pill--paid  { background: var(--success-soft); color: #065F46; }
.pill--free  { background: var(--warn-soft); color: #92400E; }
.pill--pend  { background: var(--warn-soft); color: #92400E; }
.pill--ok    { background: var(--success-soft); color: #065F46; }
.pill--rej   { background: var(--danger-soft); color: #991B1B; }

/* ===== Form controls ===== */
label.lbl {
  display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin: 0 0 6px;
}
.req { color: var(--danger); margin-left: 2px; }

.field {
  width: 100%; background: #FFF; color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 15px; font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
select.field { appearance: none; background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748B' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
textarea.field { min-height: 90px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700; font-size: 15.5px;
  cursor: pointer; border: 1px solid transparent;
  transition: background .15s ease, transform .05s ease;
  min-height: 50px; /* touch target */
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--navy); color: #FFF; border-color: var(--navy); }
.btn--primary:hover { background: var(--navy-strong); }
.btn--success { background: var(--success); color: #FFF; border-color: var(--success); }
.btn--danger  { background: var(--danger); color: #FFF; border-color: var(--danger); }
.btn--ghost   { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--lg      { min-height: 64px; font-size: 17px; }
.btn--xl      {
  width: 100%; min-height: 180px;
  font-size: 22px; font-weight: 800; letter-spacing: -0.01em;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  flex-direction: column;
}
.btn--xl i.big { font-size: 54px; margin-bottom: 10px; opacity: .95; }
.btn--xl small { display: block; font-size: 12px; font-weight: 500; opacity: .85; margin-top: 4px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ===== List rows (attendance, leave, approvals) ===== */
.row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.row + .row { margin-top: 8px; }
.row__main { flex: 1; min-width: 0; }
.row__title { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.row__title small { display:block; font-weight: 400; color: var(--ink-subtle); font-size: 12px; margin-top: 2px; }
.row__side { text-align: right; margin-left: 10px; }
.row__side strong { display: block; font-size: 14px; font-weight: 700; color: var(--ink); }
.row__side small  { display: block; font-size: 11.5px; color: var(--ink-subtle); }

/* ===== Inline alerts ===== */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-size: 13.5px;
}
.alert i { margin-top: 2px; flex-shrink: 0; }
.alert--ok   { background: var(--success-soft); color: #065F46; border-color: #A7F3D0; }
.alert--err  { background: var(--danger-soft);  color: #991B1B; border-color: #FECACA; }
.alert--warn { background: var(--warn-soft);    color: #92400E; border-color: #FDE68A; }
.alert--info { background: var(--accent-soft);  color: var(--navy); border-color: #BFDBFE; }

/* ===== KPI tiles ===== */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
}
.kpi__label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-subtle); }
.kpi__value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; line-height: 1.1; }

/* ===== Bottom tab bar ===== */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; align-items: center;
  height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
  box-shadow: 0 -2px 10px rgba(15,23,42,0.04);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 0;
  color: var(--ink-subtle); font-size: 11px; font-weight: 500;
  text-decoration: none;
}
.tabbar a.active { color: var(--navy); }
.tabbar a i { font-size: 20px; }
.tabbar a.active i { color: var(--accent); }

/* ===== Login screen ===== */
.login {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 24px 20px calc(env(safe-area-inset-bottom) + 24px);
  max-width: 480px; margin: 0 auto;
  background: var(--bg);
}
.login__brand {
  text-align: center; margin-bottom: 28px;
}
.login__logo {
  width: 72px; height: 72px; border-radius: 18px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--accent) 100%);
  display: inline-flex; align-items: center; justify-content: center;
  color: #FFF; font-size: 32px;
  box-shadow: var(--shadow-md);
  margin-bottom: 12px;
}
.login__brand h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 4px; }
.login__brand p  { color: var(--ink-muted); font-size: 14px; margin: 0; }

/* ===== Camera overlay ===== */
.cam-overlay {
  position: fixed; inset: 0; background: #000; z-index: 100;
  display: flex; flex-direction: column;
}
.cam-overlay video { flex: 1; width: 100%; object-fit: cover; background: #000; }
.cam-overlay__hud {
  color: #FFF; padding: 16px; text-align: center; font-size: 14px;
  background: rgba(0,0,0,0.5);
}
.cam-overlay__hud strong { display: block; font-size: 16px; margin-bottom: 4px; }
.cam-overlay__actions {
  padding: 16px; display: flex; gap: 10px;
  background: rgba(0,0,0,0.85);
  padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
}
.cam-overlay__actions .btn--ghost { background: rgba(255,255,255,0.15); color: #FFF; border-color: rgba(255,255,255,0.2); }
.cam-overlay__actions .btn--ghost:hover { background: rgba(255,255,255,0.25); }

/* ===== Loading spinner ===== */
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,0.3); border-top-color: #FFF;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner--dark { border-color: rgba(15,23,42,0.2); border-top-color: var(--navy); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Misc ===== */
.clock-face {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-size: 32px; font-weight: 800; letter-spacing: -0.02em;
  color: #FFF;
}

.badge-today {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,0.14); color: #FFF;
  font-size: 11.5px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; margin-bottom: 8px;
}

.hide { display: none !important; }
.center { text-align: center; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.flex { display: flex; gap: 10px; }
.flex > * { flex: 1; }
