/* ===== NosyBe Connect — Apporteur Dashboard ===== */
:root {
  --dark: #0D3349;
  --teal: #028090;
  --mint: #02C39A;
  --sand: #F4E9D8;
  --white: #FFFFFF;
  --grey: #64748B;
  --light: #F1F5F9;
  --gold: #F59E0B;
  --red: #EF4444;
  --green: #10B981;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--light);
  color: #1e293b;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); text-decoration: none; }

/* === LOGIN === */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--dark) 0%, var(--teal) 100%);
  padding: 20px;
}
.login-box {
  background: var(--white);
  border-radius: 16px;
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-box h1 {
  font-size: 24px;
  color: var(--dark);
  text-align: center;
  margin-bottom: 4px;
}
.login-box .subtitle {
  text-align: center;
  color: var(--grey);
  font-size: 14px;
  margin-bottom: 32px;
}
.login-logo {
  text-align: center;
  margin-bottom: 24px;
  font-size: 32px;
  font-weight: 800;
  color: var(--mint);
}
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 15px;
  transition: border-color 0.2s;
  background: var(--white);
  color: #1e293b;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--teal);
}
.form-group textarea {
  resize: vertical;
  min-height: 80px;
}
.pin-input {
  letter-spacing: 12px;
  text-align: center;
  font-size: 24px !important;
  font-weight: 700;
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
  text-align: center;
}
.btn-primary { background: var(--mint); color: var(--dark); }
.btn-primary:hover { background: #01a77e; }
.btn-teal { background: var(--teal); color: var(--white); }
.btn-teal:hover { background: #016d7a; }
.btn-dark { background: var(--dark); color: var(--white); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #dc2626; }
.btn-gold { background: var(--gold); color: var(--dark); }
.btn-outline {
  background: transparent;
  border: 2px solid var(--teal);
  color: var(--teal);
}
.btn-outline:hover { background: var(--teal); color: var(--white); }
.btn-sm { padding: 8px 14px; font-size: 13px; min-height: 36px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === LAYOUT === */
.app-header {
  background: var(--dark);
  color: var(--white);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header h1 {
  font-size: 16px;
  font-weight: 700;
}
.app-header .user-name {
  font-size: 13px;
  color: var(--mint);
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.btn-logout {
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--white);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.app-content {
  padding: 16px;
  padding-bottom: 80px;
  max-width: 800px;
  margin: 0 auto;
}

/* === TAB NAV (mobile bottom) === */
.tab-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--dark);
  display: flex;
  justify-content: space-around;
  padding: 6px 0;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.tab-nav button {
  background: none;
  border: none;
  color: var(--grey);
  font-size: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: color 0.2s;
  position: relative;
  min-width: 50px;
}
.tab-nav button .tab-icon { font-size: 20px; }
.tab-nav button.active { color: var(--mint); }
.tab-nav button:hover { color: var(--mint); }
.tab-badge {
  position: absolute;
  top: 0;
  right: 4px;
  background: var(--red);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* === TAB PANELS === */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* === CARDS === */
.card {
  background: var(--white);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
}

/* === STATS GRID === */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--white);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--teal);
  line-height: 1.2;
}
.stat-value.mint { color: var(--mint); }
.stat-value.gold { color: var(--gold); }
.stat-value.red { color: var(--red); }
.stat-label {
  font-size: 12px;
  color: var(--grey);
  margin-top: 4px;
}

/* === PROGRESS BAR === */
.progress-container {
  background: var(--white);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
}
.progress-bar {
  background: #e2e8f0;
  border-radius: 8px;
  height: 10px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--teal), var(--mint));
  transition: width 0.5s ease;
}
.progress-footer {
  font-size: 12px;
  color: var(--grey);
  margin-top: 6px;
}

/* === BADGES === */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-green { background: #d1fae5; color: #065f46; }
.badge-gold { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-teal { background: #ccfbf1; color: #134e4a; }
.badge-dark { background: #e2e8f0; color: var(--dark); }
.badge-mint { background: #d1fae5; color: #047857; }

.badge-n1 { background: var(--teal); color: var(--white); }
.badge-n2 { background: var(--dark); color: var(--white); }
.badge-n3 { background: var(--mint); color: var(--dark); }

/* === ALERTS === */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-red { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--red); }
.alert-gold { background: #fef3c7; color: #92400e; border-left: 4px solid var(--gold); }
.alert-green { background: #d1fae5; color: #065f46; border-left: 4px solid var(--green); }

/* === TABLE === */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  padding: 10px 12px;
  background: var(--light);
  font-weight: 700;
  color: var(--dark);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
tr:hover td { background: #f8fafc; }

/* === LISTS === */
.list-item {
  background: var(--white);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.list-item.expired { opacity: 0.5; }
.list-item.resilie { opacity: 0.4; }
.list-item-info { flex: 1; }
.list-item-title { font-weight: 700; font-size: 14px; color: var(--dark); }
.list-item-sub { font-size: 12px; color: var(--grey); margin-top: 2px; }
.list-item-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* === COUNTDOWN === */
.countdown {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
}
.countdown.danger { background: #fee2e2; color: #991b1b; }
.countdown.warning { background: #fef3c7; color: #92400e; }
.countdown.ok { background: #d1fae5; color: #065f46; }

/* === MESSAGING === */
.message-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 8px;
  max-width: 85%;
  font-size: 14px;
  line-height: 1.5;
}
.message-bubble.admin {
  background: var(--light);
  color: var(--dark);
  margin-right: auto;
  border-bottom-left-radius: 4px;
}
.message-bubble.apporteur {
  background: var(--teal);
  color: var(--white);
  margin-left: auto;
  border-bottom-right-radius: 4px;
}
.message-meta {
  font-size: 11px;
  color: var(--grey);
  margin-top: 4px;
}
.message-type-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  margin-bottom: 6px;
  display: inline-block;
}

/* === TOAST === */
.toast-container {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: 10px;
  color: var(--white);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  max-width: 320px;
}
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.toast-info { background: var(--teal); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-10px); }
}

/* === LOADER === */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.loader::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === MODAL === */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--white);
  border-radius: 16px 16px 0 0;
  padding: 24px;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal h2 {
  font-size: 18px;
  margin-bottom: 16px;
  color: var(--dark);
}
.modal-close {
  float: right;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--grey);
}

/* === NEWS ITEM === */
.news-item {
  background: var(--white);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.news-item.important { border-left: 4px solid var(--red); }
.news-item h3 { font-size: 15px; color: var(--dark); margin-bottom: 6px; }
.news-item p { font-size: 13px; color: #475569; line-height: 1.6; }
.news-date { font-size: 11px; color: var(--grey); margin-top: 8px; }

/* === SECTION TITLE === */
.section-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--dark);
  margin-bottom: 16px;
  margin-top: 8px;
}

/* === FILTER BAR === */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-bar select {
  padding: 8px 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  background: var(--white);
}

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--grey);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* === RESOURCE CARD === */
.resource-card {
  background: var(--white);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 14px;
}
.resource-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.resource-icon.video { background: #fee2e2; }
.resource-icon.pdf { background: #dbeafe; }
.resource-icon.script { background: #fef3c7; }
.resource-icon.fiche { background: #d1fae5; }
.resource-info h4 { font-size: 14px; color: var(--dark); }
.resource-info p { font-size: 12px; color: var(--grey); }

/* === ADMIN SPECIFIC === */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.admin-sidebar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}
.admin-sidebar button {
  white-space: nowrap;
  padding: 8px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 20px;
  background: var(--white);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--dark);
  transition: all 0.2s;
}
.admin-sidebar button.active {
  background: var(--teal);
  color: var(--white);
  border-color: var(--teal);
}

/* === RESPONSIVE === */
@media (min-width: 768px) {
  .tab-nav {
    position: static;
    justify-content: center;
    gap: 4px;
    padding: 10px;
    border-top: none;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }
  .tab-nav button { flex-direction: row; font-size: 13px; gap: 6px; }
  .tab-nav button .tab-icon { font-size: 16px; }
  .app-content { padding-bottom: 20px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .modal-overlay { align-items: center; }
  .modal { border-radius: 16px; max-height: 80vh; }
}
