/* ===== VARIABLES GLOBALES ===== */
:root {
  --blanc:     #FFFFFF;
  --brume:     #F5F7F4;
  --vert-doux: #D4E8D0;
  --vert-mid:  #8FBC8F;
  --vert-fort: #4A7C59;
  --encre:     #1C2B1E;
  --gris:      #8A9B8E;
  --alerte:    #E07A5F;
  --jaune:     #F2CC8F;

  --primary:       var(--vert-mid);
  --primary-dark:  var(--vert-fort);
  --primary-light: var(--vert-doux);
  --bg:            var(--brume);
  --text:          var(--encre);
  --text-light:    var(--gris);
  --accent:        var(--jaune);
}

/* ===== THÈMES ===== */
[data-theme="cuivre"] {
  --primary:       #B87333;
  --primary-dark:  #8B4513;
  --primary-light: #D2B48C;
  --accent:        #F5DEB3;
}

[data-theme="rouge-royal"] {
  --primary:       #C8102E;
  --primary-dark:  #8B0000;
  --primary-light: #F4C2C2;
  --accent:        #FFD700;
}

[data-theme="jaune-espagnol"] {
  --primary:       #C8A900;
  --primary-dark:  #8B6914;
  --primary-light: #FFF0A0;
  --accent:        #C8102E;
}

[data-theme="bleu-glace"] {
  --primary:       #5B9EC9;
  --primary-dark:  #2B6A99;
  --primary-light: #B8DCF0;
  --accent:        #E8F4FC;
}

[data-theme="bleu-marin"] {
  --primary:       #1E3A8A;
  --primary-dark:  #0F172A;
  --primary-light: #93C5FD;
  --accent:        #3B82F6;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* ===== HEADER avec colibri ===== */
header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--primary-light);
}

.header-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

header h1 {
  color: var(--primary-dark);
  font-size: 2.5rem;
  display: inline;
}

header p {
  color: var(--text-light);
  font-size: 1.1rem;
  margin-top: 0.4rem;
}

/* ===== BOUTONS ===== */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
  text-decoration: none;
  display: inline-block;
}

.btn-primary { background-color: var(--primary); color: var(--blanc); }
.btn-primary:hover { background-color: var(--primary-dark); }

.btn-secondary {
  background-color: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-secondary:hover { background-color: var(--primary-light); color: var(--primary-dark); }

.btn-danger {
  background: none;
  border: 1.5px solid var(--alerte);
  color: var(--alerte);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.btn-danger:hover { background: var(--alerte); color: white; }

/* ===== AUTH ===== */
.auth-container {
  max-width: 500px;
  margin: 2rem auto;
  background: var(--blanc);
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.auth-form { display: none; }
.auth-form.active { display: block; }

.auth-form h2 { color: var(--primary-dark); margin-bottom: 1.5rem; text-align: center; }

.form-group { margin-bottom: 1.5rem; }

label { display: block; margin-bottom: 0.5rem; color: var(--text); font-weight: 500; }

input, textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--primary-light);
  border-radius: 6px;
  font-size: 1rem;
  background-color: var(--blanc);
  color: var(--text);
  font-family: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--primary); }

.form-footer { text-align: center; margin-top: 1rem; }
.form-footer a { color: var(--primary); text-decoration: none; cursor: pointer; }
.form-footer a:hover { text-decoration: underline; }

/* ===== NAVBAR MAILBOX ===== */
.mailbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--primary-light);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.3s;
  font-size: 0.9rem;
}
.nav-btn:hover { background-color: var(--primary-light); color: var(--primary-dark); }
.nav-btn.active { background-color: var(--primary); color: var(--blanc); border-color: var(--primary); }

/* ===== BARRE D'ACTIONS SÉLECTION ===== */
.selection-bar {
  display: none;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--primary-light);
  border-radius: 8px;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.selection-bar.visible { display: flex; }

.selection-bar span { font-size: 0.9rem; color: var(--primary-dark); font-weight: 600; }

/* ===== LISTE DES MAILS ===== */
.mail-list { display: flex; flex-direction: column; gap: 0.7rem; }

.mail-item {
  background: var(--blanc);
  padding: 1rem 1.2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border-left: 4px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
}

.mail-item:hover { transform: translateY(-1px); box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.mail-item.unread { border-left-color: var(--primary); font-weight: 500; }
.mail-item.selected { background: var(--primary-light); border-left-color: var(--primary-dark); }

.mail-checkbox {
  margin-top: 0.2rem;
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.mail-content { flex: 1; min-width: 0; }

.mail-header { display: flex; justify-content: space-between; margin-bottom: 0.3rem; }
.mail-sender { font-weight: 600; color: var(--text); }
.mail-date { color: var(--text-light); font-size: 0.85rem; white-space: nowrap; }
.mail-subject { color: var(--primary-dark); margin-bottom: 0.3rem; }
.mail-preview { color: var(--text-light); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== VUE MAIL ===== */
.mail-view {
  background: var(--blanc);
  border-radius: 10px;
  padding: 2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.mail-view h2 { margin-bottom: 1rem; color: var(--primary-dark); }
.mail-view-meta { display: flex; gap: 2rem; color: var(--text-light); font-size: 0.9rem; margin-bottom: 1rem; flex-wrap: wrap; }
.mail-view-body { white-space: pre-wrap; line-height: 1.7; padding: 1.2rem; background: var(--bg); border-radius: 6px; margin-bottom: 1.5rem; }

.ttl-bar-wrap { margin-bottom: 1.5rem; }
.ttl-label { font-size: 0.78rem; color: var(--text-light); margin-bottom: 0.3rem; }
.ttl-bar { height: 4px; background: var(--primary-light); border-radius: 2px; overflow: hidden; }
.ttl-bar-fill { height: 100%; border-radius: 2px; transition: width 0.5s; }

.mail-view-actions { display: flex; gap: 1rem; flex-wrap: wrap; }

/* ===== CORBEILLE badge ===== */
.badge-corbeille {
  font-size: 0.75rem;
  background: var(--alerte);
  color: white;
  border-radius: 10px;
  padding: 0.1rem 0.4rem;
  margin-left: 0.3rem;
}

/* ===== COMPOSE ===== */
.compose-form {
  max-width: 800px;
  margin: 0 auto;
  background: var(--blanc);
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.compose-form textarea { min-height: 200px; resize: vertical; }

/* ===== THÈME SÉLECTEUR ===== */
.theme-selector {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 1000;
}

.theme-selector select {
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--primary-light);
  background: var(--blanc);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
}

/* ===== FLASH MESSAGE ===== */
.flash {
  background: var(--vert-doux);
  color: var(--vert-fort);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  text-align: center;
  font-weight: 500;
}

/* ===== BANNIÈRE MAILS CERTIFIÉS EN ATTENTE ===== */
/* Mails importants (2FA, alertes) volontairement non auto-téléchargés —
   restent sur le serveur jusqu'à récupération explicite par l'utilisateur,
   pour éviter qu'un autre appareil ne les aspire silencieusement */
.alerte-certifie {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #FFF8E1;
  border: 1px solid #E8C468;
  border-radius: 8px;
  padding: 0.7rem 1rem;
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
}

/* ===== VIDE ===== */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-light);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .container { padding: 1rem; }
  .mailbox-header { flex-direction: column; align-items: flex-start; }
  .nav { gap: 0.3rem; }
  .nav-btn { padding: 0.4rem 0.7rem; font-size: 0.85rem; }
}

/* ===== SETTINGS ===== */
.settings-card {
  background: var(--blanc);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.settings-card h2 {
  color: var(--primary-dark);
  font-size: 1.1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--primary-light);
}

/* ===== BADGE MAILS NON LUS ===== */
.nav-btn .badge {
  display: inline-block;
  background: var(--alerte);
  color: white;
  border-radius: 10px;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  margin-left: 0.3rem;
  font-weight: 700;
  vertical-align: middle;
}

/* ===== CONVERSATIONS ===== */
.conversation-item {
  background: var(--blanc);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  margin-bottom: 0.7rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border-left: 4px solid transparent;
}

.conversation-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.conversation-item.unread { border-left-color: var(--primary); }

.conversation-count {
  font-size: 0.75rem;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 10px;
  padding: 0.1rem 0.5rem;
  font-weight: 600;
}

.conversation-thread {
  border-left: 3px solid var(--primary-light);
  margin-left: 1rem;
  padding-left: 1rem;
}

.thread-mail {
  padding: 0.8rem;
  margin-bottom: 0.5rem;
  background: var(--brume);
  border-radius: 6px;
  font-size: 0.9rem;
}

.thread-mail .thread-meta {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 0.3rem;
}
