@import url('https://api.fontshare.com/v2/css?f[]=satoshi@400,500,700,900&display=swap');

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Satoshi', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --couleur-principale: #253266;
  --couleur-secondaire: #cdc690;
  --couleur-douce: #e7ddd3;
  
  --bg-app: #fcfbf9;
  --bg-card: #ffffff;
  --text-main: #1f2742;
  --text-muted: #5e657c;
  --border: #e3ded6;
  --danger: #e74c3c;
  --success: #2e7d32;
  --shadow: 0 4px 18px rgba(37, 50, 102, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-app: #131b38;
    --bg-card: #1c264a;
    --text-main: #f5f4ef;
    --text-muted: #a3a9bf;
    --border: #2c3863;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  }
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h2, h3 {
  color: var(--text-main);
}

button, input, textarea, select {
  font-size: 1rem;
  font-family: inherit;
}

/* Champs textuels : 100% de largeur */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="number"],
input[type="search"],
textarea {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: var(--bg-app);
  color: var(--text-main);
}

textarea {
  resize: vertical;
}

/* Correction stricte : Checkboxes et Radios ne prennent JAMAIS 100% */
input[type="checkbox"],
input[type="radio"] {
  width: 18px !important;
  height: 18px !important;
  accent-color: var(--couleur-secondaire);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0 !important;
}

.toggle-control {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem;
  color: var(--text-main);
}

/* Menus déroulants soignés */
select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg-app);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 2.2rem 0.6rem 0.8rem;
  font-weight: 600;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23cdc690' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}

select option {
  background-color: var(--bg-card);
  color: var(--text-main);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.2rem;
  border-radius: 10px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--couleur-principale);
  color: #ffffff;
}

@media (prefers-color-scheme: dark) {
  .btn-primary {
    background-color: var(--couleur-secondaire);
    color: #253266;
  }
}

.btn-secondary {
  background-color: var(--couleur-secondaire);
  color: #253266;
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
}

.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
}

.card {
  background-color: var(--bg-card);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.badge {
  background-color: var(--couleur-douce);
  color: var(--couleur-principale);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  text-transform: uppercase;
  display: inline-block;
}

.hidden {
  display: none !important;
}

/* En-tête */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: var(--couleur-principale);
  color: #ffffff;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.header-logo {
  width: 32px;
  height: 32px;
}

.header-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--couleur-secondaire);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.btn-header-action {
  background: none;
  border: none;
  color: var(--couleur-secondaire);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  border-radius: 8px;
}

.btn-header-action svg {
  width: 22px;
  height: 22px;
  stroke: var(--couleur-secondaire);
}

.btn-logout-danger {
  background: rgba(231, 76, 60, 0.15) !important;
  border: 1px solid rgba(231, 76, 60, 0.4) !important;
  color: #e74c3c !important;
  padding: 0.45rem !important;
  border-radius: 8px;
}

.btn-logout-danger svg {
  width: 24px !important;
  height: 24px !important;
  stroke: #e74c3c !important;
}

/* Navigation du bas */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 0.75rem 0.5rem calc(0.75rem + env(safe-area-inset-bottom));
  z-index: 50;
}

.nav-item {
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 1;
  padding: 0.3rem 0;
  transition: transform 0.15s ease;
}

.nav-item:active {
  transform: scale(0.92);
}

.nav-item svg {
  width: 24px;
  height: 24px;
  stroke: var(--couleur-secondaire);
  opacity: 0.45;
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.nav-item.active svg {
  opacity: 1;
  stroke-width: 2.3;
  filter: drop-shadow(0 0 6px rgba(205, 198, 144, 0.5));
}

.main-content {
  padding: 1rem 1rem calc(5rem + env(safe-area-inset-bottom));
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

/* Auth & Onboarding */
.auth-screen,
#onboarding-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  width: 100%;
}

.auth-card,
.onboarding-card {
  width: 100%;
  max-width: 460px;
  margin: auto;
  background: var(--bg-card);
  border-radius: 16px;
  padding: 2.2rem 1.8rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.onboarding-header {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background-color: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: var(--couleur-secondaire);
  transition: width 0.3s ease;
}

.onboarding-step {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.onboarding-step .sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.onboarding-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}

.onboarding-nav button {
  flex: 1;
}

.avatar-upload-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
}

.file-input {
  display: none;
}

.auth-logo {
  display: block;
  margin: 0 auto 0.75rem;
  width: 72px;
  height: 72px;
}

.brand-title {
  text-align: center;
  color: var(--couleur-principale);
  font-size: 1.5rem;
}

@media (prefers-color-scheme: dark) {
  .brand-title {
    color: var(--couleur-secondaire);
  }
}

.brand-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.auth-links {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: center;
}

.auth-links a {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-decoration: underline;
}

.rgpd-box {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin: 1rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Anniversaires d'entreprise */
.anniversary-card {
  background: linear-gradient(135deg, rgba(205, 198, 144, 0.25), rgba(231, 221, 211, 0.2));
  border: 2px solid var(--couleur-secondaire);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.anniversary-badge {
  background-color: var(--couleur-secondaire);
  color: #253266;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 0.5rem;
}

.post-pinned {
  border-left: 4px solid var(--couleur-secondaire);
}

.post-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.post-author {
  font-weight: 700;
  font-size: 0.95rem;
}

.post-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Échanges */
.post-actions {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-weight: 600;
}

.action-btn.liked {
  color: #e0245e;
}

.action-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.comments-section {
  margin-top: 0.85rem;
  background-color: var(--bg-app);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.comment-item {
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  line-height: 1.45;
}

.comment-author {
  font-weight: 700;
  color: var(--couleur-secondaire);
  margin-right: 0.35rem;
}

/* Images dans les publications */
.post-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.post-image-thumb {
  width: 100%;
  aspect-ratio: 16 / 9; /* Ou 4 / 3, voire auto si tu veux le ratio d'origine */
  height: auto;
  max-height: 380px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  display: block;
}

/* Aperçu images avant publication */
.image-preview-bar {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.preview-thumb {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Agenda */
.event-card {
  display: flex;
  gap: 1.2rem;
  align-items: center;
}

.event-date-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: var(--couleur-secondaire);
  color: #253266;
  border-radius: 12px;
  min-width: 60px;
  height: 60px;
  font-weight: 800;
  flex-shrink: 0;
}

.event-date-badge .day {
  font-size: 1.3rem;
  line-height: 1;
}

.event-date-badge .month {
  font-size: 0.7rem;
  text-transform: uppercase;
}

.event-info {
  flex: 1;
}

.event-info h3 {
  margin-bottom: 0.25rem;
}

.event-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Annuaire */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 600px) {
  .cards-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.member-card {
  display: flex;
  gap: 1rem;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.member-card:hover {
  transform: translateY(-2px);
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--couleur-secondaire);
  background-color: var(--couleur-douce);
  flex-shrink: 0;
}

.avatar-lg {
  width: 90px;
  height: 90px;
}

.company-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.member-name {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.member-headline {
  font-size: 0.85rem;
  line-height: 1.3;
}

.member-tenure {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

#modal-member-body a {
  color: var(--couleur-secondaire);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Messagerie Privée - Bulles de contact */
.dm-contacts-carousel {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
  scrollbar-width: thin;
}

.dm-contact-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  flex-shrink: 0;
  width: 65px;
  text-align: center;
}

.dm-contact-item.active .avatar {
  border-color: #2ecc71;
  box-shadow: 0 0 8px rgba(46, 204, 113, 0.4);
}

.dm-contact-name {
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 65px;
  color: var(--text-main);
}

.chat-window {
  display: flex;
  flex-direction: column;
  height: 420px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.chat-bubble {
  max-width: 78%;
  padding: 0.6rem 0.85rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.chat-bubble.mine {
  align-self: flex-end;
  background-color: var(--couleur-principale);
  color: #fff;
  border-bottom-right-radius: 2px;
}

@media (prefers-color-scheme: dark) {
  .chat-bubble.mine {
    background-color: var(--couleur-secondaire);
    color: #253266;
  }
}

.chat-bubble.theirs {
  align-self: flex-start;
  background-color: var(--bg-app);
  border: 1px solid var(--border);
  border-bottom-left-radius: 2px;
}

/* Modale & Tableau */
.table-wrapper {
  overflow-x: auto;
  margin-top: 1rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.data-table th, .data-table td {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.install-banner {
  background: var(--couleur-principale);
  color: #fff;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #253266;
  color: #ffffff;
  padding: 0.6rem 1.2rem;
  border-radius: 20px;
  font-size: 0.85rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  z-index: 200;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}

.modal-content {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
}
