/* =====================================================================
   Nexus ERP — Styles globaux
   Aucune dépendance externe. WCAG 2.1 AA.
   ===================================================================== */

/* ----- Variables ----- */
:root {
    --color-brand:         #1e3a5f;
    --color-brand-hover:   #2d5a9e;
    --color-accent:        #3b82f6;
    --color-text:          #111827;
    --color-text-muted:    #6b7280;
    --color-bg:            #f8fafc;
    --color-surface:       #ffffff;
    --color-border:        #e5e7eb;
    --color-sidebar-bg:    #1e3a5f;
    --color-sidebar-text:  #cbd5e1;
    --color-sidebar-hover: rgba(255, 255, 255, 0.08);
    --color-sidebar-active:#2d5a9e;
    --color-success:       #16a34a;
    --color-error:         #dc2626;
    --color-info:          #0284c7;

    --sidebar-width:   240px;
    --header-height:    60px;
    --footer-height:    40px;

    --radius-sm:  4px;
    --radius-md:  8px;
    --radius-lg: 12px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);

    --transition: 150ms ease;
}

/* ----- Reset léger ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
}

/* ----- Accessibilité ----- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 8px;
    padding: 8px 16px;
    background: var(--color-brand);
    color: #fff;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    font-weight: 600;
    text-decoration: none;
    z-index: 9999;
    transition: top var(--transition);
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

/* Focus visible global */
:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* FocusOnNavigate met le focus sur le <h1> de la page au changement de route
   (accessibilité : annonce du titre). Ce n'est pas un élément interactif :
   on masque le contour de focus pour éviter un titre « sélectionné » au chargement. */
.page-header h1:focus,
.page-header h1:focus-visible {
    outline: none;
}

/* ----- Shell de l'application ----- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ----- Sidebar ----- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    height: var(--header-height);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-decoration: none;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: var(--color-brand-hover);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
}

.brand-name { font-size: 1.05rem; }

/* ----- Navigation sidebar ----- */
.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.sidebar-nav ul {
    list-style: none;
}

.nav-section {
    margin-top: 16px;
}

.nav-section-title {
    display: block;
    padding: 4px 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.35);
    cursor: default;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--color-sidebar-text);
    text-decoration: none;
    border-radius: 0;
    transition: background var(--transition), color var(--transition);
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    background: transparent;
    font-size: 0.875rem;
}

.nav-item:hover {
    background: var(--color-sidebar-hover);
    color: #fff;
}

.nav-item--active {
    background: var(--color-sidebar-active);
    color: #fff;
    font-weight: 600;
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.75;
}

.nav-item--active .nav-icon,
.nav-item:hover .nav-icon {
    opacity: 1;
}

/* ----- Zone principale ----- */
.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ----- En-tête ----- */
.app-header {
    height: var(--header-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.header-left { flex: 1; }

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
}

.header-user-section {
    position: relative;
    display: flex;
    align-items: center;
}

.header-user-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: 0.875rem;
    transition: background var(--transition);
}
.header-user-btn:hover { background: var(--color-bg); }

.header-tenant-name {
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.header-dropdown-arrow {
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

/* Couche transparente plein écran : ferme le menu déroulant au clic extérieur. */
.header-dropdown-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99;
    background: transparent;
}

.header-tenant-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    z-index: 100;
    overflow: hidden;
}

.tenant-dropdown-item {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    text-align: left;
    transition: background var(--transition);
}
.tenant-dropdown-item:hover { background: var(--color-bg); }
.tenant-dropdown-item--current { font-weight: 600; }

.tenant-dropdown-info {
    display: flex;
    flex-direction: column;
}
.tenant-dropdown-name { font-size: 0.875rem; color: var(--color-text); }
.tenant-dropdown-slug { font-size: 0.75rem; color: var(--color-text-muted); }
.tenant-dropdown-check { color: var(--color-primary); font-size: 0.9rem; }

.btn-logout {
    padding: 5px 12px;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    transition: background var(--transition), border-color var(--transition);
}

.btn-logout:hover {
    background: var(--color-bg);
    border-color: var(--color-text-muted);
    color: var(--color-text);
}

.btn-login {
    padding: 5px 12px;
    background: var(--color-accent);
    border-radius: var(--radius-sm);
    color: #fff;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
}

/* ----- Contenu principal ----- */
.main-content {
    flex: 1;
    padding: 28px 32px;
}

/* ----- Pied de page ----- */
.app-footer {
    height: var(--footer-height);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* ----- Composants communs ----- */
.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
}

.page-header p {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* ----- Dashboard ----- */
.welcome-banner {
    background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-brand-hover) 100%);
    color: #fff;
    padding: 24px 28px;
    border-radius: var(--radius-lg);
    margin-bottom: 28px;
}

.welcome-banner h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.welcome-banner p { opacity: 0.85; }

/* ----- Tableau de bord (P2-DSH) ----- */
.dashboard-task-line {
    padding: 6px 0;
    border-bottom: 1px solid var(--color-border);
}

.dashboard-task-line:last-child {
    border-bottom: none;
}

.dashboard-task-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* ----- Sélection de tenant ----- */
.tenant-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 480px;
}

.tenant-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: border-color var(--transition), box-shadow var(--transition);
    box-shadow: var(--shadow-sm);
}

.tenant-card:hover {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-md);
}

.tenant-initial {
    width: 44px;
    height: 44px;
    background: var(--color-brand);
    color: #fff;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    flex-shrink: 0;
}

.tenant-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tenant-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-text);
}

.tenant-slug {
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.tenant-arrow {
    color: var(--color-text-muted);
    font-size: 1.1rem;
}

/* ----- Alertes ----- */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    border: 1px solid;
    font-size: 0.875rem;
}

.alert-error  { background: #fef2f2; border-color: #fca5a5; color: var(--color-error); }
.alert-info   { background: #eff6ff; border-color: #93c5fd; color: var(--color-info); }

/* ----- Placeholder ----- */
.page-placeholder {
    padding: 40px;
    background: var(--color-surface);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* ----- Liens et boutons ----- */
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ----- Landing page ----- */
.landing-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--color-bg);
}

.landing-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}

.landing-header-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 32px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.landing-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-text);
    text-decoration: none;
}

.landing-nav { display: flex; align-items: center; gap: 16px; }

.landing-main { flex: 1; }

.landing-footer {
    height: var(--footer-height);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* Hero */
.hero {
    background: linear-gradient(160deg, var(--color-brand) 0%, var(--color-brand-hover) 100%);
    color: #fff;
    padding: 96px 32px;
}

.hero-inner {
    max-width: 720px;
    margin: 0 auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.hero-badge {
    display: inline-block;
    padding: 4px 14px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    line-height: 1.15;
}

.hero-subtitle {
    font-size: 1.05rem;
    opacity: 0.85;
    max-width: 560px;
    line-height: 1.7;
}

.hero-actions { margin-top: 8px; }

/* Boutons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    padding: 9px 18px;
    background: var(--color-accent);
    color: #fff;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    transition: background var(--transition), box-shadow var(--transition);
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    background: #2563eb;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    text-decoration: none;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    padding: 9px 18px;
    background: transparent;
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    transition: background var(--transition);
    cursor: pointer;
}

.btn-secondary:hover {
    background: rgba(59, 130, 246, 0.06);
    text-decoration: none;
}

.btn-large { padding: 13px 32px; font-size: 1rem; border-radius: var(--radius-md); }

/* Features */
.features {
    padding: 80px 32px;
}

.features-inner {
    max-width: 1120px;
    margin: 0 auto;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    text-align: center;
    margin-bottom: 48px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 24px;
}

.feature-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: box-shadow var(--transition), border-color var(--transition);
}

.feature-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-accent);
}

.feature-icon {
    width: 44px;
    height: 44px;
    background: #eff6ff;
    color: var(--color-accent);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feature-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
}

.feature-card p {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    line-height: 1.65;
}

/* ----- Lisibilité des éléments header réutilisés dans la MudAppBar bleue ----- */
/* Le menu utilisateur et le bouton de déconnexion proviennent de l'ancien header clair :
   sur la barre bleue MudBlazor, leurs couleurs sombres deviennent illisibles. On force
   l'héritage de la couleur de texte de l'AppBar (blanc) tant qu'ils y sont rendus. */
.mud-appbar .header-user-btn,
.mud-appbar .header-tenant-name,
.mud-appbar .header-dropdown-arrow {
    color: inherit;
}

.mud-appbar .btn-logout {
    color: inherit;
    border-color: rgba(255, 255, 255, 0.5);
}

.mud-appbar .header-user-btn:hover,
.mud-appbar .btn-logout:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.85);
    color: inherit;
}

/* La liste déroulante des espaces de travail garde son fond clair : on rétablit le texte sombre. */
.mud-appbar .header-tenant-dropdown {
    color: var(--color-text);
}
