/* Local-ize portal — minimal, sober, Swiss */

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: #111827;
  background: #FAFAF9;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

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

/* ===== Sidebar ===== */
.sidebar {
  width: 240px;
  background: #1F2937;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  padding: 0 20px 20px 20px;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
  margin-bottom: 14px;
}
.brand-name { color: #FAFAF9; font-size: 18px; font-weight: 500; letter-spacing: -0.01em; }
.brand-subtitle { color: #9CA3AF; font-size: 11px; margin-top: 2px; }

.sidebar-section-label {
  padding: 0 20px 8px 20px;
  color: #6B7280;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 12px;
  margin-bottom: 16px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  color: #D1D5DB;
  font-size: 13px;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}
.nav-item i { font-size: 17px; flex-shrink: 0; }
.nav-label { flex: 1; }
.nav-item:hover { background: rgba(255,255,255,0.04); color: #FAFAF9; }
.nav-item.active {
  background: rgba(14, 116, 144, 0.18);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
  border-radius: 0;
  color: #FAFAF9;
}
.nav-item.placeholder { cursor: not-allowed; opacity: 0.65; }
.nav-item.placeholder:hover { background: rgba(255,255,255,0.02); color: #D1D5DB; }

.nav-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 500;
}
.nav-badge-accent { background: var(--accent); color: #FAFAF9; }
.nav-badge-warning { background: #D97706; color: #FAFAF9; }
.nav-badge-role {
  background: rgba(217, 119, 6, 0.18);
  color: #F59E0B;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-spacer { flex: 1; }
.sidebar-user {
  padding: 14px 20px;
  border-top: 0.5px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #FAFAF9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
}
.user-info { flex: 1; min-width: 0; }
.user-name { color: #FAFAF9; font-size: 13px; }
.user-role { color: #9CA3AF; font-size: 11px; }
.logout-form { margin: 0; }
.logout-btn {
  background: transparent;
  border: none;
  color: #9CA3AF;
  font-size: 16px;
  padding: 4px;
}
.logout-btn:hover { color: #FAFAF9; }

/* ===== Main content ===== */
.main-content {
  flex: 1;
  background: #FAFAF9;
  padding: 28px 32px;
  min-width: 0;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 28px;
}
.page-title { font-size: 22px; font-weight: 500; color: #111827; letter-spacing: -0.01em; }
.page-subtitle { font-size: 13px; color: #6B7280; margin-top: 4px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  border: none;
  font-family: inherit;
}
.status-active { background: #ECFDF5; color: #065F46; }
.status-active .status-dot { width: 6px; height: 6px; background: #059669; border-radius: 50%; }
.status-sleeping { background: #FEF3C7; color: #92400E; cursor: pointer; }
.status-sleeping .status-dot { width: 6px; height: 6px; background: #D97706; border-radius: 50%; }
.status-sleeping:hover { background: #FDE68A; }
.status-waking { background: #DBEAFE; color: #1E40AF; }
.status-waking .status-dot { width: 6px; height: 6px; background: #2563EB; border-radius: 50%; }
.status-dot.pulsing { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ===== Sections ===== */
.section { margin-bottom: 24px; }
.section-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 14px;
}
.section-label {
  font-size: 13px;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}
.section-meta { font-size: 13px; color: #111827; font-weight: 500; }

/* ===== App grid ===== */
.app-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.app-card {
  background: #FFFFFF;
  border: 0.5px solid #E5E7EB;
  border-radius: 12px;
  padding: 18px;
}
.app-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.app-icon {
  width: 40px;
  height: 40px;
  background: #ECFEFF;
  color: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.app-icon i { font-size: 22px; }
.app-version { font-size: 11px; color: #6B7280; }
.app-version-warning { color: #D97706; }
.app-name { font-size: 14px; font-weight: 500; color: #111827; margin-bottom: 2px; }
.app-desc { font-size: 11px; color: #6B7280; margin-bottom: 12px; }

/* ===== Buttons ===== */
.btn {
  width: 100%;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.12s, background 0.12s;
}
.btn-primary { background: var(--accent); color: #FFFFFF; border: none; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary {
  background: #FFFFFF;
  color: #111827;
  border: 0.5px solid #D1D5DB;
}
.btn-secondary:hover { background: #F9FAFB; }
.btn-block { display: block; width: 100%; padding: 10px; font-size: 14px; }

/* ===== Cards generic ===== */
.card {
  background: #FFFFFF;
  border: 0.5px solid #E5E7EB;
  border-radius: 12px;
  overflow: hidden;
}

/* ===== Sessions ===== */
.session-row { display: flex; align-items: center; padding: 11px 14px; }
.session-row.with-divider { border-bottom: 0.5px solid #F3F4F6; }
.session-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  margin-right: 10px;
  flex-shrink: 0;
}
.avatar-amber { background: #FEF3C7; color: #92400E; }
.avatar-blue { background: #DBEAFE; color: #1E40AF; }
.avatar-emerald { background: #D1FAE5; color: #065F46; }
.session-info { flex: 1; min-width: 0; }
.session-user { font-size: 12px; color: #111827; }
.session-meta { font-size: 10px; color: #6B7280; }
.session-status { font-size: 10px; color: #059669; }

/* ===== Stats ===== */
.stats-card { padding: 14px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.stat-row:last-child { margin-bottom: 0; }
.stat-label { font-size: 11px; color: #6B7280; }
.stat-value { font-size: 16px; font-weight: 500; color: #111827; }
.stat-value-sm { font-size: 13px; color: #111827; }

/* ===== Activity ===== */
.activity-row {
  display: flex;
  align-items: center;
  padding: 9px 14px;
  gap: 10px;
}
.activity-row + .activity-row { border-top: 0.5px solid #F3F4F6; }
.activity-icon { font-size: 15px; color: var(--accent); flex-shrink: 0; }
.activity-text { flex: 0 1 auto; font-size: 12px; color: #111827; min-width: 0; margin-right: auto; }
.activity-meta { color: #6B7280; }
.activity-when { font-size: 11px; color: #6B7280; white-space: nowrap; }

/* ===== Login ===== */
.login-body {
  background: #F3F4F6;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-shell { width: 100%; max-width: 380px; padding: 20px; }
.login-card {
  background: #FFFFFF;
  border-radius: 12px;
  border: 0.5px solid #E5E7EB;
  padding: 32px;
}
.login-brand { text-align: center; margin-bottom: 24px; }
.brand-name-large {
  font-size: 28px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.brand-subtitle-large { font-size: 13px; color: #6B7280; margin-top: 2px; }
.login-error {
  background: #FEF2F2;
  color: #991B1B;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 0.5px solid #FCA5A5;
}
.login-form { display: flex; flex-direction: column; gap: 14px; }
.form-label { display: flex; flex-direction: column; gap: 6px; }
.form-label span { font-size: 12px; color: #6B7280; font-weight: 500; }
.form-label input {
  padding: 9px 12px;
  font-size: 14px;
  border: 0.5px solid #D1D5DB;
  border-radius: 8px;
  font-family: inherit;
  color: #111827;
  background: #FFFFFF;
}
.form-label input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.1);
}
.login-footer {
  font-size: 11px;
  color: #9CA3AF;
  text-align: center;
  margin-top: 18px;
}

/* ===== Error page ===== */
.error-code { font-size: 64px; font-weight: 500; margin: 16px 0; color: #111827; }
.error-message { color: #6B7280; margin-bottom: 24px; }

/* === Gateway control (toggle ON/OFF live) === */
.gateway-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-error {
  background: #FEE2E2;
  color: #991B1B;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}

.btn-gateway-action {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-gateway-action.btn-stop {
  background: #FFFFFF;
  color: #991B1B;
  border-color: #FCA5A5;
}
.btn-gateway-action.btn-stop:hover {
  background: #FEE2E2;
  border-color: #EF4444;
}

.btn-gateway-action.btn-start {
  background: var(--accent, #0E7490);
  color: #FFFFFF;
  border-color: var(--accent, #0E7490);
}
.btn-gateway-action.btn-start:hover {
  background: #155E75;
  border-color: #155E75;
}

/* Animation HTMX : feedback visuel pendant les requêtes */
.htmx-request .btn-gateway-action {
  opacity: 0.5;
  pointer-events: none;
}

/* Smooth swap */
#gateway-control.htmx-swapping {
  opacity: 0.7;
  transition: opacity 0.2s;
}

/* ===== Messagerie — fil d'équipe ===== */
.chat-fil {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  max-height: calc(100vh - 240px);
  min-height: 200px;
  overflow-y: auto;
}
.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 78%;
}
.chat-msg-mine {
  flex-direction: row-reverse;
  align-self: flex-end;
}
.chat-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  background: #E5E7EB;
  color: #374151;
}
.chat-msg-mine .chat-avatar { background: var(--accent); color: #FFFFFF; }
.avatar-violet { background: #EDE9FE; color: #5B21B6; }
.avatar-rose   { background: #FCE7F3; color: #9D174D; }
.avatar-teal   { background: #CCFBF1; color: #0F766E; }
.chat-author-amber  { color: #92400E; }
.chat-author-blue   { color: #1E40AF; }
.chat-author-emerald{ color: #065F46; }
.chat-author-violet { color: #5B21B6; }
.chat-author-rose   { color: #9D174D; }
.chat-author-teal   { color: #0F766E; }
.chat-bubble {
  background: #F3F4F6;
  border-radius: 14px;
  padding: 8px 12px;
  min-width: 0;
}
.chat-msg-mine .chat-bubble { background: var(--accent); color: #FFFFFF; }
.chat-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.chat-author { font-size: 12px; font-weight: 500; }
.chat-msg-mine .chat-author { display: none; }
.chat-time { font-size: 10px; color: #9CA3AF; }
.chat-msg-mine .chat-time { color: rgba(255,255,255,0.7); }
.chat-body { font-size: 13px; line-height: 1.45; word-wrap: break-word; overflow-wrap: anywhere; }
.chat-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: stretch;
}
.chat-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  border: 0.5px solid #D1D5DB;
  border-radius: 10px;
  outline: none;
}
.chat-input:focus { border-color: var(--accent); }
.chat-form .btn-primary {
  flex: 0 0 auto;
  width: auto;
  padding: 10px 24px;
  border-radius: 10px;
  white-space: nowrap;
}

/* ===== Aperçu messagerie (dashboard) ===== */
.msg-preview-row {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  align-items: flex-start;
}
.msg-preview-row + .msg-preview-row { border-top: 0.5px solid #F3F4F6; }
.msg-preview-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
}
.msg-preview-info { flex: 1; min-width: 0; }
.msg-preview-head { display: flex; justify-content: space-between; align-items: baseline; }
.msg-preview-author { font-size: 12px; font-weight: 500; color: #111827; }
.msg-preview-time { font-size: 10px; color: #9CA3AF; white-space: nowrap; }
.msg-preview-body {
  font-size: 12px;
  color: #6B7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-preview-link {
  display: block;
  border-top: 0.5px solid #F3F4F6;
  padding: 9px 0 2px;
  text-align: center;
  font-size: 12px;
  color: var(--accent);
}

/* ===== Administration — table users ===== */
.admin-flash { padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; }
.admin-flash-ok { background: #D1FAE5; color: #065F46; }
.admin-flash-err { background: #FEE2E2; color: #991B1B; }
.admin-table-card { padding: 0; overflow: hidden; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6B7280;
  font-weight: 500;
  padding: 12px 16px;
  border-bottom: 0.5px solid #E5E7EB;
}
.admin-table tbody td { padding: 12px 16px; border-bottom: 0.5px solid #F3F4F6; vertical-align: middle; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-user-name { font-weight: 500; color: #111827; }
.admin-user-sub { font-size: 11px; color: #9CA3AF; }
.admin-role { font-size: 11px; padding: 2px 8px; border-radius: 6px; text-transform: capitalize; }
.admin-role-admin { background: #FEF3C7; color: #92400E; }
.admin-role-translator { background: #DBEAFE; color: #1E40AF; }
.admin-role-freelance { background: #EDE9FE; color: #5B21B6; }
.admin-tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; }
.admin-tag-on { background: #D1FAE5; color: #065F46; }
.admin-tag-off { background: #F3F4F6; color: #6B7280; }
.admin-tag-warn { background: #FEF3C7; color: #92400E; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ===== Zone d'échange de fichiers ===== */
.file-upload-form {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.file-input-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.file-input-label input[type="file"] { display: none; }
.file-chosen { font-size: 13px; color: #6B7280; }
