/* LogWright admin portal styles (moved out of index.html in Phase 1a). */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f0f2f5;
  --sidebar-bg: #1a2236;
  --sidebar-text: #c8d0e0;
  --sidebar-active: #3b82f6;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); }

/* ---- Login ---- */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a2236 0%, #2d3f5e 100%);
}
.login-box {
  background: var(--card); border-radius: 12px; padding: 40px;
  width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-box h1 { font-size: 22px; margin-bottom: 6px; }
.login-box p { color: var(--muted); margin-bottom: 28px; font-size: 14px; }
.login-box .error { color: var(--danger); font-size: 13px; margin-bottom: 12px; display: none; }

/* ---- Layout ---- */
#app { display: none; min-height: 100vh; }
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 0; flex-shrink: 0;
}
.sidebar-header {
  padding: 24px 20px 20px; border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sidebar-header h2 { font-size: 16px; color: #fff; }
.sidebar-header span { font-size: 12px; color: var(--sidebar-text); opacity: 0.7; }

.nav { flex: 1; padding: 12px 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; cursor: pointer; font-size: 14px;
  border-left: 3px solid transparent; transition: all 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.06); }
.nav-item.active { background: rgba(59,130,246,0.15); border-left-color: var(--sidebar-active); color: #fff; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.07); }
.logout-btn {
  width: 100%; padding: 8px; background: rgba(255,255,255,0.07);
  border: none; color: var(--sidebar-text); border-radius: 6px;
  cursor: pointer; font-size: 13px; transition: background 0.15s;
}
.logout-btn:hover { background: rgba(255,255,255,0.13); }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 16px 28px; display: flex; align-items: center; justify-content: space-between;
}
.topbar h1 { font-size: 18px; font-weight: 600; }
.topbar .user-pill {
  background: var(--bg); border-radius: 20px; padding: 6px 14px;
  font-size: 13px; color: var(--muted);
}

.content { flex: 1; padding: 28px; overflow-y: auto; }

/* ---- Sections ---- */
.section { display: none; }
.section.active { display: block; }

/* ---- Cards ---- */
.card {
  background: var(--card); border-radius: 10px;
  border: 1px solid var(--border); padding: 24px; margin-bottom: 20px;
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 20px; text-align: center;
}
.stat-card .num { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-card.clickable { cursor: pointer; transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s; }
.stat-card.clickable:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,0.08); transform: translateY(-1px); }
.stat-card .go { font-size: 11px; color: var(--primary); margin-top: 6px; opacity: 0; transition: opacity 0.12s; }
.stat-card.clickable:hover .go { opacity: 1; }

/* ---- Forms ---- */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.form-group input, .form-group select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; background: #fff; outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--primary); }

/* ---- Buttons ---- */
.btn {
  padding: 9px 18px; border-radius: 6px; border: none; font-size: 14px;
  font-weight: 500; cursor: pointer; transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { text-align: left; padding: 10px 14px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); border-bottom: 1px solid var(--border); }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
/* Stronger divider above the app-store review (APPREVIEW) account only. */
#users-table tr.reviewer-row td { border-top: 2px solid #94a3b8; }
tbody tr:hover { background: #f8fafc; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-admin    { background: #ede9fe; color: #7c3aed; }
.badge-worker   { background: #dbeafe; color: #1d4ed8; }
.badge-reviewer { background: #fef3c7; color: #b45309; }
.badge-viewer   { background: #dcfce7; color: #15803d; }
/* Read-only (viewer) portal: hide every control that changes data. */
body.role-viewer .admin-only { display: none !important; }
/* Elements shown ONLY to viewers (e.g. the read-only badge). */
.viewer-only { display: none; }
body.role-viewer .viewer-only { display: inline-block; }
.badge-active   { background: #dcfce7; color: #15803d; }
.badge-inactive { background: #fee2e2; color: #b91c1c; }
.badge-rental   { background: #fef9c3; color: #a16207; }
.badge-none     { background: #f1f5f9; color: #64748b; }
.badge-overridden { background: #f1f5f9; color: #94a3b8; text-decoration: line-through; }
.badge-pending  { background: #fef9c3; color: #a16207; }
.badge-approved { background: #dcfce7; color: #15803d; }
.badge-rejected { background: #fee2e2; color: #b91c1c; }

/* Time Off */
.timeoff-filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.timeoff-filters .form-group { margin-bottom: 0; }
.stat-badge { display: inline-block; background: var(--warning); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: 6px; vertical-align: middle; }

/* ---- Filters ---- */
.filter-bar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar .form-group { margin-bottom: 0; }

/* ---- Payroll table extras ---- */
.total-row td { font-weight: 700; background: #f8fafc; }

/* ---- Utility ---- */
.msg { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; display: none; }
.msg-success { background: #dcfce7; color: #15803d; }
.msg-error   { background: #fee2e2; color: #b91c1c; }

.empty { text-align: center; padding: 40px; color: var(--muted); font-size: 14px; }

/* Payroll worker sections */
.worker-section { margin-bottom: 20px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.worker-section-header {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--sidebar-bg); color: #fff; padding: 12px 16px;
}
.worker-section-header .worker-name { font-size: 15px; font-weight: 700; }
.worker-section-header .worker-total { font-size: 13px; opacity: 0.85; }
.worker-section table { width: 100%; border-collapse: collapse; font-size: 14px; }
.worker-section td { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.worker-section tr:last-child td { border-bottom: none; }
.worker-section tr:hover td { background: #f8fafc; }

/* ---- Audit log ---- */
.nav-divider { height: 1px; background: rgba(255,255,255,0.07); margin: 8px 20px; }
.act { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.act-edit    { background: #dbeafe; color: #1d4ed8; }
.act-delete  { background: #fee2e2; color: #b91c1c; }
.act-approve { background: #dcfce7; color: #15803d; }
.act-create  { background: #ede9fe; color: #7c3aed; }
.act-deact   { background: #f1f5f9; color: #64748b; }
.audit-when-date { font-weight: 600; }
.audit-when-time { font-size: 12px; color: var(--muted); }
.audit-target { font-weight: 600; }
.audit-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.audit-change { font-variant-numeric: tabular-nums; }
.diff-old { color: #b91c1c; text-decoration: line-through; }
.diff-new { color: #15803d; font-weight: 600; }
.diff-arrow { color: var(--muted); padding: 0 5px; }
.audit-plain { color: var(--muted); }
.audit-sep { color: var(--border); padding: 0 2px; }
