
/* ═══════════════════════════════════════════════════════
   DrX Consult HR System – Main Stylesheet
═══════════════════════════════════════════════════════ */

:root {
  --primary: #1e3a5f;
  --primary-light: #2d5a9e;
  --primary-dark: #142840;
  --accent: #00b4d8;
  --accent-light: #90e0ef;
  --success: #2ecc71;
  --warning: #f39c12;
  --danger: #e74c3c;
  --info: #3498db;
  --bg: #f0f4f8;
  --card: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #e8f0fe;
  --text: #2c3e50;
  --text-primary: #2c3e50;
  --text-muted: #7f8c8d;
  --border: #e0e6ed;
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
  --transition: all 0.25s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Utilities ── */
.hidden { display: none !important; }
.page { min-height: 100vh; }
.page.active { display: block; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.text-muted { color: var(--text-muted); font-size: 0.875rem; }
.text-center { text-align: center; }
.w-full { width: 100%; }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 0.9rem; margin-bottom: 12px; }
.alert-error { background: #fdecea; color: #c0392b; border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: 8px; border: none; cursor: pointer; font-size: 0.9rem; font-weight: 600; transition: var(--transition); text-decoration: none; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-light); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(30,58,95,0.3); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover:not(:disabled) { background: #0096c7; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #27ae60; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #c0392b; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover:not(:disabled) { background: #e67e22; }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover:not(:disabled) { background: var(--primary); color: white; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; border-radius: 8px; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-group label i { margin-right: 6px; color: var(--primary); }
.form-control { width: 100%; padding: 11px 14px; border: 2px solid var(--border); border-radius: 8px; font-size: 0.9rem; color: var(--text); background: white; transition: var(--transition); outline: none; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,58,95,0.1); }
.form-control::placeholder { color: #bdc3c7; }
select.form-control { cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 44px; }
.toggle-pw { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--text-muted); }

/* ── Cards ── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.card-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* ── Stat Cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 28px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 18px; transition: var(--transition); border-left: 4px solid transparent; }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card.blue { border-left-color: var(--primary); }
.stat-card.green { border-left-color: var(--success); }
.stat-card.orange { border-left-color: var(--warning); }
.stat-card.red { border-left-color: var(--danger); }
.stat-card.cyan { border-left-color: var(--accent); }
.stat-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-card.blue .stat-icon { background: rgba(30,58,95,0.1); color: var(--primary); }
.stat-card.green .stat-icon { background: rgba(46,204,113,0.1); color: var(--success); }
.stat-card.orange .stat-icon { background: rgba(243,156,18,0.1); color: var(--warning); }
.stat-card.red .stat-icon { background: rgba(231,76,60,0.1); color: var(--danger); }
.stat-card.cyan .stat-icon { background: rgba(0,180,216,0.1); color: var(--accent); }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th { background: var(--primary); color: white; padding: 12px 16px; text-align: left; font-weight: 600; white-space: nowrap; }
thead th:first-child { border-radius: 8px 0 0 0; }
thead th:last-child { border-radius: 0 8px 0 0; }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.15s; }
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 12px 16px; vertical-align: middle; }
.table-empty { text-align: center; padding: 40px; color: var(--text-muted); }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #fdecea; color: #c0392b; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-primary { background: rgba(30,58,95,0.1); color: var(--primary); }
.badge-secondary { background: #e9ecef; color: #495057; }

/* ── Progress Bar ── */
.progress { background: var(--border); border-radius: 20px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 20px; transition: width 0.6s ease; }
.progress-bar.green { background: var(--success); }
.progress-bar.blue { background: var(--primary); }
.progress-bar.orange { background: var(--warning); }
.progress-bar.red { background: var(--danger); }

/* ── LOGIN PAGE ── */
.login-bg { min-height: 100vh; background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%); display: flex; align-items: center; justify-content: center; padding: 20px; position: relative; overflow: hidden; }
.login-bg::before { content: ''; position: absolute; width: 600px; height: 600px; background: rgba(255,255,255,0.03); border-radius: 50%; top: -200px; right: -200px; }
.login-bg::after { content: ''; position: absolute; width: 400px; height: 400px; background: rgba(255,255,255,0.03); border-radius: 50%; bottom: -100px; left: -100px; }
.login-card { background: white; border-radius: 20px; padding: 48px 40px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); position: relative; z-index: 1; }
.login-logo { text-align: center; margin-bottom: 36px; }
.logo-icon { width: 72px; height: 72px; background: linear-gradient(135deg, var(--primary), var(--accent)); border-radius: 20px; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; font-size: 2rem; color: white; box-shadow: 0 8px 24px rgba(30,58,95,0.3); }
.login-logo h1 { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.login-logo p { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }
.login-hint { margin-top: 24px; padding: 16px; background: var(--bg); border-radius: 10px; font-size: 0.8rem; color: var(--text-muted); }
.login-hint p { margin-bottom: 4px; }
.login-hint code { background: white; padding: 2px 6px; border-radius: 4px; font-family: monospace; color: var(--primary); font-weight: 600; }

/* ── SIDEBAR ── */
.sidebar { position: fixed; left: 0; top: 0; width: var(--sidebar-w); height: 100vh; background: var(--primary-dark); color: white; display: flex; flex-direction: column; z-index: 1000; transition: transform 0.3s ease; overflow-y: auto; }
.sidebar-header { padding: 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; font-weight: 700; }
.sidebar-logo i { color: var(--accent); font-size: 1.3rem; }
.sidebar-close { display: none; background: none; border: none; color: white; font-size: 1.2rem; cursor: pointer; }
.sidebar-nav { flex: 1; padding: 16px 12px; }
.nav-section-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,0.4); padding: 12px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px; color: rgba(255,255,255,0.75); text-decoration: none; font-size: 0.9rem; font-weight: 500; transition: var(--transition); margin-bottom: 2px; }
.nav-item:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-item.active { background: var(--accent); color: white; box-shadow: 0 4px 12px rgba(0,180,216,0.3); }
.nav-item i { width: 18px; text-align: center; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.1); }
.user-info { margin-bottom: 12px; }
.user-info .user-name { font-weight: 600; font-size: 0.9rem; }
.user-info .user-role { font-size: 0.75rem; color: rgba(255,255,255,0.5); text-transform: capitalize; }

/* ── TOPBAR ── */
.topbar { height: var(--topbar-h); background: white; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.menu-btn { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text); padding: 8px; border-radius: 8px; }
.menu-btn:hover { background: var(--bg); }
.topbar-title { font-size: 1.1rem; font-weight: 700; color: var(--text); flex: 1; }
.topbar-user { font-size: 0.85rem; color: var(--text-muted); }
.topbar-user strong { color: var(--primary); }

/* ── MAIN LAYOUT ── */
.main-content { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.content-area { flex: 1; padding: 28px; }
.page-header { margin-bottom: 28px; }
.page-header h2 { font-size: 1.6rem; font-weight: 800; color: var(--text); }
.page-header p { color: var(--text-muted); margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── GRID LAYOUTS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }

/* ── MODAL ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 2000; backdrop-filter: blur(4px); }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: white; border-radius: 16px; width: 90%; max-width: 560px; max-height: 90vh; overflow-y: auto; z-index: 2001; box-shadow: var(--shadow-lg); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-header button { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: 6px; }
.modal-header button:hover { background: var(--bg); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── TOAST ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: white; border-radius: 10px; padding: 14px 18px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: 380px; animation: slideIn 0.3s ease; border-left: 4px solid var(--primary); }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast i { font-size: 1.1rem; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.warning i { color: var(--warning); }
.toast span { font-size: 0.875rem; flex: 1; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(100%); } }

/* ── ATTENDANCE STATUS ── */
.checkin-card { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: white; border-radius: var(--radius); padding: 32px; text-align: center; }
.checkin-time { font-size: 3rem; font-weight: 800; margin: 16px 0; }
.checkin-date { opacity: 0.8; font-size: 0.9rem; }
.checkin-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.status-dot.present { background: var(--success); }
.status-dot.absent { background: var(--danger); }
.status-dot.late { background: var(--warning); }
.status-dot.half-day { background: var(--info); }

/* ── PERFORMANCE SCORE ── */
.score-circle { width: 140px; height: 140px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto 20px; font-weight: 800; position: relative; }
.score-circle .score-num { font-size: 2.5rem; line-height: 1; }
.score-circle .score-label { font-size: 0.75rem; opacity: 0.8; }
.score-high { background: linear-gradient(135deg, #2ecc71, #27ae60); color: white; box-shadow: 0 8px 24px rgba(46,204,113,0.4); }
.score-medium { background: linear-gradient(135deg, #f39c12, #e67e22); color: white; box-shadow: 0 8px 24px rgba(243,156,18,0.4); }
.score-low { background: linear-gradient(135deg, #e74c3c, #c0392b); color: white; box-shadow: 0 8px 24px rgba(231,76,60,0.4); }

/* ── CHURN RISK ── */
.risk-meter { text-align: center; padding: 24px; }
.risk-value { font-size: 3rem; font-weight: 800; }
.risk-high { color: var(--danger); }
.risk-medium { color: var(--warning); }
.risk-low { color: var(--success); }

/* ── PAYROLL CARD ── */
.payroll-breakdown { background: var(--bg); border-radius: 10px; padding: 20px; }
.payroll-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.payroll-row:last-child { border-bottom: none; }
.payroll-total { background: var(--primary); color: white; border-radius: 10px; padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-weight: 700; font-size: 1.1rem; }

/* ── SEARCH & FILTER BAR ── */
.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; align-items: center; }
.filter-bar .form-control { max-width: 220px; }
.search-input { position: relative; }
.search-input i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input input { padding-left: 36px; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 3rem; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--text); }

/* ── SIDEBAR OVERLAY ── */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 999; }

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .content-area { padding: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-control { max-width: 100%; }
  .modal { width: 95%; }
  .login-card { padding: 32px 24px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .checkin-time { font-size: 2rem; }
}

/* ── LOADING SPINNER ── */
.spinner { display: inline-block; width: 40px; height: 40px; border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; align-items: center; justify-content: center; padding: 60px; }

/* ── CHART CONTAINER ── */
.chart-container { position: relative; height: 280px; }

/* ── DEPT CARD ── */
.dept-card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.dept-name { font-weight: 700; font-size: 1rem; margin-bottom: 12px; color: var(--primary); }
.dept-stats { display: flex; gap: 16px; margin-bottom: 12px; }
.dept-stat { text-align: center; }
.dept-stat .val { font-size: 1.4rem; font-weight: 800; }
.dept-stat .lbl { font-size: 0.7rem; color: var(--text-muted); }

/* ── TIMELINE ── */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-item::before { content: ''; position: absolute; left: -20px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid white; box-shadow: 0 0 0 2px var(--primary); }
.timeline-date { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.timeline-content { background: var(--bg); border-radius: 8px; padding: 10px 14px; font-size: 0.875rem; }
