/* ============================================================
   TRAVAUX — Stylesheet principal
   Aesthetic: Organic / Natural / Earthy — Convivial & Mobile-first
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800;900&family=Playfair+Display:wght@700;800&display=swap');

:root {
  --primary:    #2d6a4f;
  --secondary:  #40916c;
  --accent:     #95d5b2;
  --bg:         #f0faf5;
  --bg2:        #e8f5ee;
  --surface:    #ffffff;
  --text:       #1b2d23;
  --text-muted: #5a7a65;
  --link:       #1b4332;
  --title:      #081c15;
  --border:     #b7e4c7;
  --shadow:     rgba(45,106,79,0.12);
  --radius:     14px;
  --radius-sm:  8px;
  --font-body:  'Nunito', sans-serif;
  --font-title: 'Playfair Display', serif;

  /* Status colors */
  --c-pending:    #6c757d;
  --c-inprogress: #fd7e14;
  --c-done:       #198754;
  --c-claim:      #0d6efd;
  --c-rejected:   #dc3545;
  --c-impossible: #6f42c1;
}

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

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   BACKGROUND PATTERN
   ============================================================ */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(149,213,178,0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(45,106,79,0.08) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ============================================================
   TOPBAR / NAV
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  background: linear-gradient(135deg, var(--title) 0%, var(--primary) 100%);
  color: #fff;
  padding: 0 16px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 16px rgba(8,28,21,0.3);
}
.topbar-brand {
  font-family: var(--font-title);
  font-size: 1.15rem;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.01em;
}
.topbar-brand .org-icon {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.18);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }

.topbar-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  padding: 6px 12px;
  border-radius: 20px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: flex; align-items: center; gap: 5px;
  transition: background 0.2s, transform 0.15s;
}
.topbar-btn:hover { background: rgba(255,255,255,0.25); transform: translateY(-1px); }
.topbar-btn.active { background: rgba(255,255,255,0.3); }

.badge-notif {
  background: #ff6b6b;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 2px;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.page-content {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}

.page-title {
  font-family: var(--font-title);
  font-size: 1.6rem;
  color: var(--title);
  margin-bottom: 4px;
}
.page-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 20px; }

/* ============================================================
   SECTION HEADERS
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 24px 0 12px;
}
.section-header h2 {
  font-family: var(--font-title);
  font-size: 1.2rem;
  color: var(--title);
}
.section-divider {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--border), transparent);
}

/* ============================================================
   WORKER PROFILES GRID
   ============================================================ */
.profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 12px 6px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 2px solid transparent;
  box-shadow: 0 2px 8px var(--shadow);
  transition: all 0.22s ease;
  text-align: center;
}
.profile-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px var(--shadow);
}
.profile-card.selected { border-color: var(--secondary); background: var(--bg2); }

.profile-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
  transition: border-color 0.2s;
}
.profile-avatar-placeholder {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 1.3rem;
  color: #fff;
  border: 3px solid rgba(255,255,255,0.4);
  flex-shrink: 0;
}
.profile-card:hover .profile-avatar { border-color: var(--secondary); }

.profile-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
}

/* ============================================================
   LOGIN MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8,28,21,0.65);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 16px 48px rgba(8,28,21,0.3);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:none; } }

.modal-user-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.modal-user-header .modal-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
}
.modal-user-header h3 {
  font-family: var(--font-title);
  font-size: 1.1rem;
  color: var(--title);
}
.modal-user-header p { font-size: 0.8rem; color: var(--text-muted); }

.modal-title {
  font-family: var(--font-title);
  font-size: 1.15rem;
  color: var(--title);
  margin-bottom: 16px;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-control:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(64,145,108,0.15);
}
.form-control.error { border-color: var(--c-rejected); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 24px;
  border: none;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  letter-spacing: 0.01em;
}
.btn:active { transform: scale(0.97); }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--secondary); box-shadow: 0 4px 14px rgba(45,106,79,0.35); }
.btn-secondary { background: var(--bg2); color: var(--primary); border: 2px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger    { background: var(--c-rejected); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; border-radius: 16px; }
.btn-full { width: 100%; }
.btn-icon { padding: 8px; border-radius: 50%; min-width: 36px; min-height: 36px; }

/* ============================================================
   TASK CARDS
   ============================================================ */
.tasks-section { margin-bottom: 10px; }

.task-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px var(--shadow);
  border-left: 4px solid var(--accent);
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
  position: relative;
  overflow: hidden;
}
.task-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 0.2s;
}
.task-card:hover {
  transform: translateX(3px);
  box-shadow: 0 6px 20px var(--shadow);
}
.task-card.indicative { opacity: 0.75; cursor: default; }
.task-card.indicative:hover { transform: none; }

/* Status borders */
.task-card.status-pending     { border-left-color: var(--c-pending); }
.task-card.status-in_progress { border-left-color: var(--c-inprogress); }
.task-card.status-done        { border-left-color: var(--c-done); opacity: 0.8; }
.task-card.status-claim       { border-left-color: var(--c-claim); }
.task-card.status-rejected    { border-left-color: var(--c-rejected); }
.task-card.status-impossible  { border-left-color: var(--c-impossible); }

.task-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.task-card-title {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--title);
  line-height: 1.3;
  flex: 1;
}
.task-card-title.done-title { text-decoration: line-through; opacity: 0.6; }

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.task-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}
.task-meta-item svg { flex-shrink: 0; }

.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.task-badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
  color: #fff;
  white-space: nowrap;
}

.info-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  color: var(--text-muted);
  line-height: 1;
}
.info-btn:hover { color: var(--secondary); }

/* ============================================================
   TASK DETAIL MODAL
   ============================================================ */
.task-detail-modal .modal-box { max-width: 440px; }

.status-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}
.status-btn {
  padding: 9px 10px;
  border-radius: 10px;
  border: 2px solid transparent;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.18s;
}
.status-btn:hover { opacity: 0.85; transform: translateY(-1px); }
.status-btn.active { border-color: currentColor; box-shadow: 0 0 0 3px currentColor inset; }

/* ============================================================
   STATS / SUMMARY CARDS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  text-align: center;
  box-shadow: 0 2px 8px var(--shadow);
  border-top: 3px solid var(--accent);
}
.stat-card.primary { border-top-color: var(--primary); }
.stat-card.accent  { border-top-color: var(--c-inprogress); }
.stat-value {
  font-family: var(--font-title);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--title);
  line-height: 1.1;
}
.stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 3px;
}

/* Progress bar */
.progress-bar-wrap {
  background: var(--bg2);
  border-radius: 10px;
  height: 8px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-bar {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(to right, var(--secondary), var(--accent));
  transition: width 0.6s ease;
}

/* ============================================================
   CHART CONTAINER
   ============================================================ */
.chart-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 2px 8px var(--shadow);
  margin-bottom: 12px;
}
.chart-wrap h3 {
  font-family: var(--font-title);
  font-size: 1rem;
  color: var(--title);
  margin-bottom: 12px;
}
canvas { max-width: 100%; }

/* ============================================================
   SUPERVISOR / ADMIN TABLES
   ============================================================ */
.data-table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table th {
  background: var(--primary);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--bg2);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }
.data-table tfoot td { background: var(--bg2); font-weight: 700; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 2px 8px var(--shadow);
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.filter-bar .form-group { margin-bottom: 0; min-width: 130px; flex: 1; }

/* ============================================================
   TABS
   ============================================================ */
.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--bg2);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 16px;
}
.tab-btn {
  flex: 1;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: 9px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.tab-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 2px 8px var(--shadow);
}

/* ============================================================
   MESSAGES
   ============================================================ */
.message-item {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  border-left: 3px solid var(--accent);
  box-shadow: 0 2px 6px var(--shadow);
}
.message-item.unread { border-left-color: var(--c-inprogress); background: #fff9f0; }
.message-from { font-weight: 700; font-size: 0.85rem; color: var(--title); }
.message-body { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }
.message-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }

/* ============================================================
   LANG TOGGLE
   ============================================================ */
.lang-toggle {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 16px;
  display: flex;
  overflow: hidden;
}
.lang-btn {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.15s;
}
.lang-btn.active { background: rgba(255,255,255,0.3); color: #fff; }

/* ============================================================
   COLOR SWATCH
   ============================================================ */
input[type="color"] {
  width: 44px; height: 36px;
  padding: 2px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
}

/* ============================================================
   ALERTS / TOASTS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(8,28,21,0.3);
  animation: toastIn 0.3s ease forwards;
  pointer-events: all;
}
.toast.error { background: var(--c-rejected); }
.toast.success { background: var(--c-done); }
@keyframes toastIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:none; } }
@keyframes toastOut { to { opacity:0; transform:translateY(10px); } }

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--secondary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-center {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 20px;
  color: var(--text-muted);
  gap: 10px;
  font-size: 0.88rem;
}

/* ============================================================
   DASHBOARD OBJECTIVE ROW
   ============================================================ */
.objective-row {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px var(--shadow);
}
.obj-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.obj-name { font-weight: 700; font-size: 0.9rem; color: var(--title); }
.obj-pct { font-size: 0.85rem; font-weight: 800; color: var(--secondary); }

/* ============================================================
   ADMIN NAV CARDS
   ============================================================ */
.admin-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.admin-nav-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--shadow);
  border: 2px solid transparent;
  text-decoration: none;
  color: var(--title);
  transition: all 0.2s;
}
.admin-nav-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.admin-nav-card.active { border-color: var(--primary); background: var(--bg2); }
.admin-nav-icon { font-size: 2rem; margin-bottom: 8px; }
.admin-nav-label { font-weight: 700; font-size: 0.85rem; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 10px; }
.empty-state p { font-size: 0.9rem; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
  .profiles-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }
  .profile-avatar, .profile-avatar-placeholder { width: 52px; height: 52px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-value { font-size: 1.1rem; }
  .filter-bar { flex-direction: column; }
  .filter-bar .form-group { min-width: 100%; }
  .form-row { flex-direction: column; }
  .status-actions { grid-template-columns: 1fr 1fr; }
  .data-table { font-size: 0.78rem; }
  .data-table th, .data-table td { padding: 7px 8px; }
  .admin-nav-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 360px) {
  .profiles-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .topbar, .no-print { display: none !important; }
  body { background: #fff; }
  .page-content { padding: 0; max-width: none; }
}
