/* JAC'EM Paie — Refined Financial Ledger */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Source+Sans+3:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Core palette — warm financial tones */
  --primary: #1a1f36;
  --primary-dark: #0f1225;
  --primary-light: #e8eaf0;
  --accent: #b8860b;
  --accent-light: #f5eed9;
  --accent-hover: #9a7209;

  /* Semantic */
  --success: #2d6a4f;
  --success-light: #d8f3dc;
  --warning: #c77c14;
  --warning-light: #fef0d5;
  --danger: #9b2c2c;
  --danger-light: #fde8e8;

  /* Neutrals — warm ivory scale */
  --gray-50: #faf8f5;
  --gray-100: #f3f0eb;
  --gray-200: #e5e1da;
  --gray-300: #d0cbc2;
  --gray-400: #a8a198;
  --gray-500: #7a746b;
  --gray-600: #5c564e;
  --gray-700: #3e3a34;
  --gray-800: #2a2722;
  --gray-900: #1a1814;

  /* System */
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 1px 3px rgba(26,31,54,.07), 0 1px 2px rgba(26,31,54,.04);
  --shadow-md: 0 4px 12px rgba(26,31,54,.08), 0 2px 4px rgba(26,31,54,.04);
  --shadow-lg: 0 12px 28px rgba(26,31,54,.12), 0 4px 10px rgba(26,31,54,.06);
  --bg-body: #f6f3ee;
  --bg-card: #ffffff;
  --border: #e0dbd3;
  --text-primary: #1a1f36;
  --text-secondary: #5c564e;
  --text-muted: #a8a198;

  /* Typography */
  --font-display: 'DM Serif Display', Georgia, 'Times New Roman', serif;
  --font-body: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;

  /* Transitions */
  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* ==========================================
   RESET & BASE
   ========================================== */

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

body {
  font-family: var(--font-body);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--accent-light); color: var(--primary); }

/* Subtle page texture */
body::before {
  content: '';
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d0cbc2' fill-opacity='0.08'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none; z-index: -1;
}

/* ==========================================
   NAVIGATION
   ========================================== */

#nav-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--primary);
  color: #fff; padding: 0 28px; height: 58px;
  position: sticky; top: 0; z-index: 100;
  border-bottom: 2px solid var(--accent);
  /* Subtle diagonal hatching overlay */
  background-image:
    linear-gradient(135deg, rgba(255,255,255,.03) 25%, transparent 25%),
    linear-gradient(225deg, rgba(255,255,255,.03) 25%, transparent 25%),
    linear-gradient(315deg, rgba(255,255,255,.03) 25%, transparent 25%),
    linear-gradient(45deg, rgba(255,255,255,.03) 25%, transparent 25%);
  background-size: 8px 8px;
}

.nav-brand { display: flex; align-items: center; gap: 10px; }
.nav-logo {
  font-family: var(--font-display);
  font-weight: 400; font-size: 22px;
  color: var(--accent);
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.nav-title {
  font-weight: 300; font-size: 14px; color: rgba(255,255,255,.5);
  letter-spacing: 0.15em; text-transform: uppercase;
}

.nav-links { display: flex; gap: 2px; }
.nav-link {
  color: rgba(255,255,255,.65); text-decoration: none; padding: 8px 14px;
  border-radius: var(--radius); font-size: 13px; font-weight: 500;
  letter-spacing: 0.01em;
  transition: all .2s var(--ease);
  position: relative;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active {
  background: rgba(184,134,11,.15);
  color: var(--accent);
  font-weight: 600;
}
.nav-link.active::after {
  content: ''; position: absolute; bottom: -1px; left: 50%; transform: translateX(-50%);
  width: 20px; height: 2px; background: var(--accent); border-radius: 1px;
}

.nav-user { display: flex; align-items: center; gap: 12px; font-size: 12px; color: rgba(255,255,255,.55); }

/* ==========================================
   LOGIN SCREEN
   ========================================== */

.login-box {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  text-align: center; background: var(--bg-card); padding: 56px 48px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: fadeUp .5s var(--ease);
}
.login-box::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--primary), var(--accent));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.login-box h1 {
  font-family: var(--font-display); font-size: 32px; color: var(--primary);
  margin-bottom: 8px; font-weight: 400;
}
.login-box p { color: var(--text-secondary); margin-bottom: 28px; font-size: 15px; }

@keyframes fadeUp {
  from { opacity: 0; transform: translate(-50%, -46%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

/* ==========================================
   BUTTONS
   ========================================== */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card); color: var(--text-primary); font-size: 13px; font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer; transition: all .2s var(--ease); text-decoration: none;
  letter-spacing: 0.01em;
}
.btn:hover { background: var(--gray-50); border-color: var(--gray-400); box-shadow: var(--shadow); }
.btn-primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 2px 8px rgba(26,31,54,.25); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #245a42; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #822525; }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #a86a10; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 13px 28px; font-size: 15px; letter-spacing: 0.02em; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: saturate(.6); }
.btn-icon { padding: 7px; min-width: 32px; justify-content: center; }

/* Accent button (gold) */
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-hover); box-shadow: 0 2px 8px rgba(184,134,11,.3); }

/* ==========================================
   CARDS
   ========================================== */

.card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px; margin-bottom: 16px;
  border: 1px solid var(--border);
  transition: box-shadow .2s var(--ease);
  position: relative;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--gray-100);
}
.card-title {
  font-family: var(--font-display); font-size: 18px; font-weight: 400;
  color: var(--primary); letter-spacing: 0.01em;
}

/* ==========================================
   PAGE LAYOUT
   ========================================== */

#page-container {
  max-width: 1440px; margin: 0 auto; padding: 28px 32px;
  animation: fadeIn .35s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 28px; padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.page-title {
  font-family: var(--font-display); font-size: 26px; font-weight: 400;
  color: var(--primary); letter-spacing: 0.01em;
}
.page-subtitle { font-size: 14px; color: var(--text-muted); margin-top: 2px; }

/* ==========================================
   TABS
   ========================================== */

.tabs {
  display: flex; gap: 0; border-bottom: 2px solid var(--gray-200);
  margin-bottom: 24px; overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 11px 18px; text-decoration: none; color: var(--text-muted);
  font-weight: 500; font-size: 13px; letter-spacing: 0.01em;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  white-space: nowrap; transition: all .25s var(--ease);
  position: relative;
}
.tab:hover {
  color: var(--accent); background: var(--accent-light);
  border-radius: var(--radius) var(--radius) 0 0;
}
.tab.active {
  color: var(--primary); border-bottom-color: var(--accent);
  font-weight: 700;
  background: linear-gradient(to bottom, rgba(184,134,11,.05), transparent);
  border-radius: var(--radius) var(--radius) 0 0;
}

/* ==========================================
   TABLES — Ledger style
   ========================================== */

.table-wrapper { overflow-x: auto; border-radius: var(--radius); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  text-align: left; padding: 11px 14px;
  background: var(--primary);
  color: rgba(255,255,255,.85);
  font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
  white-space: nowrap;
  border-bottom: none;
}
thead th:first-child { border-radius: var(--radius) 0 0 0; }
thead th:last-child { border-radius: 0 var(--radius) 0 0; }

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  transition: background .15s;
}
tbody tr:hover { background: var(--accent-light); }
tbody tr:nth-child(even) { background: rgba(240,236,228,.35); }
tbody tr:nth-child(even):hover { background: var(--accent-light); }
tbody tr:last-child td { border-bottom: none; }

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-mono {
  font-family: var(--font-mono); font-size: 12px;
  font-feature-settings: 'tnum' 1; /* tabular numbers */
}

/* ==========================================
   INPUTS & FORMS
   ========================================== */

input[type="text"], input[type="number"], input[type="date"], input[type="email"],
input[type="password"], select, textarea {
  width: 100%; padding: 9px 13px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px;
  font-family: var(--font-body);
  background: var(--bg-card); color: var(--text-primary);
  transition: all .2s var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184,134,11,.12);
}
input.input-sm { width: 80px; padding: 5px 8px; font-size: 12px; text-align: right; font-family: var(--font-mono); }
input.input-xs { width: 60px; padding: 4px 6px; font-size: 11px; text-align: right; font-family: var(--font-mono); }

textarea { resize: vertical; min-height: 60px; }

.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 5px;
  letter-spacing: 0.03em; text-transform: uppercase;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Checkbox styling */
input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--accent);
  cursor: pointer; vertical-align: middle;
}

/* ==========================================
   BADGES
   ========================================== */

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 4px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  line-height: 1.4;
}
.badge-brouillon { background: var(--gray-100); color: var(--gray-600); border: 1px solid var(--gray-200); }
.badge-valide { background: var(--success-light); color: var(--success); border: 1px solid #a7d7b8; }
.badge-cloture { background: var(--primary-light); color: var(--primary); border: 1px solid #c4c8d4; }
.badge-definitif { background: #4a235a; color: #fff; border: 1px solid #6c3483; font-weight: 700; }
.badge-stc { background: var(--warning-light); color: var(--warning); border: 1px solid #e8d5a8; }
.badge-info { background: #e0eafc; color: #2c5282; border: 1px solid #b4cde8; }
.badge-success { background: var(--success-light); color: var(--success); border: 1px solid #a7d7b8; }
.badge-warning { background: var(--warning-light); color: var(--warning); border: 1px solid #e8d5a8; }
.badge-danger { background: var(--danger-light); color: var(--danger); border: 1px solid #e8b4b4; }
.badge-non_commence { background: var(--gray-100); color: var(--gray-500); border: 1px solid var(--gray-200); }

/* ==========================================
   STAT CARDS
   ========================================== */

.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px 20px; text-align: left;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.stat-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--accent);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}
.stat-value {
  font-family: var(--font-mono); font-size: 26px; font-weight: 600;
  color: var(--primary);
  font-feature-settings: 'tnum' 1;
  margin-bottom: 2px;
}
.stat-label {
  font-size: 12px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500;
}
.stat-card.success::before { background: var(--success); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.danger .stat-value { color: var(--danger); }

/* ==========================================
   MONTH SELECTOR
   ========================================== */

.month-selector {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.month-selector select { width: auto; min-width: 120px; }
.month-selector .btn { white-space: nowrap; }

/* ==========================================
   ALERT & STATUS ICONS
   ========================================== */

.icon-warning { color: var(--warning); cursor: help; }
.icon-stc { color: var(--danger); cursor: help; font-size: 16px; }

/* ==========================================
   MODAL
   ========================================== */

.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(26,31,54,.55);
  backdrop-filter: blur(4px);
  z-index: 200; display: flex;
  align-items: center; justify-content: center;
  animation: fadeIn .2s var(--ease);
}
.modal {
  background: var(--bg-card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%; max-width: 680px; max-height: 90vh; overflow-y: auto;
  border: 1px solid var(--border);
  animation: modalIn .3s var(--ease);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--gray-200);
}
.modal-title {
  font-family: var(--font-display); font-size: 18px; font-weight: 400;
  color: var(--primary);
}
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--gray-200);
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ==========================================
   TOAST NOTIFICATIONS
   ========================================== */

#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 14px 22px; border-radius: var(--radius);
  color: #fff; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: toastIn .4s var(--ease);
  min-width: 300px;
  border-left: 4px solid rgba(255,255,255,.4);
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }

@keyframes toastIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================
   LOADING & SPINNER
   ========================================== */

.spinner {
  display: inline-block; width: 22px; height: 22px;
  border: 2px solid var(--gray-200); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { display: flex; align-items: center; justify-content: center; padding: 48px; }

/* ==========================================
   TOOLTIP
   ========================================== */

[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip); position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: var(--primary); color: #fff;
  padding: 5px 10px; border-radius: var(--radius); font-size: 11px;
  white-space: nowrap; z-index: 50;
  box-shadow: var(--shadow);
  animation: tooltipIn .15s var(--ease);
}
@keyframes tooltipIn { from { opacity: 0; transform: translateX(-50%) translateY(4px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ==========================================
   TOGGLE SWITCH
   ========================================== */

.toggle-switch { position: relative; display: inline-block; width: 38px; height: 21px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--gray-300); transition: .3s var(--ease); border-radius: 21px;
}
.toggle-slider::before {
  content: ''; position: absolute; height: 15px; width: 15px; left: 3px; bottom: 3px;
  background: #fff; transition: .3s var(--ease); border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-slider { background-color: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(17px); }

/* ==========================================
   UTILITY — SCROLLBAR
   ========================================== */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ==========================================
   PROGRESS BAR (for saisie salaire)
   ========================================== */

.progress-bar {
  background: var(--gray-200); border-radius: 4px; height: 20px;
  width: 120px; position: relative; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), #d4a843);
  transition: width .5s var(--ease);
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 768px) {
  .nav-links { display: none; }
  #page-container { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 22px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  #nav-bar { padding: 0 16px; }
  .nav-logo { font-size: 18px; }
}

/* ==========================================
   CARD VARIANTS — accent borders
   ========================================== */

.card[style*="border-left:4px solid var(--primary)"],
.card[style*="border-left: 4px solid var(--primary)"] {
  border-left-color: var(--accent) !important;
  background: linear-gradient(90deg, rgba(184,134,11,.03), transparent 40%);
}
.card[style*="border-left:4px solid var(--warning)"],
.card[style*="border-left: 4px solid var(--warning)"] {
  background: linear-gradient(90deg, rgba(199,124,20,.04), transparent 40%);
}

/* ==========================================
   PAGE TRANSITIONS
   ========================================== */

#page-container > * {
  animation: staggerIn .4s var(--ease) both;
}
#page-container > *:nth-child(1) { animation-delay: 0s; }
#page-container > *:nth-child(2) { animation-delay: .05s; }
#page-container > *:nth-child(3) { animation-delay: .1s; }
#page-container > *:nth-child(4) { animation-delay: .15s; }
#page-container > *:nth-child(5) { animation-delay: .2s; }

@keyframes staggerIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================
   PRINT STYLES
   ========================================== */

/* Journal tables */
.total-row { background: var(--bg-alt, #f8f9fa); border-top: 2px solid var(--border, #dee2e6); }
.total-row td { font-weight: 600; }
.print-table { width: 100%; font-size: 13px; }
.print-table th { font-size: 12px; white-space: nowrap; }

@media print {
  #nav-bar, #toast-container, .btn, .tabs, .page-header select { display: none !important; }
  body { background: #fff; }
  body::before { display: none; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  #page-container { max-width: none; padding: 0; }
  .print-table { font-size: 11px; }
  .print-table th, .print-table td { padding: 3px 6px; }
}
