@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

/* Two brand themes, sampled from the Revolution HR Solutions artwork: a
   white-dominant "day" look and the original black "night" look. Default
   follows the OS/browser color-scheme preference; js/theme.js lets the user
   override it manually via a header toggle and remembers the choice. */
:root,
[data-theme="light"] {
  --color-bg: #ffffff;
  --color-bg-raised: #f6f6f5;
  --color-card: #ffffff;
  --color-border: #e3e3e0;
  --color-ink: #14140f;
  --color-muted: #6b6b64;
  --color-red: #ec1f25;
  --color-red-dark: #a3151a;
  --color-success: #1f7a41;
  --color-warn: #8a6d1a;
  --color-danger: #ec1f25;
  --color-header-bg: #ffffff;
  --color-header-ink: #14140f;
  --color-footer-bg: #f6f6f5;
  --color-footer-ink: #14140f;
  --color-hover-tint: rgba(20, 20, 15, 0.035);
  --radius: 12px;
  --shadow: 0 8px 28px rgba(20, 20, 15, 0.1);
  --max-width: 1160px;
  font-size: 16px;
}

[data-theme="dark"] {
  --color-bg: #0a0a0a;
  --color-bg-raised: #131313;
  --color-card: #161616;
  --color-border: #2b2b2b;
  --color-ink: #f2f2f0;
  --color-muted: #9a9a95;
  --color-success: #2e9e5b;
  --color-warn: #c9a227;
  --color-header-bg: #000000;
  --color-header-ink: #ffffff;
  --color-footer-bg: #000000;
  --color-footer-ink: #ffffff;
  --color-hover-tint: rgba(255, 255, 255, 0.02);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0a0a0a;
    --color-bg-raised: #131313;
    --color-card: #161616;
    --color-border: #2b2b2b;
    --color-ink: #f2f2f0;
    --color-muted: #9a9a95;
    --color-success: #2e9e5b;
    --color-warn: #c9a227;
    --color-header-bg: #000000;
    --color-header-ink: #ffffff;
    --color-footer-bg: #000000;
    --color-footer-ink: #ffffff;
    --color-hover-tint: rgba(255, 255, 255, 0.02);
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--color-ink);
  background: var(--color-bg);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.15s ease, color 0.15s ease;
}

a { color: var(--color-red); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }

/* ---------------- Header ---------------- */
.site-header {
  background: var(--color-header-bg);
  border-bottom: 2px solid var(--color-red);
  position: sticky;
  top: 0;
  z-index: 40;
  transition: background-color 0.15s ease;
}
.site-header .container { height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.3rem; font-weight: 800; color: var(--color-header-ink); letter-spacing: 0.04em; }
.brand-mark { height: 44px; width: auto; }
.nav-cta { display: flex; gap: 10px; align-items: center; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-header-ink);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
}
.theme-toggle:hover { border-color: var(--color-red); }

/* Manager (tablet/Android app) header: always the same dark, branded chrome
   as the admin sidebar (#0d0d0a), independent of the light/dark theme
   toggle — matches how the admin sidebar itself stays dark in both themes. */
.manager-header { background: #0d0d0a; }
.manager-header .container { height: auto; min-height: 64px; padding: 10px 24px; flex-wrap: wrap; row-gap: 10px; }
.manager-header .brand { color: #f2f2f0; }
.manager-header .theme-toggle { color: #f2f2f0; border-color: rgba(255,255,255,0.18); }
.manager-header .theme-toggle:hover { border-color: var(--color-red); }
.manager-header .manager-header-link { color: #c7c7c0; }
.manager-header .manager-header-link:hover { color: #fff; text-decoration: none; }
.manager-header .manager-role-badge { background: rgba(201,162,39,0.18); color: #c9a227; }
.manager-header .app-sidebar-avatar { width: 36px; height: 36px; font-size: 0.8rem; }

main { flex: 1; padding: 32px 0 64px; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 8px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.92rem;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
  font-family: inherit;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--color-red); color: #fff; }
.btn-primary:hover { background: var(--color-red-dark); }
.btn-outline { background: transparent; border-color: var(--color-red); color: var(--color-red); }
.btn-ghost { background: transparent; color: var(--color-ink); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.btn-lg { padding: 16px 28px; font-size: 1.05rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Large touch targets for tablet use in the manager section */
.manager-shell .btn { padding: 16px 24px; font-size: 1.05rem; }
.manager-shell .theme-toggle { width: 44px; height: 44px; font-size: 1.2rem; }

/* ---------------- Cards / forms ---------------- */
.card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-raised);
  color: var(--color-ink);
  font-size: 0.95rem;
  font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: 2px solid var(--color-red); }

.alert { padding: 12px 16px; border-radius: 8px; font-size: 0.9rem; margin-bottom: 16px; }
.alert-error { background: rgba(236, 31, 37, 0.15); border: 1px solid var(--color-red); color: var(--color-danger); }
.alert-success { background: rgba(31, 122, 65, 0.12); border: 1px solid var(--color-success); color: var(--color-success); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--color-border); font-size: 0.92rem; }
th { color: var(--color-muted); font-weight: 600; text-transform: uppercase; font-size: 0.78rem; letter-spacing: 0.03em; }
tr:hover td { background: var(--color-hover-tint); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.badge-draft { background: rgba(154,154,149,0.2); color: var(--color-muted); }
.badge-pending { background: rgba(201,162,39,0.2); color: var(--color-warn); }
.badge-completed { background: rgba(46,158,91,0.2); color: var(--color-success); }

/* ---------------- Layout helpers ---------------- */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.row { display: flex; align-items: center; gap: 12px; }
.text-center { text-align: center; }
.muted { color: var(--color-muted); }
.spacer { height: 24px; }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------------- Auth screens ---------------- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 36px; box-shadow: var(--shadow); }
.auth-logo { display: block; margin: 0 auto 24px; max-width: 260px; }
.auth-sub { color: var(--color-muted); margin-top: -8px; margin-bottom: 24px; }

/* ---------------- Admin app shell (persistent sidebar) ---------------- */
.app-shell { display: flex; align-items: stretch; min-height: 100vh; width: 100%; }
.app-sidebar {
  width: 250px;
  flex-shrink: 0;
  background: #0d0d0a;
  color: #f2f2f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
}
.app-sidebar-brand { padding: 18px 20px 14px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.app-sidebar-brand img { height: 32px; }
.app-sidebar-user { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.app-sidebar-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--color-red); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
.app-sidebar-user-info { min-width: 0; flex: 1; }
.app-sidebar-user-name { font-weight: 700; font-size: 0.76rem; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-sidebar-user-role { font-size: 0.72rem; color: #a3a39c; text-transform: capitalize; }
.app-sidebar-nav { flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.app-sidebar-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: #c7c7c0; font-weight: 600; font-size: 0.88rem; }
.app-sidebar-link:hover { background: rgba(255,255,255,0.07); text-decoration: none; color: #fff; }
.app-sidebar-link.active { background: var(--color-red); color: #fff; }
.app-sidebar-link .icon { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }
.app-sidebar-footer { padding: 12px 20px 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.app-sidebar-footer .btn { width: 100%; justify-content: center; }

.app-content-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app-content-wrap main.container { max-width: none; padding: 24px 28px 56px; margin: 0; }
.app-topbar {
  background: var(--color-header-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.app-topbar-actions { display: flex; align-items: center; gap: 14px; }
.app-role-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; background: rgba(201,162,39,0.15); color: var(--color-warn); font-weight: 700; font-size: 0.78rem; text-transform: capitalize; white-space: nowrap; }

@media (max-width: 900px) {
  .app-sidebar { display: none; }
  .app-content-wrap main.container { padding: 20px 16px 48px; }
}

/* ---------------- Dashboard widgets ---------------- */
.stat-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat-card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 16px 18px; }
.stat-card .stat-value { font-size: 1.7rem; font-weight: 800; line-height: 1.15; }
.stat-card .stat-label { color: var(--color-muted); font-size: 0.82rem; margin-top: 4px; }

.progress-track { height: 8px; border-radius: 999px; background: var(--color-bg-raised); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--color-red); }

.donut { width: 140px; height: 140px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto; flex-shrink: 0; }
.donut-inner { width: 100px; height: 100px; border-radius: 50%; background: var(--color-card); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-inner .donut-pct { font-size: 1.4rem; font-weight: 800; line-height: 1; }
.donut-inner .donut-label { font-size: 0.72rem; color: var(--color-muted); margin-top: 2px; }

.avatar-circle { width: 38px; height: 38px; border-radius: 50%; background: var(--color-red); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; flex-shrink: 0; }

/* ---------------- Footer ---------------- */
.site-footer { background: var(--color-footer-bg); border-top: 2px solid var(--color-red); padding: 24px 0; margin-top: auto; transition: background-color 0.15s ease; }
.footer-tagline { font-weight: 800; letter-spacing: 0.3em; font-size: 0.85rem; color: var(--color-footer-ink); margin-bottom: 8px; }
.footer-bottom { font-size: 0.82rem; }
