/* ============================================================
   Worker Management System - Main Stylesheet
   ============================================================ */

:root {
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 64px;
  --topbar-height: 60px;
  --primary: #1a56db;
  --primary-dark: #1e40af;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --muted: #6b7280;
  --bg: #f3f4f6;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #1a56db;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

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

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: width .25s ease, transform .25s ease;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.brand-mark {
  width: 38px; height: 38px;
  background: var(--primary);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}

.brand-text { overflow: hidden; }
.brand-name { color: #fff; font-weight: 700; font-size: 14px; white-space: nowrap; }
.brand-role { color: var(--sidebar-text); font-size: 11px; white-space: nowrap; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  position: relative;
  white-space: nowrap;
  transition: background .15s, color .15s;
}

.sidebar-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-link.active { background: var(--primary); color: #fff; }
.sidebar-link i { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }

.nav-badge {
  position: absolute;
  right: 10px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.user-details { overflow: hidden; }
.user-name { color: #fff; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { color: var(--sidebar-text); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: rgba(239,68,68,.15);
  color: #fca5a5;
  border-radius: 7px;
  text-decoration: none;
  font-size: 12.5px;
  transition: background .15s;
  width: 100%;
}
.btn-logout:hover { background: rgba(239,68,68,.3); color: #fff; }

/* ---- SIDEBAR COLLAPSED ---- */
body.sidebar-collapsed .app-sidebar { width: var(--sidebar-collapsed-width); }
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .sidebar-link span,
body.sidebar-collapsed .user-details,
body.sidebar-collapsed .btn-logout span { display: none; }
body.sidebar-collapsed .sidebar-link { padding: 10px; justify-content: center; }
body.sidebar-collapsed .nav-badge { right: 2px; top: 2px; }
body.sidebar-collapsed .btn-logout { justify-content: center; }

/* ---- MAIN ---- */
.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .25s ease;
}

body.sidebar-collapsed .app-main { margin-left: var(--sidebar-collapsed-width); }

/* ---- TOPBAR ---- */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.topbar-title { flex: 1; }
.topbar-title h1 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.role-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.role-admin      { background: #dbeafe; color: #1e40af; }
.role-supervisor { background: #d1fae5; color: #065f46; }
.role-worker     { background: #fef3c7; color: #92400e; }

/* ---- PAGE CONTENT ---- */
.page-content { padding: 24px; flex: 1; }

/* ---- CARDS ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card .stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; margin: 4px 0; color: var(--text); }
.stat-card .stat-sub   { font-size: 12px; color: var(--text-muted); }
.stat-card .stat-icon  {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(26,86,219,.1);
  color: var(--primary);
  font-size: 20px;
}

/* ---- TABLE ---- */
.table th { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); background: #f9fafb; }
.table td { vertical-align: middle; font-size: 13.5px; }

/* ---- BADGES ---- */
.badge-present  { background: #d1fae5; color: #065f46; }
.badge-late     { background: #fef3c7; color: #92400e; }
.badge-absent   { background: #fee2e2; color: #991b1b; }
.badge-half     { background: #e0e7ff; color: #3730a3; }
.badge-leave    { background: #f3f4f6; color: #374151; }
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-progress { background: #dbeafe; color: #1e40af; }
.badge-submitted{ background: #e0e7ff; color: #4338ca; }
.badge-verified { background: #d1fae5; color: #065f46; }
.badge-partial  { background: #fef3c7; color: #92400e; }
.badge-issue    { background: #fee2e2; color: #991b1b; }
.badge-cancelled{ background: #f3f4f6; color: #6b7280; }
.badge-low      { background: #f0fdf4; color: #166534; }
.badge-medium   { background: #fefce8; color: #713f12; }
.badge-high     { background: #fff7ed; color: #9a3412; }
.badge-urgent   { background: #fef2f2; color: #7f1d1d; }
.badge-excellent{ background: #d1fae5; color: #065f46; }
.badge-good     { background: #dbeafe; color: #1e40af; }
.badge-average  { background: #fef3c7; color: #92400e; }
.badge-weak     { background: #fee2e2; color: #991b1b; }
.badge-poor     { background: #fce7f3; color: #831843; }

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}

/* ---- FORMS ---- */
.form-label { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.form-control, .form-select { font-size: 13.5px; border-color: var(--border); border-radius: 7px; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.1); }

/* ---- ALERTS ---- */
.alert { border-radius: var(--radius); font-size: 13.5px; }

/* ---- BUTTONS ---- */
.btn { border-radius: 7px; font-size: 13.5px; font-weight: 500; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ---- LOGIN PAGE ---- */
.login-page { background: linear-gradient(135deg, #1e293b 0%, #1a56db 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-panel { background: #fff; border-radius: 16px; overflow: hidden; width: 100%; max-width: 900px; box-shadow: 0 25px 60px rgba(0,0,0,.3); display: grid; grid-template-columns: 1fr 1fr; }
.login-hero { background: linear-gradient(160deg, #1e293b, #1a56db); padding: 48px 40px; display: flex; flex-direction: column; justify-content: space-between; }
.login-hero h1 { color: #fff; font-size: 22px; font-weight: 800; margin: 0 0 12px; }
.login-hero p { color: rgba(255,255,255,.7); font-size: 14px; }
.login-form-side { padding: 48px 40px; }

/* ---- KIOSK PAGE ---- */
.kiosk-page { background: #0f172a; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.kiosk-card { background: #1e293b; border-radius: 20px; padding: 48px; text-align: center; max-width: 420px; width: 100%; }
.kiosk-pin-display { background: #0f172a; border-radius: 12px; padding: 20px; font-size: 36px; font-weight: 800; color: #fff; letter-spacing: 12px; min-height: 80px; display: flex; align-items: center; justify-content: center; margin: 24px 0; border: 2px solid #334155; }
.kiosk-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0; }
.kiosk-key { background: #334155; border: none; color: #fff; font-size: 22px; font-weight: 700; padding: 18px; border-radius: 12px; cursor: pointer; transition: background .15s, transform .1s; }
.kiosk-key:hover { background: #475569; transform: scale(.97); }
.kiosk-key.zero { grid-column: 2; }
.kiosk-key.del { background: #7f1d1d; }
.kiosk-key.enter { background: var(--primary); grid-column: span 3; }

/* ---- PROGRESS BAR ---- */
.score-bar { height: 8px; border-radius: 4px; }

/* ---- MOBILE SIDEBAR ---- */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 999; }

@media (max-width: 768px) {
  .app-sidebar { transform: translateX(-100%); width: var(--sidebar-width) !important; }
  .app-sidebar.mobile-open { transform: translateX(0); }
  .app-main { margin-left: 0 !important; }
  body.sidebar-collapsed .sidebar-link span { display: inline !important; }
  body.sidebar-collapsed .brand-text { display: block !important; }
  .sidebar-backdrop.show { display: block; }
  .login-panel { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .page-content { padding: 16px; }
}

/* ---- QUILL editor ---- */
.ql-container { border-radius: 0 0 7px 7px !important; min-height: 180px; font-size: 14px; }
.ql-toolbar { border-radius: 7px 7px 0 0 !important; }

/* ---- Misc ---- */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state i { font-size: 40px; display: block; margin-bottom: 12px; }
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 18px; font-weight: 700; margin: 0 0 4px; }
.page-header p { font-size: 13px; color: var(--text-muted); margin: 0; }
.section-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
