/* ============ EMS Premium Theme ============ */
:root {
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --bg: #f3f4f8;
  --surface: #ffffff;
  --text: #1e2233;
  --text-muted: #6b7280;
  --border: #e5e7ef;
  --sidebar-bg: #111527;
  --sidebar-text: #9aa2b8;
  --sidebar-active: rgba(124, 58, 237, .18);
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 8px 24px rgba(16, 24, 40, .05);
  --radius: 14px;
}
[data-theme="dark"] {
  --bg: #0d1020;
  --surface: #161a2e;
  --text: #e6e8f2;
  --text-muted: #8f96ad;
  --border: #262b45;
  --sidebar-bg: #0a0d1c;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  transition: background .25s, color .25s;
}

/* ---------- Layout ---------- */
.app-wrapper { display: flex; min-height: 100vh; }
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content { padding: 24px; flex: 1; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 250px; flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 1040;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px; padding: 22px 20px; color: #fff;
  font-weight: 700; font-size: 1.05rem; letter-spacing: .3px;
}
.sidebar-brand i { font-size: 1.4rem; background: var(--brand-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.sidebar-nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.sidebar .nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 14px; margin-bottom: 4px; border-radius: 10px;
  color: var(--sidebar-text); text-decoration: none; font-size: .93rem;
  border: 0; background: transparent; cursor: pointer; transition: all .18s;
}
.sidebar .nav-item:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.sidebar .nav-item.active { color: #fff; background: var(--sidebar-active); box-shadow: inset 3px 0 0 var(--brand-2); }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .07); }
.sidebar-overlay { display: none; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 14px 24px; position: sticky; top: 0; z-index: 1030;
}
.page-title { font-size: 1.15rem; font-weight: 700; margin: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  width: 38px; height: 38px; border-radius: 10px; font-size: 1.05rem;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: all .18s;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.user-chip {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text);
  font-weight: 600; font-size: .9rem; padding: 5px 12px 5px 5px;
  border: 1px solid var(--border); border-radius: 999px; transition: border-color .18s;
}
.user-chip:hover { border-color: var(--brand); color: var(--brand); }
.user-chip img, .avatar-fallback { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.avatar-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-grad); color: #fff; font-size: .75rem; font-weight: 700;
}

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); font-weight: 700; }

.stat-card { display: flex; align-items: center; gap: 16px; padding: 20px; }
.stat-icon {
  width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; color: #fff;
}
.stat-value { font-size: 1.55rem; font-weight: 800; line-height: 1.1; }
.stat-label { color: var(--text-muted); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.bg-grad-1 { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.bg-grad-2 { background: linear-gradient(135deg, #059669, #10b981); }
.bg-grad-3 { background: linear-gradient(135deg, #d97706, #f59e0b); }
.bg-grad-4 { background: linear-gradient(135deg, #dc2626, #f43f5e); }
.bg-grad-5 { background: linear-gradient(135deg, #0284c7, #38bdf8); }

/* ---------- Tables ---------- */
.table { color: var(--text); margin: 0; }
.table > :not(caption) > * > * { background: transparent; color: inherit; border-color: var(--border); padding: 12px 16px; }
.table thead th { color: var(--text-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; }
.table-hover tbody tr:hover > * { background: rgba(124, 58, 237, .05); }

/* ---------- Forms & buttons ---------- */
.form-control, .form-select {
  background: var(--surface); color: var(--text); border-color: var(--border); border-radius: 10px; padding: 9px 14px;
}
.form-control:focus, .form-select:focus {
  background: var(--surface); color: var(--text);
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}
.form-label { font-weight: 600; font-size: .86rem; }
.btn-brand { background: var(--brand-grad); color: #fff; border: 0; border-radius: 10px; padding: 9px 20px; font-weight: 600; }
.btn-brand:hover { color: #fff; filter: brightness(1.08); }
.btn { border-radius: 10px; }

.badge-soft-success { background: rgba(16, 185, 129, .13); color: #059669; }
.badge-soft-danger { background: rgba(244, 63, 94, .13); color: #e11d48; }
.badge-soft-info { background: rgba(56, 189, 248, .15); color: #0284c7; }

/* ---------- Auth pages ---------- */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(124, 58, 237, .25), transparent),
              radial-gradient(1000px 500px at 110% 110%, rgba(79, 70, 229, .25), transparent), var(--bg);
  padding: 20px;
}
.auth-card { width: 100%; max-width: 420px; padding: 36px; border-radius: 20px; }
.auth-logo { width: 62px; height: 62px; border-radius: 18px; background: var(--brand-grad); color: #fff; font-size: 1.7rem; display: inline-flex; align-items: center; justify-content: center; }

/* ---------- Profile ---------- */
.profile-photo { width: 110px; height: 110px; border-radius: 24px; object-fit: cover; }
.profile-fallback { width: 110px; height: 110px; border-radius: 24px; font-size: 2rem; }
.detail-row { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: .92rem; }
.detail-row:last-child { border-bottom: 0; }
.detail-row .k { color: var(--text-muted); }
.detail-row .v { font-weight: 600; text-align: right; }

/* ---------- Activity feed ---------- */
.feed-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--border); font-size: .89rem; }
.feed-item:last-child { border-bottom: 0; }
.feed-dot { width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: var(--brand); flex-shrink: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: -260px; transition: left .25s; }
  .sidebar.open { left: 0; }
  .sidebar-overlay.show { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 1035; }
  .content { padding: 16px; }
}

/* ---------- Break overlay (Step 5) ---------- */
.break-overlay {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: rgba(10, 13, 28, .82); backdrop-filter: blur(6px);
  color: #fff; align-items: center; justify-content: center; text-align: center;
}
.break-overlay.show { display: flex; }

/* ---------- Admin calendar (Step 6) ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { text-align: center; font-size: .72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; padding: 4px 0; }
.cal-cell {
  min-height: 74px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  color: var(--text); padding: 6px; display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  cursor: pointer; transition: border-color .15s, transform .1s; text-align: left;
}
.cal-cell:hover { border-color: var(--brand); transform: translateY(-1px); }
.cal-cell.empty { visibility: hidden; }
.cal-cell .num { font-weight: 700; font-size: .9rem; }
.cal-cell .badge { font-size: .58rem; }
.cal-label { font-size: .62rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; max-width: 100%; white-space: nowrap; }
.cal-cell.today { box-shadow: 0 0 0 2px var(--brand); }
.cal-cell.type-holiday, .cal-cell.type-festival { background: rgba(244, 63, 94, .06); }
.cal-cell.type-sunday { background: rgba(107, 114, 128, .08); }
.cal-cell.type-half_day { background: rgba(79, 70, 229, .07); }
.cal-cell.type-company_leave { background: rgba(56, 189, 248, .08); }
@media (max-width: 575.98px) { .cal-cell { min-height: 58px; } .cal-cell .badge { display: none; } }

/* ---------- Impersonation banner ---------- */
.impersonate-bar {
  background: linear-gradient(90deg, #d97706, #f59e0b); color: #fff;
  padding: 8px 16px; display: flex; align-items: center; justify-content: center; gap: 12px;
  font-size: .9rem; position: sticky; top: 0; z-index: 1050;
}

/* ---------- Print (reports) ---------- */
@media print {
  .sidebar, .topbar, .no-print, .impersonate-bar { display: none !important; }
  .content { padding: 0; }
  .card { border: none; box-shadow: none; }
  body { background: #fff; }
}
