/* ============================================
   LATIFI GROUP — GESTION DE PAIE
   Style v1.0 — Design: Industriel/Précis
   ============================================ */

:root {
  --bg: #f4f6fa;
  --bg2: #ffffff;
  --bg3: #eef1f7;
  --border: #dde2ee;
  --border-light: #c8d0e0;
  --text: #1a1e2e;
  --text-muted: #6b7590;
  --text-dim: #a0abc0;
  --accent: #1a6abf;
  --accent-dim: rgba(26,106,191,0.12);
  --accent-hover: #2279d9;
  --green: #22c55e;
  --green-dim: rgba(34,197,94,0.12);
  --red: #ef4444;
  --red-dim: rgba(239,68,68,0.12);
  --blue: #3b82f6;
  --blue-dim: rgba(59,130,246,0.12);
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --font: 'IBM Plex Sans Arabic', sans-serif;
  --mono: 'IBM Plex Mono', monospace;
  --radius: 8px;
  --shadow: 0 4px 24px rgba(100,120,180,0.12);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

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

.hidden { display: none !important; }

/* ============================================
   LOGIN
   ============================================ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
}

.login-bg-pattern {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.6;
  pointer-events: none;
}

.login-card {
  position: relative;
  z-index: 1;
  width: 380px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  box-shadow: var(--shadow), 0 0 60px rgba(26,106,191,0.08);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 36px;
}

.logo-mark {
  width: 48px;
  height: 48px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  letter-spacing: 1px;
  font-family: var(--mono);
}

.brand-name {
  display: block;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--text);
}

.brand-sub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
}
.field-group input,
.field-group select,
.field-group textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color 0.2s;
  outline: none;
}
.field-group input:focus,
.field-group select:focus {
  border-color: var(--accent);
}
.field-group select option { background: var(--bg2); color: var(--text); }

.login-error {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  text-align: center;
}

.btn-login {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  border: none;
  padding: 12px;
  border-radius: var(--radius);
  font-size: 14px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-top: 4px;
}
.btn-login:hover { background: var(--accent-hover); }
.btn-login:active { transform: scale(0.98); }

.login-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 28px;
  font-family: var(--mono);
}

/* ============================================
   APP LAYOUT
   ============================================ */
.app {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark-sm {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-family: var(--mono);
  flex-shrink: 0;
}

.sidebar-brand {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--text);
}
.sidebar-sub {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.nav-item:hover {
  color: var(--text);
  background: var(--bg3);
}
.nav-item.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: rgba(26,106,191,0.2);
  font-weight: 600;
}
.nav-icon {
  font-size: 12px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}
.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s;
}
.btn-logout:hover {
  border-color: var(--red);
  color: var(--red);
}

/* MAIN CONTENT */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* TOPBAR */
.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.page-breadcrumb {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.week-badge {
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-muted);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 5px 12px 5px 6px;
  border-radius: 20px;
}
.user-avatar {
  width: 26px;
  height: 26px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* MODULE CONTAINER */
.module-container {
  flex: 1;
  padding: 28px;
}

.module { display: none; }
.module.active { display: block; animation: fadeIn 0.2s ease; }

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

/* ============================================
   DASHBOARD
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--border-light); }
.stat-card.accent {
  border-color: rgba(26,106,191,0.3);
  background: linear-gradient(135deg, var(--bg2), var(--accent-dim));
}
.stat-card.dark {
  background: var(--bg3);
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
}
.stat-card.dark .stat-value { color: var(--text); }
.stat-sub {
  font-size: 11px;
  color: var(--text-dim);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.dash-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.panel-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.worker-mini-list { display: flex; flex-direction: column; gap: 8px; }
.worker-mini-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg3);
  border-radius: 6px;
  font-size: 13px;
}
.worker-mini-salary {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
}

.attendance-mini { display: flex; flex-direction: column; gap: 6px; }
.att-mini-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
.att-mini-bar {
  flex: 1;
  margin: 0 12px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.att-mini-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}
.att-mini-days {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  width: 40px;
  text-align: right;
}

/* ============================================
   TOOLBAR & BUTTONS
   ============================================ */
.module-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  width: 280px;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--accent); }

.week-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.week-selector label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: transparent;
  color: var(--text);
  font-weight: 600;
  border: 1px solid var(--border);
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--border-light); background: var(--bg3); }

.btn-export {
  background: var(--bg3);
  color: var(--text);
  font-weight: 600;
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-export:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
  background: var(--red);
  color: #fff;
  font-weight: 700;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
}
.btn-danger:hover { opacity: 0.85; }

.btn-icon {
  background: var(--bg3);
  color: var(--text-muted);
  border: 1px solid var(--border);
  width: 30px;
  height: 30px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.btn-icon:hover { color: var(--text); border-color: var(--border-light); }
.btn-icon.del:hover { color: var(--red); border-color: var(--red); }

/* ============================================
   TABLES
   ============================================ */
.table-wrapper {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
}

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

.data-table thead tr {
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}
.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg3); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.badge-green { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,197,94,0.25); }
.badge-red { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.25); }
.badge-yellow { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(26,106,191,0.25); }
.badge-blue { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(59,130,246,0.25); }

.td-mono {
  font-family: var(--mono);
  font-size: 13px;
}
.td-name { font-weight: 600; }

/* CHECKBOXES IN ATTENDANCE */
.att-check {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ATTENDANCE TOTALS */
.att-totals {
  margin-top: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}
.att-total-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.att-total-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.att-total-val {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--accent);
}

/* PAYROLL TOTAL */
.payroll-total {
  margin-top: 16px;
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
}
.payroll-total-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.payroll-total-amount {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--accent);
}

/* ============================================
   SUMMARY
   ============================================ */
.summary-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.summary-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.summary-header {
  background: var(--bg3);
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.summary-row:last-child { border-bottom: none; }
.summary-row-total {
  background: var(--accent-dim);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(26,106,191,0.2);
}
.summary-total-label {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
}
.summary-total-amount {
  font-size: 32px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--accent);
}
.summary-amount {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--text);
}
.finance-note {
  background: var(--bg3);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
}

/* ============================================
   HISTORY
   ============================================ */
.history-content { display: flex; flex-direction: column; gap: 20px; }
.history-worker-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.history-worker-header {
  background: var(--bg3);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.history-worker-name {
  font-weight: 700;
  font-size: 14px;
}
.history-worker-total {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}
.history-week-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.history-week-row:last-child { border-bottom: none; }
.history-week-label { color: var(--text-muted); font-family: var(--mono); font-size: 12px; }
.history-week-amount { font-family: var(--mono); font-weight: 600; }

/* ============================================
   SETTINGS
   ============================================ */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.settings-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings-msg {
  margin-top: 12px;
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(34,197,94,0.3);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  display: inline-block;
}

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(100,110,140,0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  width: 440px;
  max-width: 100%;
  box-shadow: var(--shadow);
  animation: modalIn 0.2s ease;
}

.modal-sm { width: 360px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s;
}
.modal-close:hover { color: var(--text); background: var(--bg3); }

.modal-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-body p { font-size: 14px; color: var(--text); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
}

/* ============================================
   TOAST
   ============================================ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  background: var(--bg3);
  border: 1px solid var(--border-light);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  max-width: 320px;
}
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }

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

/* ============================================
   PRINT / PDF STYLES
   ============================================ */
@media print {
  .sidebar, .topbar, .module-toolbar, .btn-primary,
  .btn-export, .btn-icon, .btn-logout { display: none !important; }
  .main-content { margin-left: 0; }
  body { background: white; color: black; }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
}
.login-logo-img{
    width:70px;
    height:70px;
    object-fit:contain;
}

.sidebar-logo-img{
    width:45px;
    height:45px;
    object-fit:contain;
    background:white;
    border-radius:8px;
    padding:3px;
}
.edit{
    background:#2563eb;
    color:white;
    padding:6px 10px;
    border-radius:8px;
    text-decoration:none;
    margin-right:5px;
}

.del{
    background:#dc2626;
    color:white;
    padding:6px 10px;
    border-radius:8px;
    text-decoration:none;
}
.history{
    background:#16a34a;
    color:white;
    padding:6px 10px;
    border-radius:8px;
    text-decoration:none;
    margin-right:5px;
}
.btn-primary,
.btn-danger{
    display:inline-block;
    margin-right:10px;
}
.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--accent);
  padding: 4px 8px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 99;
}

.sidebar-overlay.active {
  display: block;
}

@media (max-width: 800px) {
  .hamburger {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 100;
  }

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

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

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

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

