/* PulseHR — clean, minimal, indigo accent */
:root {
  --bg: #fafafa;
  --bg-card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-dim: #6b7280;
  --text-mute: #9ca3af;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-soft: #eef2ff;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --success: #10b981;
  --success-soft: #d1fae5;
  --warning: #f59e0b;
  --warning-soft: #fffbeb;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* === Layout === */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.brand-dot { width: 22px; height: 22px; border-radius: 6px; background: var(--primary); display: inline-flex; align-items: center; justify-content: center; color: white; font-size: 13px; }
.brand-tag { font-size: 11px; color: var(--text-mute); background: var(--primary-soft); color: var(--primary); padding: 2px 8px; border-radius: 999px; margin-left: 4px; font-weight: 600; }
.user-menu { display: flex; align-items: center; gap: 14px; }
.user-menu .name { font-weight: 600; }
.user-menu .role { font-size: 11px; color: var(--text-mute); }
.btn-logout { background: transparent; color: var(--text-dim); border: 1px solid var(--border); padding: 6px 14px; border-radius: 8px; font-size: 13px; }
.btn-logout:hover { background: var(--bg); color: var(--text); }

.main { flex: 1; display: flex; }
.sidebar { width: 230px; background: var(--bg-card); border-right: 1px solid var(--border); padding: 20px 14px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  padding: 9px 12px; border-radius: 8px; color: var(--text-dim);
  display: flex; align-items: center; gap: 10px; font-weight: 500;
  transition: background 0.1s;
}
.nav a:hover { background: var(--bg); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-icon { width: 16px; height: 16px; opacity: 0.7; }

.content { flex: 1; padding: 28px 32px; overflow: auto; }
.content-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; gap: 16px; }
.content-title { font-size: 22px; font-weight: 700; }
.content-subtitle { color: var(--text-dim); font-size: 13px; margin-top: 2px; }

/* === Cards === */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 22px; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; font-weight: 600; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-label { color: var(--text-dim); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.stat-sub { color: var(--text-mute); font-size: 12px; margin-top: 2px; }

/* === Buttons === */
.btn { padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; border: 1px solid transparent; transition: all 0.1s; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-card); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: white; }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* === Tables === */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 10px 14px; background: var(--bg); color: var(--text-dim); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover { background: var(--bg); }
.table .actions { display: flex; gap: 6px; }

/* === Forms === */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field label { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.form-field input, .form-field select, .form-field textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: white; color: var(--text);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: 2px solid var(--primary-soft); border-color: var(--primary);
}

/* === Modals === */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 100;
  display: flex; align-items: center; justify-content: center;
  animation: fade-in 0.15s;
}
.modal {
  background: var(--bg-card); border-radius: var(--radius); width: min(640px, 92vw);
  max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lg);
}
.modal-head { padding: 16px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-weight: 700; font-size: 16px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }

/* === Pills / badges === */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.pill-active { background: var(--success-soft); color: var(--success); }
.pill-inactive { background: var(--bg); color: var(--text-mute); }
.pill-leave { background: var(--warning-soft); color: var(--warning); }
.pill-terminated { background: var(--danger-soft); color: var(--danger); }
.pill-probation { background: #e0e7ff; color: #4338ca; }

/* === Login === */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center;
              background: linear-gradient(135deg, #fafafa 0%, #eef2ff 100%); padding: 20px; }
.login-card { width: min(420px, 100%); background: white; border-radius: var(--radius); padding: 36px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; margin-bottom: 24px; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.login-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form button { padding: 11px; font-size: 14px; margin-top: 6px; }
.login-error { color: var(--danger); background: var(--danger-soft); padding: 8px 12px; border-radius: 8px; font-size: 13px; }

/* === Loading / empty === */
.loading { padding: 60px 20px; text-align: center; color: var(--text-mute); }
.empty { padding: 40px 20px; text-align: center; color: var(--text-dim); }
.empty-title { font-weight: 600; color: var(--text); margin-bottom: 6px; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* === AI chat === */
.chat-wrap { display: flex; flex-direction: column; gap: 14px; height: calc(100vh - 180px); }
.chat-history { flex: 1; overflow-y: auto; padding: 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; gap: 12px; }
.chat-msg { padding: 10px 14px; border-radius: 10px; max-width: 78%; }
.chat-msg.user { background: var(--primary); color: white; align-self: flex-end; }
.chat-msg.assistant { background: var(--bg); border: 1px solid var(--border); }
.chat-msg .who { font-size: 10px; opacity: 0.7; margin-bottom: 4px; font-weight: 600; text-transform: uppercase; }
.chat-input { display: flex; gap: 8px; }
.chat-input textarea { flex: 1; resize: vertical; min-height: 44px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }

/* === Org chart === */
.org-chart { font-size: 13px; }
.org-node { padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; cursor: pointer; }
.org-node:hover { border-color: var(--primary); }
.org-children { margin-left: 24px; border-left: 2px solid var(--border); padding-left: 14px; }

/* === Responsive === */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .content { padding: 18px; }
}

/* === Phase 2: Leave types grid === */
.leave-types-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important; }
.leave-type-card {
  background: white;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.leave-type-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.leave-type-name { font-weight: 700; font-size: 14px; color: var(--text); }
.leave-type-pill { padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.leave-type-stats { display: flex; align-items: baseline; gap: 4px; margin: 4px 0; }
.leave-type-used { font-size: 24px; font-weight: 800; color: var(--text); }
.leave-type-sep { color: var(--text-mute); font-size: 16px; }
.leave-type-total { color: var(--text-dim); font-size: 13px; font-weight: 500; }
.leave-type-bar { background: var(--bg); height: 5px; border-radius: 999px; margin-top: 8px; overflow: hidden; }
.leave-type-bar-fill { height: 100%; transition: width 0.5s ease; }
.leave-type-meta { font-size: 11px; color: var(--text-mute); margin-top: 6px; font-family: var(--mono, 'JetBrains Mono', monospace); }
.leave-type-tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }

/* === Dashboard polish — Astra-style hover lift === */
.card, .stat { transition: transform 0.18s ease, box-shadow 0.18s ease; }
.card:hover, .stat:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.06); }

/* === Stat gradients === */
.stat:nth-child(1) { background: linear-gradient(135deg, #eef2ff 0%, #ffffff 60%); }
.stat:nth-child(2) { background: linear-gradient(135deg, #fef3c7 0%, #ffffff 60%); }
.stat:nth-child(3) { background: linear-gradient(135deg, #d1fae5 0%, #ffffff 60%); }
.stat:nth-child(4) { background: linear-gradient(135deg, #fce7f3 0%, #ffffff 60%); }

/* === PulseHR brand gradient on login === */
.login-brand .brand-dot { background: linear-gradient(135deg, #6366f1 0%, #ec4899 100%); }

/* === Hover transitions on nav links === */
.nav a { transition: all 0.12s ease; }
.nav a:hover { transform: translateX(2px); }
.nav a.active { box-shadow: inset 3px 0 0 var(--primary); }

/* === Tables — zebra + sticky head === */
.table tbody tr:nth-child(odd) { background: rgba(0,0,0,0.012); }

/* === Skeleton loading === */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg) 0%, #f0f0f3 50%, var(--bg) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: 6px;
  height: 14px;
}
