/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --info: #0891b2;
  --info-light: #ecfeff;

  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;

  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --sidebar-width: 256px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

/* ===== Auth / Login ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo h1 { font-size: 26px; font-weight: 700; color: var(--primary); }
.auth-logo p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1; padding: 10px; text-align: center; font-size: 14px; font-weight: 500;
  cursor: pointer; border: none; background: none; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s;
}
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== Mobile menu button (hamburger) ===== */
.mobile-menu-btn {
  display: none;
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: var(--text-muted);
  padding: 6px 8px; border-radius: var(--radius);
  transition: all .15s; line-height: 1; flex-shrink: 0;
}
.mobile-menu-btn:hover { background: var(--bg); color: var(--text); }

/* ===== Sidebar backdrop (mobile) ===== */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 99; cursor: pointer;
}
.sidebar-backdrop.open { display: block; }

/* ===== App Layout ===== */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed; top: 0; left: 0; height: 100vh;
  display: flex; flex-direction: column; z-index: 100; overflow-y: auto;
}

.sidebar-header { padding: 20px; border-bottom: 1px solid var(--border); }
.sidebar-logo { font-size: 20px; font-weight: 700; color: var(--primary); }
.sidebar-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .5px; }

.sidebar-nav { flex: 1; padding: 12px; }

.nav-section-title {
  font-size: 11px; font-weight: 600; color: var(--text-light);
  text-transform: uppercase; letter-spacing: .6px;
  padding: 12px 8px 4px;
}

.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: var(--radius); color: var(--text-muted); text-decoration: none;
  font-size: 14px; font-weight: 500; transition: all .15s; cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--primary-light); color: var(--primary); }
.nav-link .icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--text-muted); }

.main-content { margin-left: var(--sidebar-width); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.page-header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 18px 28px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50; gap: 12px;
}
.page-header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-title { font-size: 17px; font-weight: 600; }
.page-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.page-body { padding: 28px; flex: 1; }

/* ===== Cards ===== */
.card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 24px; margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; background: var(--primary); color: white;
  border-radius: 50%; font-size: 12px; font-weight: 700; flex-shrink: 0;
}

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 5px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; color: var(--text);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
  outline: none; font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
textarea { resize: vertical; min-height: 88px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius); font-size: 14px; font-weight: 500;
  cursor: pointer; border: none; transition: all .15s; text-decoration: none; white-space: nowrap;
  font-family: inherit;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-ghost { background: none; color: var(--text-muted); border: 1px solid transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; }

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center; padding: 3px 9px;
  border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-muted { background: var(--bg); color: var(--text-muted); }

/* Task status */
.status-terminada { background: #dcfce7; color: #15803d; }
.status-en_curso { background: #dbeafe; color: #1d4ed8; }
.status-pendiente { background: #fef9c3; color: #a16207; }
.status-bloqueada { background: #fee2e2; color: #b91c1c; }

/* ===== Task Table ===== */
.task-table { width: 100%; border-collapse: collapse; }
.task-table th {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .4px;
  padding: 8px 10px; text-align: left; border-bottom: 2px solid var(--border);
}
.task-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.task-table td input, .task-table td select { padding: 6px 8px; font-size: 13px; }
.task-table .col-num { width: 36px; text-align: center; color: var(--text-light); font-size: 12px; }
.task-table .col-task { min-width: 180px; }
.task-table .col-req { min-width: 120px; }
.task-table .col-status { width: 150px; }
.task-table .col-comment { min-width: 160px; }
.task-table .col-action { width: 36px; }

.add-task-btn {
  border: 2px dashed var(--border); background: none; color: var(--text-muted);
  padding: 9px; border-radius: var(--radius); cursor: pointer; width: 100%;
  font-size: 13px; transition: all .15s; margin-top: 8px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit;
}
.add-task-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.del-btn {
  background: none; border: none; color: var(--text-light); cursor: pointer;
  padding: 4px 6px; border-radius: 4px; transition: all .15s; font-size: 16px;
}
.del-btn:hover { color: var(--danger); background: var(--danger-light); }

/* ===== Rating Grid ===== */
.rating-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.rating-table th {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .4px;
  padding: 6px 10px; text-align: center; border-bottom: 2px solid var(--border);
}
.rating-table th:first-child { text-align: left; }
.rating-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.rating-table td:not(:first-child) { text-align: center; }
.rating-table tr:last-child td { border-bottom: none; }
.rating-table .dim-label { font-size: 14px; color: var(--text); }
.rating-table .col-rating { width: 95px; }
.rating-table .col-notes { width: 160px; }

.rating-radio { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }
.rating-table .col-notes input { font-size: 13px; width: 100%; }

/* Rating header colors */
.th-excellent { color: var(--success) !important; }
.th-tres-bon { color: #1d4ed8 !important; }
.th-satisfaisant { color: var(--warning) !important; }
.th-insatisfaisant { color: var(--danger) !important; }

/* ===== Friction Signals ===== */
.signal-table { width: 100%; border-collapse: collapse; }
.signal-table th {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .4px;
  padding: 8px 12px; text-align: left; border-bottom: 2px solid var(--border);
}
.signal-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.signal-table tr:last-child td { border-bottom: none; }
.signal-label { font-size: 14px; }
.signal-toggle { display: flex; align-items: center; justify-content: center; gap: 16px; }
.toggle-opt { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; cursor: pointer; }
.toggle-opt input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.signal-desc { min-width: 200px; }
.signal-desc input { font-size: 13px; }

/* ===== Form Actions Bar ===== */
.form-actions {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 14px 28px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; bottom: 0; z-index: 50; gap: 12px;
}
.form-actions-left { display: flex; align-items: center; gap: 12px; }
.form-actions-right { display: flex; gap: 10px; }

/* ===== Stats Cards ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 20px; box-shadow: var(--shadow-sm); }
.stat-value { font-size: 30px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 6px; }
.stat-icon { font-size: 20px; margin-bottom: 8px; }

/* ===== Data Table ===== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .4px;
  padding: 10px 14px; text-align: left; border-bottom: 2px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover { background: var(--bg); cursor: pointer; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ===== Alerts ===== */
.alert {
  padding: 12px 16px; border-radius: var(--radius); font-size: 14px;
  margin-bottom: 16px; display: flex; align-items: flex-start; gap: 10px;
}
.alert-error { background: var(--danger-light); color: var(--danger); border-left: 3px solid var(--danger); }
.alert-success { background: var(--success-light); color: var(--success); border-left: 3px solid var(--success); }
.alert-info { background: var(--primary-light); color: var(--primary); border-left: 3px solid var(--primary); }
.alert-warning { background: var(--warning-light); color: var(--warning); border-left: 3px solid var(--warning); }

/* ===== Submission History Cards ===== */
.submission-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 22px; margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; transition: all .15s; box-shadow: var(--shadow-sm);
  text-decoration: none; color: inherit;
}
.submission-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.submission-month { font-size: 16px; font-weight: 600; }
.submission-date { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ===== Admin Score Bar ===== */
.score-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.score-bar-label { font-size: 13px; width: 240px; flex-shrink: 0; line-height: 1.3; }
.score-bar-track { flex: 1; height: 20px; background: var(--bg); border-radius: 4px; overflow: hidden; display: flex; }
.score-bar-seg { height: 100%; transition: width .4s; }
.seg-excellent { background: var(--success); }
.seg-tres_bon { background: #3b82f6; }
.seg-satisfaisant { background: var(--warning); }
.seg-insatisfaisant { background: var(--danger); }
.score-bar-legend { display: flex; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 300; padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 28px; width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg); position: relative;
}
.modal-title { font-size: 17px; font-weight: 600; margin-bottom: 16px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 24px; }

/* ===== Loading ===== */
.loading-screen {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  flex-direction: column; gap: 12px;
}
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Toast ===== */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 500;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: #1e293b; color: white; padding: 11px 16px;
  border-radius: var(--radius); font-size: 14px; box-shadow: var(--shadow-lg);
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  animation: slideUp .2s ease; max-width: 320px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-icon { font-size: 44px; margin-bottom: 12px; opacity: .5; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }

/* ===== Filter Bar ===== */
.filter-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-bar select, .filter-bar input { width: auto; }

/* ===== Detail View ===== */
.detail-section-title {
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px;
  margin: 20px 0 10px;
}
.detail-rating-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.detail-rating-row:last-child { border-bottom: none; }
.rating-chip { padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.chip-excellent { background: var(--success-light); color: var(--success); }
.chip-tres_bon { background: #dbeafe; color: #1d4ed8; }
.chip-satisfaisant { background: var(--warning-light); color: var(--warning); }
.chip-insatisfaisant { background: var(--danger-light); color: var(--danger); }
.chip-na { background: var(--bg); color: var(--text-muted); }

/* ===== Misc Utilities ===== */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
hr.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

@media (max-width: 768px) {
  /* Sidebar */
  .sidebar { transform: translateX(-100%); transition: transform .3s; z-index: 100; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-menu-btn { display: inline-flex; align-items: center; justify-content: center; }

  /* Layout */
  .page-body { padding: 16px; }
  .page-header { padding: 12px 16px; flex-wrap: wrap; }
  .page-header > .flex { flex-shrink: 0; }

  /* Auth card */
  .auth-card { padding: 28px 20px; margin: 16px; max-width: calc(100% - 32px); }

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

  /* Tables */
  .rating-table, .signal-table { font-size: 13px; }

  /* Score bars */
  .score-bar-label { width: 130px; font-size: 12px; }

  /* Form actions bar */
  .form-actions { padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
  .form-actions-left { width: 100%; }
  .form-actions-right { width: 100%; justify-content: flex-end; }

  /* Modals */
  .modal-overlay { padding: 16px; }
  .modal { padding: 20px 16px; }
}
