/* ===================================================
   Fluent UI Layout — fixes obligatorios
   FluentBodyContent no declara display:flex en su CSS
   de componente; hay que forzarlo aquí para que
   FluentNavMenu (sidebar) y FluentMain queden en fila.
   =================================================== */
html {
    height: 100%;
}

body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: auto;
}

/* FluentLayout: flex column de altura completa */
.layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
}

/* FluentBodyContent: flex ROW — sidebar izquierda, main derecha */
.body-content {
    display: flex;
    flex-direction: row;
    flex: 1;
}

/* nav-drawer: contenedor scrollable del sidebar en desktop */
.nav-drawer {
    flex-shrink: 0;
    width: 240px;
}

/* FluentNavMenu: ancho fijo, sin overflow propio (scroll en .nav-drawer) */
.fluent-nav-menu {
    flex-shrink: 0;
}

/* FluentMain: ocupa el resto */
main, [class*="main-content"] {
    flex: 1;
    min-width: 0;
    overflow: visible !important;
}

/* ===================================================
   ADS BarberSalon — Variables de marca
   Colores extraídos de www.appsdatastudio.com.mx
   =================================================== */
:root {
    --brand-primary:   #534AB7;
    --brand-primary-lt:#AFA9EC;
    --brand-lavender:  #EEEDFE;
    --brand-navy:      #1A2E4A;
    --brand-navy-dk:   #26215C;
    --brand-accent:    #FF6B2B;
    --brand-gradient:  linear-gradient(135deg, #1A2E4A 0%, #534AB7 100%);
    --brand-gradient-h:linear-gradient(90deg,  #1A2E4A 0%, #534AB7 100%);
}

/* ===================================================
   Reset base
   =================================================== */
html, body {
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    height: 100%;
    padding: 0;
    margin: 0;
    overflow: auto; /* permitimos scroll para diagnosticar recortes */
}

/* ===================================================
   Header con gradiente de marca
   =================================================== */
.app-header {
    background: var(--brand-gradient-h) !important;
    color: #fff !important;
    min-height: 52px;
}

.app-header fluent-button::part(control),
.app-header .fluent-button {
    color: rgba(255, 255, 255, 0.85) !important;
}

.app-header span,
.app-header fluent-text,
.app-header fluent-label {
    color: #fff !important;
}

/* ===================================================
   Fondo de login
   =================================================== */
.login-bg {
    background: var(--brand-lavender);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ===================================================
   Footer
   =================================================== */
.app-footer {
    font-size: .8rem;
    color: var(--neutral-foreground-hint, #666);
    text-align: center;
}

/* ===================================================
   Blazor error boundary (styled to brand)
   =================================================== */
.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
    border-radius: 4px;
}
.blazor-error-boundary::after {
    content: "Ocurrió un error inesperado. Intenta recargar la página.";
}

/* ===================================================
   Error UI flotante (Blazor circuit error)
   =================================================== */
#blazor-error-ui {
    background: var(--brand-navy);
    color: #fff;
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,.3);
    display: none;
    left: 0;
    padding: .75rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-size: .9rem;
}
#blazor-error-ui a {
    color: var(--brand-primary-lt);
    font-weight: 600;
    text-decoration: underline;
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1.25rem;
    top: .5rem;
    opacity: .8;
}

/* ===================================================
   Responsivo — hamburguesa oculta en desktop por defecto
   =================================================== */
.nav-toggle {
    display: none;
}

/* ── Teléfono ≤640px ──────────────────────────────── */
@media (max-width: 640px) {

    /* Mostrar botón hamburguesa */
    .nav-toggle {
        display: inline-flex !important;
    }

    /* Sidebar convertido en drawer */
    .nav-drawer {
        position: fixed;
        top: 52px;
        left: 0;
        bottom: 0;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 2px 0 8px rgba(0,0,0,.25);
        background: var(--neutral-layer-1, #fff);
        overflow-y: auto;
    }
    .nav-drawer.abierto {
        transform: translateX(0);
    }
    .fluent-nav-menu {
        width: 240px !important;
        height: 100%;
    }

    /* Overlay oscuro detrás del drawer */
    .nav-overlay {
        position: fixed;
        inset: 52px 0 0 0;
        z-index: 999;
        background: rgba(0,0,0,.4);
    }

    /* Ocultar nombre+sucursal en header para ganar espacio */
    .app-header .usuario-info {
        display: none;
    }
    .app-header img {
        height: 28px;
    }

    /* FluentDataGrid → tarjetas apiladas */
    main [role="row"] {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        border: 1px solid var(--neutral-stroke-rest, #e0e0e0);
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 8px 12px;
        background: var(--neutral-layer-1, #fff);
    }
    main [role="columnheader"] {
        display: none !important;
    }
    main [role="gridcell"] {
        width: 100% !important;
        min-width: 0 !important;
        padding: 4px 0 !important;
        justify-content: flex-start !important;
    }
    main [role="gridcell"]:first-child {
        font-weight: 600;
        font-size: 1.05rem;
        padding-bottom: 6px !important;
        border-bottom: 1px solid var(--neutral-stroke-rest, #e0e0e0);
        margin-bottom: 4px;
    }

    /* Forms: filas horizontales pasan a verticales */
    main fluent-stack[orientation="horizontal"] {
        flex-wrap: wrap !important;
    }
    main fluent-toolbar {
        flex-wrap: wrap !important;
        row-gap: 6px;
    }

    /* Eliminar max-width fijo en forms para usar todo el ancho */
    main fluent-stack[style*="max-width"] {
        max-width: 100% !important;
    }
}

/* ── Tablet 641px–1024px ──────────────────────────── */
@media (min-width: 641px) and (max-width: 1024px) {
    /* Nav visible pero más compacto */
    .fluent-nav-menu {
        width: 200px !important;
    }
    /* En tablet el drawer es normal (visible), no overlay */
    .nav-drawer {
        position: static;
        transform: none;
        box-shadow: none;
    }
}

/* ===================================================
   Toolbar de Index — búsqueda amplia, Nuevo alineado derecha
   =================================================== */
fluent-toolbar {
    width: 100% !important;   /* inline-flex → necesita ancho para que el spacer funcione */
}

fluent-toolbar fluent-search {
    flex: 1 1 auto;     /* ocupa todo el espacio hasta los botones */
    min-width: 200px;
}

fluent-toolbar fluent-search::part(control) {
    font-size: 1rem !important;
    height: 36px !important;
}

/* ===================================================
   Modales (FluentDialog) responsivos
   =================================================== */
fluent-dialog::part(control) {
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
    border: none;
    max-width: 95vw;
}

/* En pantallas grandes (Desktop), los modales de captura deben ser más amplios */
@media (min-width: 1024px) {
    fluent-dialog[style*="min-width"] {
        min-width: 750px !important;
    }
}

/* Corregir desbordamiento de FluentSelect y otros componentes en modales */
fluent-select, 
fluent-text-field, 
fluent-number-field, 
fluent-text-area,
fluent-autocomplete {
    width: 100% !important;
    max-width: 100% !important; 
    box-sizing: border-box !important;
}

fluent-select::part(control),
fluent-select::part(listbox),
fluent-autocomplete::part(control) {
    width: 100% !important;
    max-width: 100% !important;
}

/* Forzar que el popover del Select, Autocomplete y regiones ancladas 
   no se corte y se posicione por encima de todo */
fluent-select::part(listbox),
fluent-autocomplete::part(listbox),
fluent-anchored-region {
    z-index: 9999 !important;
}

/* El Autocomplete renderiza su listbox DENTRO de un elemento shadow DOM a veces 
   y otras veces el componente principal encapsula el contexto Z. 
   Esto fuerza a que el componente padre también escape de la tarjeta. */
fluent-autocomplete {
    position: relative;
    z-index: 9998 !important;
}

/* Evitar que el cuerpo del modal recorte los desplegables (Selects) 
   pero permitir scroll si el contenido es muy alto (Tabs) */
fluent-dialog-body, 
.fluent-dialog-body {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    display: flex !important; 
    flex-direction: column !important;
}

/* Asegurar que el grid no cause desbordamiento por padding/gap */
fluent-grid, fluent-grid-item {
    max-width: 100% !important;
}

/* ===================================================
   Componente Personalizado: AdsCard
   =================================================== */
.ads-card {
    background-color: var(--neutral-layer-1, #ffffff);
    border: 1px solid var(--neutral-stroke-layer-rest, #e0e0e0);
    border-radius: calc(var(--control-corner-radius) * 3); /* usualmente 12px */
    box-sizing: border-box;
    overflow: visible !important; /* Vital para permitir menús desplegables */
}

/* Fix Global de Desbordamiento en contenedores estructurales */
fluent-card, .fluent-card,
fluent-stack, .fluent-stack,
fluent-grid, fluent-grid-item,
fluent-card::part(control),
fluent-grid-item::part(control) {
    overflow: visible !important;
}

/* ===================================================
   Tema Oscuro — Ajustes de contraste
   =================================================== */
[data-theme='dark'] {
    --brand-navy: #96ADCF; /* Azul mucho más claro para títulos */
    --brand-lavender: #1a1a2e;
}

[data-theme='dark'] .action-card,
[data-theme='dark'] fluent-card,
[data-theme='dark'] .ads-card {
    background-color: var(--neutral-layer-2) !important;
    border: 1px solid var(--neutral-stroke-rest) !important;
}

[data-theme='dark'] .notification-item {
    background: var(--neutral-layer-3);
}

[data-theme='dark'] .app-footer {
    color: var(--neutral-foreground-hint);
}

/* ===================================================
   Misc helpers
   =================================================== */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}
.invalid {
    outline: 1px solid #e50000;
}
.validation-message {
    color: #e50000;
    font-size: .85rem;
}
