/* ============================================================
   CAREVIEW PRO — Universal Design System
   Red / White / Black Professional Theme
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700;800&family=DM+Mono:wght@400;500&display=swap');

/* ── CSS Variables ─────────────────────────────────────── */
:root {
  --red:          #DC2626;
  --red-dark:     #B91C1C;
  --red-light:    #FEE2E2;
  --red-mid:      #EF4444;
  --black:        #0A0A0A;
  --black-soft:   #111827;
  --black-mid:    #1F2937;
  --gray-dark:    #374151;
  --gray-mid:     #6B7280;
  --gray-light:   #D1D5DB;
  --gray-pale:    #F3F4F6;
  --gray-white:   #F9FAFB;
  --white:        #FFFFFF;
  --success:      #16A34A;
  --success-bg:   #DCFCE7;
  --warning:      #D97706;
  --warning-bg:   #FEF3C7;
  --info:         #2563EB;
  --info-bg:      #DBEAFE;
  --danger:       #DC2626;
  --danger-bg:    #FEE2E2;

  --sidebar-w:    260px;
  --topbar-h:     64px;
  --radius:       10px;
  --radius-lg:    16px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow:       0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg:    0 10px 25px rgba(0,0,0,0.1), 0 4px 10px rgba(0,0,0,0.08);
  --shadow-red:   0 4px 20px rgba(220,38,38,0.3);

  --brand-gradient: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
  --brand-primary:  var(--red);
}

/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--gray-pale);
  color: var(--black-soft);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-dark); }

/* ── App Shell ─────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--black);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.sidebar-logo h2 {
  font-size: 17px;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-logo span {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  display: block;
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-nav { flex: 1; padding: 16px 12px; }

.nav-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,0.3);
  padding: 16px 8px 6px;
  margin-top: 4px;
}
.nav-section:first-child { padding-top: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,0.65);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s ease;
  margin-bottom: 2px;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.nav-item.active {
  background: var(--red);
  color: var(--white);
  font-weight: 600;
  box-shadow: var(--shadow-red);
}
.nav-item .icon { width: 20px; text-align: center; font-size: 15px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.sidebar-footer > div:first-child { font-weight: 600; font-size: 13px; color: var(--white); }

/* ── Main Content ──────────────────────────────────────── */
.main-content { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar h1 { font-size: 18px; font-weight: 700; color: var(--black-soft); letter-spacing: -0.3px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  background: var(--gray-pale);
  border-radius: 50px;
  cursor: pointer;
  border: 1px solid var(--gray-light);
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--red);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Page Content ──────────────────────────────────────── */
.page-content { flex: 1; padding: 28px; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.06);
  overflow: hidden;
}
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-pale);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--white);
}
.card-header h3 { font-size: 15px; font-weight: 700; color: var(--black-soft); letter-spacing: -0.2px; }
.card-body { padding: 24px; }

/* ── Stat Cards ─────────────────────────────────────────── */
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.06);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--red);
}
.stat-card .stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-mid);
  margin-bottom: 8px;
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--black-soft);
  letter-spacing: -1px;
  line-height: 1;
}
.stat-card .stat-sub { font-size: 12px; color: var(--gray-mid); margin-top: 6px; }
.stat-card .stat-icon {
  position: absolute;
  right: 20px; top: 50%;
  transform: translateY(-50%);
  font-size: 36px;
  opacity: 0.1;
}

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead tr { background: var(--gray-pale); border-bottom: 2px solid var(--gray-light); }
thead th {
  padding: 12px 20px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--gray-mid);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid #F3F4F6; transition: background 0.1s; }
tbody tr:hover { background: #FAFAFA; }
tbody tr:last-child { border-bottom: none; }
td { padding: 14px 20px; color: var(--black-soft); vertical-align: middle; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
  font-family: 'DM Sans', sans-serif;
  line-height: 1;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--red); color: var(--white); box-shadow: 0 2px 8px rgba(220,38,38,0.3); }
.btn-primary:hover { background: var(--red-dark); color: var(--white); box-shadow: var(--shadow-red); }
.btn-secondary { background: var(--gray-pale); color: var(--black-soft); border: 1px solid var(--gray-light); }
.btn-secondary:hover { background: var(--gray-light); color: var(--black-soft); }
.btn-success { background: var(--success); color: var(--white); box-shadow: 0 2px 8px rgba(22,163,74,0.3); }
.btn-success:hover { background: #15803D; color: var(--white); }
.btn-danger { background: var(--red); color: var(--white); box-shadow: 0 2px 8px rgba(220,38,38,0.2); }
.btn-danger:hover { background: var(--red-dark); color: var(--white); }
.btn-outline { background: transparent; color: var(--black-soft); border: 1.5px solid var(--gray-light); }
.btn-outline:hover { border-color: var(--red); color: var(--red); background: var(--red-light); }
.btn-dark { background: var(--black-soft); color: var(--white); }
.btn-dark:hover { background: var(--black); color: var(--white); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 13px 28px; font-size: 15px; }
.w-100 { width: 100%; }

/* ── Forms ──────────────────────────────────────────────── */
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--black-soft); margin-bottom: 6px; }
.form-control {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 13.5px;
  font-family: 'DM Sans', sans-serif;
  color: var(--black-soft);
  background: var(--white);
  border: 1.5px solid var(--gray-light);
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  -webkit-appearance: none;
}
.form-control:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(220,38,38,0.1); }
.form-control::placeholder { color: var(--gray-mid); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }
.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-section { margin-bottom: 28px; }
.form-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-mid);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-pale);
}

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.badge-primary   { background: var(--red-light); color: var(--red-dark); }
.badge-success   { background: var(--success-bg); color: #15803D; }
.badge-warning   { background: var(--warning-bg); color: #92400E; }
.badge-danger    { background: var(--danger-bg); color: var(--red-dark); }
.badge-info      { background: var(--info-bg); color: #1D4ED8; }
.badge-secondary { background: var(--gray-pale); color: var(--gray-dark); border: 1px solid var(--gray-light); }
.badge-dark      { background: var(--black-soft); color: var(--white); }

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 20px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: #15803D; border-color: #BBF7D0; }
.alert-danger, .alert-error { background: var(--danger-bg); color: var(--red-dark); border-color: #FECACA; }
.alert-warning { background: var(--warning-bg); color: #92400E; border-color: #FDE68A; }
.alert-info { background: var(--info-bg); color: #1D4ED8; border-color: #BFDBFE; }
.alert-dismissible { position: relative; padding-right: 40px; }
.btn-close { position: absolute; right: 12px; top: 12px; background: none; border: none; cursor: pointer; font-size: 16px; opacity: 0.5; color: inherit; }
.btn-close:hover { opacity: 1; }

/* ── Clock Widget ───────────────────────────────────────── */
.clock-widget {
  background: var(--black);
  border-radius: var(--radius-lg);
  padding: 24px;
  color: var(--white);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.clock-widget::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 140px; height: 140px;
  background: var(--red);
  border-radius: 50%;
  opacity: 0.2;
}
.clock-widget .time-display {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -1px;
  font-family: 'DM Mono', monospace;
  color: var(--white);
  line-height: 1;
  margin: 8px 0;
  position: relative;
  z-index: 1;
}
.clock-widget .date-display { font-size: 12px; color: rgba(255,255,255,0.5); font-weight: 500; position: relative; z-index: 1; }

/* ── Welcome Banner ─────────────────────────────────────── */
.welcome-banner {
  background: var(--black);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  color: var(--white);
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
}
.welcome-banner::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 220px; height: 220px;
  background: var(--red);
  border-radius: 50%;
  opacity: 0.2;
}
.welcome-banner::after {
  content: '';
  position: absolute;
  bottom: -40px; right: 120px;
  width: 140px; height: 140px;
  background: var(--red);
  border-radius: 50%;
  opacity: 0.1;
}
.welcome-banner h2 { font-size: 22px; font-weight: 800; color: var(--white); letter-spacing: -0.5px; position: relative; z-index: 1; }
.welcome-banner .sub { font-size: 13px; color: rgba(255,255,255,0.6); margin-top: 4px; position: relative; z-index: 1; }
.welcome-banner .stats-row { display: flex; gap: 32px; margin-top: 20px; position: relative; z-index: 1; flex-wrap: wrap; }
.welcome-banner .stat-item .label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,0.5); margin-bottom: 2px; }
.welcome-banner .stat-item .value { font-size: 20px; font-weight: 800; color: var(--white); }

/* ── Task Items ─────────────────────────────────────────── */
.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  margin-bottom: 4px;
  background: var(--gray-pale);
  transition: background 0.1s;
}
.task-item:hover { background: var(--gray-light); }
.task-checkbox { width: 18px; height: 18px; accent-color: var(--red); cursor: pointer; flex-shrink: 0; }
.task-label { font-size: 13.5px; color: var(--black-soft); }
.task-label.done { text-decoration: line-through; color: var(--gray-mid); }

/* ── Slide Panel ─────────────────────────────────────────── */
.slide-panel {
  position: fixed;
  top: 0; right: -500px; bottom: 0;
  width: 480px;
  background: var(--white);
  box-shadow: -8px 0 40px rgba(0,0,0,0.12);
  z-index: 200;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.slide-panel.open { right: 0; }
.slide-panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-pale);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 1;
}
.slide-panel-header h3 { font-size: 16px; font-weight: 700; }
.slide-panel-body { padding: 24px; flex: 1; }
.panel-close {
  background: var(--gray-pale);
  border: none;
  border-radius: 8px;
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-dark);
  transition: all 0.15s;
}
.panel-close:hover { background: var(--red); color: var(--white); }
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 199;
  display: none;
  backdrop-filter: blur(2px);
}
.panel-overlay.open { display: block; }

/* ── Pay Stub ───────────────────────────────────────────── */
.paystub-card {
  background: var(--white);
  border: 1px solid var(--gray-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow 0.15s, transform 0.15s;
}
.paystub-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.paystub-header { background: var(--black); color: var(--white); padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; }
.paystub-body { padding: 18px 20px; }
.paystub-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; border-bottom: 1px dashed var(--gray-pale); }
.paystub-row:last-child { border-bottom: none; }
.paystub-total { background: var(--red); color: var(--white); padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; font-weight: 700; }

/* ── Signature ──────────────────────────────────────────── */
#signatureCanvas {
  border: 2px dashed var(--gray-light);
  border-radius: var(--radius);
  width: 100%;
  height: 160px;
  touch-action: none;
  cursor: crosshair;
  background: var(--gray-pale);
  display: block;
}
#signatureCanvas.signed { border-color: var(--red); border-style: solid; }

/* ── Utilities ──────────────────────────────────────────── */
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--red) !important; }
.text-warning { color: var(--warning) !important; }
.text-info    { color: var(--info) !important; }
.text-muted   { color: var(--gray-mid) !important; }
.text-sm      { font-size: 12.5px; }
.text-xs      { font-size: 11px; }
.fw-bold      { font-weight: 700; }

.empty-state { text-align: center; padding: 56px 24px; color: var(--gray-mid); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h4 { font-size: 16px; font-weight: 700; color: var(--black-soft); margin-bottom: 6px; }

/* ── Print ──────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .btn, .slide-panel { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  body { background: white; }
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
}