/*
 * Thème Mail Piler "dark" – style identique à l’admin Enterprise (Legal Holds, data-bs-theme="dark")
 * Fond sombre, navbar compacte bg-body-tertiary, cartes dark, bouton bleu.
 */

/* --- Variables thème sombre (body noir, header bleu roi) --- */
:root {
  --piler-dark-bg: #000000;
  --piler-dark-bg-elevated: #0d1117;
  --piler-dark-bg-card: #161b22;
  --piler-dark-border: #30363d;
  --piler-dark-text: #ffffff;
  --piler-dark-text-muted: #ffffff;
  --piler-dark-primary: #0d6efd;
  --piler-dark-primary-hover: #0b5ed7;
  --piler-dark-navbar: #002366;
}

/* --- Bandeau 2FA obligatoire (fond rouge, texte blanc) --- */
.alert-2fa-required {
  background-color: #c00 !important;
  color: #fff !important;
  border-color: #a00;
}

/* --- Base --- */
html, body { height: auto !important; height: 100%; min-height: 100%; }
body {
  margin: 0;
  padding-top: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--piler-dark-text);
  background-color: var(--piler-dark-bg);
}
body#loginpage {
  background-color: var(--piler-dark-bg);
  padding-top: 60px;
  padding-bottom: 60px;
  min-height: 100vh;
  box-sizing: border-box;
}

/* --- Header : seule zone avec fond (bleu roi). Tout le contenu à l’intérieur = fond transparent --- */
#header {
  min-height: 44px;
  width: 100%;
  background-color: var(--piler-dark-navbar);
  text-transform: lowercase;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
#header #menu,
#header .navbar,
#header .container-fluid,
#header .navbar-collapse,
#header .navbar-brand {
  background: transparent !important;
  border-bottom: none;
  box-shadow: none;
}

/* Pas de fond noir dans le menu : le .container-fluid du menu reste transparent (bleu du nav) */
#menu .container-fluid {
  background: transparent !important;
}

/* --- Navbar / Menu (pages sans #header : fond bleu roi) --- */
#menu.piler-navbar,
#menu {
  background: var(--piler-dark-navbar) !important;
  color: var(--piler-dark-text) !important;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  font-weight: 500;
  text-transform: lowercase;
  min-height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid var(--piler-dark-border);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

#menu .navbar-collapse { flex-grow: 0; }
#menu .navbar-brand img.branding_logo { max-height: 32px; }

.piler-navbar-toggler {
  border-color: rgba(255,255,255,0.5) !important;
  padding: 0.35rem 0.6rem;
}
.piler-navbar-toggler:hover,
.piler-navbar-toggler:focus {
  border-color: #fff !important;
  box-shadow: 0 0 0 0.15rem rgba(255,255,255,0.25);
}
.piler-navbar-toggler .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255,255,255,0.9)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

@media (max-width: 991.98px) {
  #menu .navbar-collapse {
    margin-top: 8px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  #menu .menulink { display: block; padding: 8px 12px; margin: 2px 0; border-radius: 6px; }
  #menu .dropdown { width: 100%; }
  #menu .dropdown .menulink { width: 100%; text-align: left; }
  #menu .dropdown-menu { position: static !important; margin: 4px 0 12px 0; box-shadow: inset 0 0 0 1px var(--piler-dark-border); }
}

.menulink {
  text-shadow: none;
  padding: 6px 10px;
  margin: 0 2px;
  color: var(--piler-dark-text) !important;
  font-size: 14px;
  border-radius: 6px;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.menulink:hover {
  color: #fff !important;
  text-decoration: none;
  background: rgba(255,255,255,0.1);
}

/* Dropdown : fond sombre, compact --- */
.dropdown-menu {
  font-size: 14px;
  font-weight: 400;
  text-transform: lowercase;
  padding: 6px 0;
  min-width: 200px;
  border-radius: 8px;
  border: 1px solid var(--piler-dark-border);
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  margin-top: 6px;
  background: var(--piler-dark-bg-card) !important;
}

.dropdown-menu .dropdown-item,
a.dropdown-item {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
  color: var(--piler-dark-text) !important;
}
.dropdown-menu li.dropdown-item:hover,
.dropdown-menu a.dropdown-item:hover {
  background-color: rgba(255,255,255,0.08) !important;
  color: #fff !important;
  text-decoration: none;
}

/* Container et panneaux --- */
.container-panes { height: calc(95vh - 56px); display: flex; flex-direction: column; }
.pane { overflow-y: auto; flex-grow: 1; min-height: 300px; position: relative; background: var(--piler-dark-bg); }
.resizer { height: 5px; background: var(--piler-dark-border); cursor: row-resize; }
.pane-upper-content {
  height: calc(100% - 40px);
  overflow-y: auto;
  border: 1px solid var(--piler-dark-border);
  border-radius: 8px;
  background: var(--piler-dark-bg-card);
}
.pane-upper-fixed {
  height: 40px;
  background: var(--piler-dark-bg-elevated);
  position: absolute;
  bottom: 0;
  width: 100%;
  border-top: 1px solid var(--piler-dark-border);
  border-radius: 0 0 8px 8px;
}
#preview {
  height: 500px;
  border: 1px solid var(--piler-dark-border);
  border-radius: 8px;
  background: var(--piler-dark-bg-card);
}
.no-select { user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; }

.resizer-search-results { display: inline-block; width: 5px; height: 100%; position: absolute; right: 0; top: 0; cursor: col-resize; }

/* Titres --- */
h1, h2, h3, h4 {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 600;
  text-transform: lowercase;
  color: #fff !important;
}
h2 i { font-size: 1.75rem; }

/* Search container --- */
.searchcontainer { padding-top: 24px; margin-left: 16px; margin-right: 16px; }
.searchcontainer .form-control {
  background: var(--piler-dark-bg-card);
  border-color: var(--piler-dark-border);
  color: var(--piler-dark-text);
}
.searchcontainer .form-control::placeholder { color: rgba(255,255,255,0.7); }
.searchcontainer,
.searchcontainer label { color: #ffffff !important; }

/* Boutons --- */
.btn {
  border-radius: 6px;
  font-weight: 500;
}
.btn-primary {
  background: var(--piler-dark-primary) !important;
  border-color: var(--piler-dark-primary) !important;
  color: #fff !important;
}
.btn-primary:hover {
  background: var(--piler-dark-primary-hover) !important;
  border-color: var(--piler-dark-primary-hover) !important;
  color: #fff !important;
}
.btn-secondary {
  background: var(--piler-dark-bg-card) !important;
  border-color: var(--piler-dark-border) !important;
  color: var(--piler-dark-text) !important;
}
.btn-secondary:hover {
  background: var(--piler-dark-border) !important;
  color: #fff !important;
}
.btn-search { width: 33%; }
.btn-options { width: 34%; }

/* Champs formulaire --- */
input[type=text],
input[type=password],
select.form-control,
.form-control {
  background: var(--piler-dark-bg-card) !important;
  border: 1px solid var(--piler-dark-border) !important;
  color: var(--piler-dark-text) !important;
  border-radius: 6px;
  padding: 8px 12px;
}
input[type=text]:focus,
input[type=password]:focus,
select.form-control:focus,
.form-control:focus {
  border-color: var(--piler-dark-primary) !important;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25) !important;
  outline: 0;
}

#pagingrow { overflow: hidden; color: #ffffff !important; }
#pagingrow a,
.boxfooter,
.boxfooter a,
.messagelistfooter,
#messagelistfooter { color: #ffffff !important; }
.functionbox { border-left: 1px solid var(--piler-dark-border); height: 30px; overflow: hidden; }

/* Modal Advanced Search : lisibilité (fond, champs, placeholders) */
#advancedSearchModal .modal-content {
  background-color: #0d1117 !important;
  border: 1px solid #30363d;
  color: #ffffff !important;
}
#advancedSearchModal .modal-header {
  background-color: #161b22 !important;
  border-bottom-color: #30363d !important;
  color: #ffffff !important;
}
#advancedSearchModal .modal-title { color: #ffffff !important; }
#advancedSearchModal .modal-body {
  background-color: #0d1117 !important;
  color: #ffffff !important;
}
#advancedSearchModal .modal-body .table,
#advancedSearchModal .modal-body .table td {
  background-color: transparent !important;
  color: #ffffff !important;
  border-color: #30363d !important;
}
#advancedSearchModal .form-control,
#advancedSearchModal input[type="text"],
#advancedSearchModal input[type="date"] {
  background-color: #21262d !important;
  border: 1px solid #6e7681 !important;
  color: #ffffff !important;
}
#advancedSearchModal .form-control::placeholder,
#advancedSearchModal input::placeholder {
  color: rgba(255, 255, 255, 0.65) !important;
}
#advancedSearchModal .form-control:focus,
#advancedSearchModal input:focus {
  border-color: #58a6ff !important;
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.3) !important;
}
#advancedSearchModal .modal-footer {
  background-color: #161b22 !important;
  border-top-color: #30363d !important;
}
#advancedSearchModal .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
  opacity: 0.9;
}
#advancedSearchModal .form-check-input {
  background-color: #21262d !important;
  border-color: #6e7681 !important;
}
#advancedSearchModal .form-check-input:checked {
  background-color: #0d6efd;
  border-color: #0d6efd;
}
#advancedSearchModal label,
#advancedSearchModal .table td:first-child { color: #ffffff !important; }

/* Messages --- */
.messageheader {
  background-color: var(--piler-dark-bg-elevated);
  padding: 12px 16px;
  border-bottom: 1px solid var(--piler-dark-border);
  border-radius: 8px 8px 0 0;
  color: var(--piler-dark-text);
}
.messagecontents {
  background-color: var(--piler-dark-bg-card);
  padding: 16px;
  border-radius: 0 0 8px 8px;
  color: #ffffff !important;
}
.messagecontents,
.messagecontents *,
#preview,
#preview * {
  color: #ffffff !important;
}
#preview iframe { background: var(--piler-dark-bg-card) !important; }

.resultrow { font-style: italic; cursor: pointer; color: #ffffff !important; }
.resultrow.new { font-style: normal; }
.resultrow:hover { background: rgba(255,255,255,0.08); }
/* Ligne mail sélectionnée : bleu roi (override Bootstrap .table-info et .table-striped) */
#results tr.resultrow.selected,
#results tr.resultrow.selected.table-info,
table.table tr.resultrow.selected,
table.table tr.resultrow.selected.table-info,
#results.table-striped tbody tr.resultrow.selected,
#results.table-striped tbody tr.resultrow.selected:nth-of-type(odd),
#results.table-striped tbody tr.resultrow.selected:nth-of-type(even) {
  background-color: #002366 !important;
  color: #ffffff !important;
}
#results tr.resultrow.selected td,
#results tr.resultrow.selected.table-info td,
table.table tr.resultrow.selected td,
table.table tr.resultrow.selected.table-info td,
#results.table-striped tbody tr.resultrow.selected td,
#results.table-striped tbody tr.resultrow.selected:nth-of-type(odd) td,
#results.table-striped tbody tr.resultrow.selected:nth-of-type(even) td {
  background-color: #002366 !important;
  color: #ffffff !important;
  border-color: #003380 !important;
}
#results .table-info,
#results tr.table-info td { background-color: #002366 !important; color: #ffffff !important; }
/* Variables Bootstrap pour forcer bleu roi sur chaque cellule sélectionnée (lignes paires et impaires) */
#results.table-striped tbody tr.resultrow.selected,
#results.table-striped tbody tr.resultrow.selected > *,
#results.table-striped tbody tr.resultrow.selected td,
#results.table-striped tbody tr.resultrow.selected th {
  --bs-table-accent-bg: #002366 !important;
  --bs-table-striped-bg: #002366 !important;
  --bs-table-bg: #002366 !important;
  background-color: #002366 !important;
  color: #ffffff !important;
}
/* Dernier recours : toute cellule d'une ligne sélectionnée */
#results tbody tr.resultrow.selected td,
#results tbody tr.resultrow.selected.table-info td {
  --bs-table-accent-bg: #002366 !important;
  --bs-table-striped-bg: #002366 !important;
  background-color: #002366 !important;
  color: #ffffff !important;
  border-color: #003380 !important;
}
/* Force bleu roi pour toute ligne avec classe "selected" (striped odd/even) */
#results tbody tr[class*="selected"] td,
#results tbody tr[class*="selected"] th,
#results .table-striped tbody tr[class*="selected"] > * {
  --bs-table-accent-bg: #002366 !important;
  --bs-table-striped-bg: #002366 !important;
  background-color: #002366 !important;
  color: #ffffff !important;
  border-color: #003380 !important;
}

/* Liens --- */
a { color: #ffffff; text-decoration: none; }
a:hover { color: #ffffff; text-decoration: underline; opacity: 0.9; }
a.xxx { color: #ffffff; text-decoration: underline; }
a.xxx:hover { color: #ffffff; text-decoration: underline; }

/* Page de login --- */
#logo-lg { width: 280px; margin: 0 auto 24px; display: block; filter: brightness(0.9); }
#logincontainer { text-transform: lowercase; color: var(--piler-dark-text); }
.compatibility { max-width: 340px; margin: 0 auto; color: var(--piler-dark-text-muted); text-align: center; font-size: 13px; }

.form-signin {
  max-width: 380px;
  width: 100%;
  padding: 32px 40px 40px;
  margin: 0 auto 24px;
  background: var(--piler-dark-bg-card);
  border: 1px solid var(--piler-dark-border);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
/* Page login / 2FA : titres et formulaire */
.form-signin .form-signin-heading,
.form-signin h2 {
  font-size: 1.15rem !important;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 1rem;
}

/* Popup / page 2FA (saisie du code après login) */
.form-2fa .form-2fa-title {
  font-size: 1.25rem !important;
  color: #fff !important;
  margin-bottom: 1.25rem;
  text-align: center;
}
.form-2fa .form-control {
  background: rgba(255,255,255,0.08) !important;
  border: 1px solid var(--piler-dark-border);
  color: #fff !important;
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  text-align: center;
  margin-bottom: 1.25rem;
}
.form-2fa .form-control::placeholder {
  color: rgba(255,255,255,0.5);
}
.form-2fa .form-control:focus {
  border-color: var(--piler-dark-primary);
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.35);
}
.form-2fa-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}
.form-2fa-actions .btn-primary {
  background: var(--piler-dark-primary) !important;
  border-color: var(--piler-dark-primary) !important;
}
.form-2fa-actions .btn-outline-secondary {
  border-color: var(--piler-dark-border);
  color: var(--piler-dark-text) !important;
}
.form-2fa-actions .btn-outline-secondary:hover {
  background: rgba(255,255,255,0.1) !important;
  color: #fff !important;
  border-color: rgba(255,255,255,0.3);
}
/* Bouton Cancel visible sur fond sombre */
.form-signin .btn[type="reset"],
.form-signin .btn:not(.btn-primary) {
  background: var(--piler-dark-border) !important;
  border-color: var(--piler-dark-border) !important;
  color: var(--piler-dark-text) !important;
}
.form-signin .btn[type="reset"]:hover,
.form-signin .btn:not(.btn-primary):hover {
  background: var(--piler-dark-text-muted) !important;
  color: #fff !important;
  border-color: var(--piler-dark-text-muted) !important;
}
#compatibility { max-width: 340px; margin: 24px auto 0; color: var(--piler-dark-text-muted); text-align: center; }

.ps10 { padding-left: 10px; }
.pe10 { padding-right: 10px; }

/* Icônes sémantiques --- */
i.spam { color: #f59e0b; }
i.attachment { color: #6ea8fe; }
i.note { color: #20c997; }
i.tag { color: #a78bfa; }
i.verified { color: #51cf66; }
.private { color: #ff6b6b; }
.xxx { color: #ffffff; }

.myspinner { width: 5rem; height: 5rem; }
.middleofscreen { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.hidden { visibility: hidden; }

/* Tableaux (style Legal Holds / Enterprise) --- */
table { width: 100%; border-collapse: collapse; }
th {
  padding: 12px 16px;
  border: 1px solid var(--piler-dark-border);
  position: relative;
  background: var(--piler-dark-bg-elevated) !important;
  font-weight: 600;
  color: #ffffff !important;
  font-size: 13px;
}
td {
  padding: 12px 16px;
  border: 1px solid var(--piler-dark-border);
  background: var(--piler-dark-bg-card) !important;
  color: #ffffff !important;
}
th.centered, td.centered { text-align: center; }
th.auto-width, td.auto-width { width: 1%; white-space: nowrap; }

.tsa { border-top: 1px solid var(--piler-dark-border); border-bottom: 1px solid var(--piler-dark-border); }

.branding_logo { max-height: 28px; filter: brightness(0.95); }

/* Cartes / cards (style stats Legal Holds) --- */
.card, .border {
  background: var(--piler-dark-bg-card) !important;
  border-color: var(--piler-dark-border) !important;
  color: var(--piler-dark-text) !important;
  border-radius: 8px;
}
.card-body { color: var(--piler-dark-text) !important; }

/* ========== Page Health Monitor ========== */
.health-page-content { color: var(--piler-dark-text); }
.health-refresh-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--piler-dark-border);
  border-radius: 8px;
  color: var(--piler-dark-text);
  font-size: 14px;
}
.health-refresh-bar i { opacity: 0.9; }
.health-card {
  background: var(--piler-dark-bg-card);
  border: 1px solid var(--piler-dark-border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  color: var(--piler-dark-text);
}
.health-card-title {
  margin: 0 0 1rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--piler-dark-border);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 600;
}
.health-card-title i { margin-right: 6px; opacity: 0.9; }
.health-card-subtitle {
  margin: 0 0 0.5rem 0;
  color: var(--piler-dark-text-muted);
  font-weight: 600;
}
.health-uptime {
  margin: 0 0 1rem 0;
  color: #7ee787;
  font-size: 0.95rem;
}
.health-dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1.5rem;
  align-items: baseline;
}
.health-dl dt {
  margin: 0;
  color: var(--piler-dark-text-muted);
  font-weight: 500;
  font-size: 0.9rem;
}
.health-dl dd {
  margin: 0;
  color: var(--piler-dark-text);
  font-size: 0.9rem;
}
.health-dl dd.text-success { color: #7ee787; }
.health-dl dd.text-danger { color: #ff7b72; }
.health-dl dd.health-critical {
  color: #ff7b72;
  font-weight: 600;
  background: rgba(255,120,114,0.12);
  padding: 6px 10px;
  border-radius: 6px;
  margin-top: 4px;
}
.health-link { color: #6ea8fe; text-decoration: none; }
.health-link:hover { color: #8bb4ff; text-decoration: underline; }
.health-progress {
  height: 22px;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  overflow: hidden;
  max-width: 280px;
}
.health-progress .progress-bar { font-size: 12px; line-height: 22px; }
@media (max-width: 767.98px) {
  .health-dl { grid-template-columns: 1fr; gap: 0.2rem 0; }
  .health-dl dt { margin-top: 0.5rem; }
  .health-dl dt:first-child { margin-top: 0; }
}

/* Container principal --- */
#main.container,
.container.text-start,
.container-fluid {
  background: var(--piler-dark-bg);
  color: #ffffff !important;
}
.pane { background: var(--piler-dark-bg) !important; }
.pane-upper-content { background: var(--piler-dark-bg-card) !important; color: #ffffff !important; }

/* Toast / spinner --- */
.toast { background: var(--piler-dark-bg-card); border-color: var(--piler-dark-border); }
.toast-header { background: var(--piler-dark-bg-elevated); color: var(--piler-dark-text); border-color: var(--piler-dark-border); }
.toast-body { color: var(--piler-dark-text); }
.spinner-border.text-primary { color: var(--piler-dark-primary) !important; }

/* Select / options --- */
select.form-control option {
  background: var(--piler-dark-bg-card);
  color: var(--piler-dark-text);
}

/* ========== Responsive ========== */
@media (max-width: 991.98px) {
  #main.container,
  .container { max-width: 100%; padding-left: 12px; padding-right: 12px; }
  .searchcontainer { margin-left: 8px; margin-right: 8px; padding-top: 12px; }
  #menu .d-flex { flex-wrap: wrap; }
  #menu .menulink { padding: 6px 8px; font-size: 13px; }
}

@media (max-width: 767.98px) {
  body { font-size: 13px; }
  #main.container,
  .container { padding-left: 10px; padding-right: 10px; }
  .container.text-start .row .col-3 { width: 100%; max-width: 100%; flex: 0 0 100%; margin-bottom: 8px; }
  .container.text-start .row.justify-content-start { flex-direction: column; }
  .searchcontainer .row { flex-direction: column; }
  .searchcontainer .form-control { max-width: 100%; }
  table.table { font-size: 12px; }
  #results { overflow-x: auto; -webkit-overflow-scrolling: touch; display: block; }
  #results table { min-width: 500px; }
}

/* Tables: scroll horizontal on small screens */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 767.98px) {
  .table-responsive { margin-left: -10px; margin-right: -10px; padding-left: 10px; padding-right: 10px; }
}
