/* ==========================================================================
   THÈME PERSONNALISÉ ISLAM.RE (Bleu Marine & Bleu Ciel)
   ========================================================================== */

/* --- MODE CLAIR --- */
body.light {
  /* Identité principale : Bleu Marine */
  --primary: #003265;
  --on-primary: #ffffff; /* Texte blanc sur fond marine */

  /* Conteneurs secondaires : Bleu Ciel */
  --primary-container: #b9e3ff;
  --on-primary-container: #001e3e; /* Texte marine très foncé pour rester lisible */

  /* Éléments secondaires et tertiaires (Variations chromatiques) */
  --secondary: #4a607a;
  --on-secondary: #ffffff;
  --secondary-container: #d4e4fe;
  --on-secondary-container: #051c34;

  /* Fonds de page et surfaces (Grisé bleuté très léger) */
  --surface: #f8fafc;
  --surface-container-low: #f1f5f9;
  --surface-container: #e2e8f0;
  --surface-container-high: #cbd5e1;
  --surface-container-highest: #94a3b8;
}

/* --- MODE SOMBRE --- */
body.dark {
  /* En mode sombre, le Bleu Ciel devient la couleur principale pour éclairer l'écran */
  --primary: #8fc9ff;
  --on-primary: #003265; /* Texte marine sur fond ciel */

  /* Le conteneur devient le Bleu Marine pour s'effacer en arrière-plan */
  --primary-container: #004789;
  --on-primary-container: #d1e4ff;

  /* Éléments secondaires en mode sombre */
  --secondary: #b1c8e8;
  --on-secondary: #1a314b;
  --secondary-container: #334862;
  --on-secondary-container: #d4e4fe;

  /* Fonds de page et surfaces sombres (Slate/Bleu nuit) */
  --surface: #0f172a;
  --surface-container-low: #1e293b;
  --surface-container: #334155;
  --surface-container-high: #475569;
  --surface-container-highest: #64748b;
}

main {
  min-height: 80vh;
}

section[data-config-section] {
  min-height: 12rem;
  content-visibility: auto;
  contain-intrinsic-size: 12rem;
}

/* --- OPTIMISATIONS DYNAMIQUES RENDU & CLS --- */
img.responsive {
  max-width: 100%;
  height: auto;
  content-visibility: auto;
  background-color: var(--surface-container-low);
}

article img.circle.large {
  aspect-ratio: 1 / 1;
  object-fit: cover;
  width: 4rem;
  height: 4rem;
  flex-shrink: 0;
}

/* --- GRILLE DASHBOARD 3-ÉTATS RESPONSIVE MATHÉMATIQUE --- */
#dashboard-grid {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 0.75rem !important;
}

@media (min-width: 768px) {
  #dashboard-grid > [data-widget-size="small"],
  #dashboard-grid > .s12.m6.l4 {
    flex: 0 0 calc(33.333% - 0.5rem) !important;
    max-width: calc(33.333% - 0.5rem) !important;
    box-sizing: border-box !important;
  }
  #dashboard-grid > [data-widget-size="medium"],
  #dashboard-grid > .s12.m12.l8 {
    flex: 0 0 calc(66.666% - 0.25rem) !important;
    max-width: calc(66.666% - 0.25rem) !important;
    box-sizing: border-box !important;
  }
  #dashboard-grid > [data-widget-size="large"],
  #dashboard-grid > .s12.m12.l12 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
}

@media (max-width: 767px) {
  #dashboard-grid > [data-widget-size="small"],
  #dashboard-grid > .s12.m6.l4 {
    flex: 0 0 calc(50% - 0.4rem) !important;
    max-width: calc(50% - 0.4rem) !important;
    box-sizing: border-box !important;
  }
  #dashboard-grid > [data-widget-size="medium"],
  #dashboard-grid > .s12.m12.l8,
  #dashboard-grid > [data-widget-size="large"],
  #dashboard-grid > .s12.m12.l12 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
}

/* --- VARIABLES DÉGRADÉ ICÔNE DASHBOARD & LOGO --- */
:root {
  --dash-icon-gradient: linear-gradient(135deg, #003265 0%, #0b57d0 50%, #8fc9ff 100%);
  --dash-icon-color: #0b57d0;
}

body.dark {
  --dash-icon-gradient: linear-gradient(135deg, #8fc9ff 0%, #389bfd 50%, #004789 100%);
  --dash-icon-color: #8fc9ff;
}

/* --- ICÔNE DASHBOARD COULEUR/DÉGRADÉ LOGO --- */
i.icon-dashboard,
a[href="dashboard.html"] i,
a[href="dashboard"] i,
[data-icon="dashboard"] {
  background: var(--dash-icon-gradient) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  display: inline-block;
}

table#prayer-table tr.active-prayer th,
table#prayer-table tr.active-prayer td,
td.active-prayer,
th.active-prayer {
  background-color: var(--primary-container) !important;
  color: var(--on-primary-container) !important;
  font-weight: bold !important;
}

table#prayer-table tr.active-prayer th:first-child {
  border-left: 4px solid var(--primary) !important;
}

/* --- PRIÈRE INTERDITE (Lever, Zénith, Coucher) --- */
.forbidden-prayer {
  background-color: #fee2e2 !important;
  color: #991b1b !important;
  font-weight: bold !important;
  border: 1px solid #ef4444 !important;
}

body.dark .forbidden-prayer {
  background-color: #7f1d1d !important;
  color: #feccae !important;
  border: 1px solid #ef4444 !important;
}

#hero-prayer.is-forbidden {
  background-color: #991b1b !important;
  color: #ffffff !important;
}

#hero-prayer.is-forbidden #hero-prayer-label {
  color: #fca5a5 !important;
  font-weight: bold !important;
}

/* --- BOUTON FAB DASHBOARD POSITIONNÉ AU-DESSUS DE LA BOTTOM NAV SUR MOBILE --- */
@media (max-width: 767px) {
  #dash-fab-add {
    bottom: 5.5rem !important;
    right: 1.25rem !important;
    z-index: 99 !important;
  }

  #app-top img.circle {
    display: none !important;
  }
}

/* --- SALAH PAGE CUSTOM UI --- */
table#prayer-table {
  width: 100%;
  border-collapse: collapse;
}

table#prayer-table tr {
  border-bottom: 1px solid var(--surface-container-high);
}

table#prayer-table th {
  text-align: left;
  font-weight: normal;
  padding: 1rem;
}

table#prayer-table td {
  padding: 1rem;
  font-size: 1.25rem;
}

.salah-hero {
  transition: background 0.3s ease, color 0.3s ease;
}

.salah-stepper {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
body.light .salah-stepper {
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* --- NAVIGATION DRAWER DESKTOP (Fix Largeur & Lignes) --- */
#app-left.drawer {
  /* width: 17rem ; */
  min-width: 15rem ;
  box-sizing: border-box !important;
  flex-direction: column !important;
  align-items: stretch !important;
}

#app-left.drawer a.row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  text-align: left !important;
  white-space: nowrap !important;
  gap: 1rem !important;
  padding: 0.65rem 1rem !important;
  width: 100% !important;
  border-radius: 0.75rem !important;
}

#app-left.drawer a.row i {
  flex-shrink: 0 !important;
}

#app-left.drawer a.row span {
  white-space: nowrap !important;
  overflow: visible !important;
}