/* assets/css/app.css — PayrollPro */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --navy: #0d1b2a;
  --navy-light: #1a2d44;
  --navy-mid: #243b55;
  --white: #ffffff;
  --off-white: #f4f6f9;
  --border: #dde3ea;
  --muted: #8496a9;
  --accent: #2563eb;
  --accent-dim: #1e4fc0;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --text: #1a2534;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .10);
  --radius: 6px;
  --sidebar-w: 240px;
  --font: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

[data-theme="dark"] {
  --navy: #f3f4f6;
  --navy-light: #e5e7eb;
  --navy-mid: #9ca3af;
  --white: #111827;
  --off-white: #1f2937;
  --border: #374151;
  --muted: #9ca3af;
  --text: #f3f4f6;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .6);
}

[data-theme="dark"] img[src*="dmglogo.png"] {
  filter: brightness(0) invert(1);
}

/* ── Reset ──────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--off-white);
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

ul,
ol {
  list-style: none;
}

/* ── Login ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--navy);
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -20px;
  left: -20px;
  right: -20px;
  bottom: -20px;
  background: url('../img/loginbg.png') center/cover no-repeat;
  filter: blur(6px) brightness(0.7);
  z-index: 0;
}

.login-card {
  background: var(--white);
  border-radius: 10px;
  width: 100%;
  max-width: 400px;
  padding: 2.5rem 2rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo .wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: .3rem;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -.5px;
}

.login-logo .wordmark span {
  color: var(--accent);
}

.login-logo p {
  font-size: .8rem;
  color: var(--muted);
  margin-top: .25rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ── Shell ──────────────────────────────────────────────── */
.shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: width .25s ease, transform .25s ease;
  overflow-x: hidden;
}

.sidebar-brand {
  padding: 1.4rem 1.4rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-brand .wordmark {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.4px;
}

.sidebar-brand .wordmark span {
  color: var(--accent);
}

.sidebar-brand .tagline {
  font-size: .7rem;
  color: rgba(255, 255, 255, .4);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: .1rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.nav-section {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255, 255, 255, .35);
  padding: .8rem 1.4rem .3rem;
  margin-top: .5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1.4rem;
  font-size: .875rem;
  color: rgba(255, 255, 255, .7);
  border-left: 3px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}

.nav-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: .75;
  transition: margin .25s, width .25s, height .25s;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, .07);
  color: var(--white);
  border-left-color: var(--accent);
}

.nav-link.active svg {
  opacity: 1;
}

/* Folded State */
body.sidebar-folded {
  --sidebar-w: 64px;
}

body.sidebar-folded .sidebar-brand {
  padding: 1.4rem 0.5rem 1rem;
  text-align: center;
}

body.sidebar-folded .sidebar-brand .wordmark .text-full {
  display: none;
}

body.sidebar-folded .sidebar-brand .wordmark .text-short {
  display: inline-flex !important;
  font-size: 1.4rem;
}

body.sidebar-folded .sidebar-brand .tagline,
body.sidebar-folded .nav-section,
body.sidebar-folded .nav-link span {
  display: none;
}

body.sidebar-folded .sidebar-footer {
  padding: 1rem 0;
  display: flex;
  justify-content: center;
}

body.sidebar-folded .sidebar-footer .text-full {
  display: none;
}

body.sidebar-folded .sidebar-footer .logout-btn {
  margin: 0;
  padding: 0.6rem;
}

body.sidebar-folded .sidebar-footer .logout-btn svg {
  margin: 0 !important;
  width: 20px;
  height: 20px;
}

body.sidebar-folded .nav-link {
  padding: 0.8rem 0;
  justify-content: center;
}

body.sidebar-folded .nav-link svg {
  margin: 0;
  width: 20px;
  height: 20px;
}

.sidebar-footer {
  padding: 1rem 1.4rem;
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: .8rem;
  color: rgba(255, 255, 255, .5);
}

.sidebar-footer a {
  color: rgba(255, 255, 255, .65);
}

.sidebar-footer a:hover {
  color: var(--white);
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  margin-top: .75rem;
  padding: .4rem .85rem;
  background: var(--danger);
  color: var(--white) !important;
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .3px;
  transition: background .15s, opacity .15s;
}

.logout-btn:hover {
  background: #b91c1c;
}

.logout-btn svg {
  width: 14px;
  height: 14px;
  margin-right: .4rem;
  flex-shrink: 0;
}

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

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 1.75rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-user {
  font-size: .8rem;
  color: var(--muted);
}

.topbar-user strong {
  color: var(--text);
}

.page-content {
  padding: 1.75rem;
  flex: 1;
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--navy);
}

.card-body {
  padding: 1.25rem;
}

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
}

.stat-card .stat-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  margin-bottom: .4rem;
}

.stat-card .stat-val {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}

.stat-card .stat-sub {
  font-size: .75rem;
  color: var(--muted);
  margin-top: .3rem;
}

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

.data-table thead th {
  background: var(--navy);
  color: rgba(255, 255, 255, .85);
  font-weight: 500;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: .7rem 1rem;
  text-align: left;
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

.data-table tbody tr:hover {
  background: #f0f4ff;
}

.data-table tbody td {
  padding: .65rem 1rem;
  vertical-align: middle;
}

.data-table tfoot td {
  padding: .65rem 1rem;
  font-weight: 600;
  border-top: 2px solid var(--border);
  background: var(--off-white);
}

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2em .6em;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.badge-success {
  background: #dcfce7;
  color: var(--success);
}

.badge-danger {
  background: #fee2e2;
  color: var(--danger);
}

.badge-warning {
  background: #fef9c3;
  color: var(--warning);
}

.badge-info {
  background: #dbeafe;
  color: var(--accent);
}

.badge-neutral {
  background: #f1f5f9;
  color: var(--muted);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, box-shadow .15s, border-color .15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
}

.btn-navy {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}

.btn-navy:hover {
  background: var(--navy-light);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-danger:hover {
  opacity: .85;
}

.btn-sm {
  padding: .35rem .75rem;
  font-size: .8rem;
}

.btn-xs {
  padding: .2rem .55rem;
  font-size: .75rem;
}

/* ── Forms ──────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.form-group.full {
  grid-column: 1 / -1;
}

label {
  font-size: .8rem;
  font-weight: 500;
  color: var(--navy);
}

label .req {
  color: var(--danger);
  margin-left: 2px;
}

.form-control {
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .875rem;
  color: var(--text);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238496a9' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2rem;
}

.form-hint {
  font-size: .75rem;
  color: var(--muted);
}

.form-actions {
  margin-top: 1.5rem;
  display: flex;
  gap: .75rem;
  align-items: center;
}

/* ── Alerts / Flash ─────────────────────────────────────── */
.alert {
  padding: .8rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 1.25rem;
  border-left: 4px solid;
}

.alert-success {
  background: #f0fdf4;
  border-color: var(--success);
  color: #166534;
}

.alert-danger {
  background: #fef2f2;
  border-color: var(--danger);
  color: #991b1b;
}

.alert-warning {
  background: #fffbeb;
  border-color: var(--warning);
  color: #92400e;
}

.alert-info {
  background: #eff6ff;
  border-color: var(--accent);
  color: #1e40af;
}

/* ── Page header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
}

.page-header p {
  font-size: .85rem;
  color: var(--muted);
  margin-top: .2rem;
}

/* ── Upload drop zone ───────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--off-white);
}

.drop-zone:hover,
.drop-zone.over {
  border-color: var(--accent);
  background: #eff6ff;
}

.drop-zone .dz-icon {
  font-size: 2.5rem;
  opacity: .4;
  margin-bottom: .75rem;
}

.drop-zone p {
  color: var(--muted);
  font-size: .875rem;
}

.drop-zone strong {
  color: var(--accent);
}

/* ── Payslip print view ─────────────────────────────────── */
@media print {

  .sidebar,
  .topbar,
  .no-print {
    display: none !important;
  }

  .main-wrap {
    margin-left: 0;
  }

  .payslip {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

.payslip {
  max-width: 78mm;
  margin: 0 auto;
  font-family: var(--font-mono);
  font-size: .7rem;
  background: white;
  padding: 1rem;
  border: 1px solid var(--border);
  line-height: 1.5;
}

.payslip-title {
  text-align: center;
  font-weight: 700;
  font-size: .85rem;
  margin-bottom: .5rem;
}

.payslip-divider {
  border: none;
  border-top: 1px dashed #999;
  margin: .4rem 0;
}

.payslip-row {
  display: flex;
  justify-content: space-between;
}

.payslip-row.total {
  font-weight: 700;
  border-top: 1px solid #999;
  margin-top: .2rem;
  padding-top: .2rem;
}

/* ── Utilities ───────────────────────────────────────────── */
.mt-1 {
  margin-top: .5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mt-3 {
  margin-top: 1.5rem;
}

.mb-1 {
  margin-bottom: .5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.mb-3 {
  margin-bottom: 1.5rem;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.gap-1 {
  gap: .5rem;
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--muted);
}

.text-danger {
  color: var(--danger);
}

.text-success {
  color: var(--success);
}

.font-mono {
  font-family: var(--font-mono);
}

.w-full {
  width: 100%;
}

.hidden {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ── Responsive ─────────────────────────────────────────── */
.menu-toggle {
  display: flex;
  background: none;
  border: none;
  cursor: pointer;
  padding: .4rem;
  color: inherit;
}

@media (max-width: 900px) {
  body.sidebar-folded {
    --sidebar-w: 240px;
  }

  /* Reset folded on mobile */
  body.sidebar-folded .sidebar-brand,
  body.sidebar-folded .sidebar-brand .tagline,
  body.sidebar-folded .nav-section,
  body.sidebar-folded .nav-link span,
  body.sidebar-folded .sidebar-footer .text-full {
    display: block;
  }

  body.sidebar-folded .sidebar-footer {
    display: block;
    padding: 1rem 1.4rem;
  }

  body.sidebar-folded .sidebar-footer .logout-btn {
    margin-top: .75rem;
    padding: .4rem .85rem;
  }

  body.sidebar-folded .sidebar-footer .logout-btn svg {
    margin-right: .4rem !important;
    width: 14px;
    height: 14px;
  }

  body.sidebar-folded .sidebar-brand .wordmark .text-full {
    display: inline-flex;
  }

  body.sidebar-folded .sidebar-brand .wordmark .text-short {
    display: none !important;
  }

  body.sidebar-folded .nav-link {
    padding: .6rem 1.4rem;
    justify-content: flex-start;
  }

  body.sidebar-folded .nav-link svg {
    width: 16px;
    height: 16px;
    margin-right: .75rem;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-wrap {
    margin-left: 0;
  }

  .menu-toggle {
    display: flex;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 540px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .page-content {
    padding: 1rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Modals ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(2px);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--white);
  border-radius: 12px;
  width: 90%;
  max-width: 380px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.3px;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0.2rem;
  transition: color 0.15s;
}

.modal-close:hover {
  color: var(--navy);
}

.modal-body {
  color: #64748b;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

.modal-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.modal-footer .btn {
  flex: 1;
  justify-content: center;
  border-radius: 20px;
  font-weight: 600;
  padding: 0.6rem 1rem;
}