/* ============================================================
   Portal Merquen - estilos centralizados
   Fuente: se mantiene la del sistema (Tailwind base). No se importa
   ninguna tipografia externa a proposito.
   Acento: emerald (verde de marca agro Quelen), no el indigo AI por defecto.
   Lock de color: 1 solo acento; los badges de rol/estado conservan su
   color porque codifican estado semantico, no decoracion.
   Lock de forma: --radius para tarjetas/inputs/botones; pill para badges.
   ============================================================ */

:root {
    --accent: #059669;          /* emerald-600: acento unico de marca */
    --accent-hover: #047857;    /* emerald-700 */
    --accent-ring: rgba(5, 150, 105, 0.45);
    --radius: 0.75rem;          /* radio unico para tarjetas/inputs/botones */
    --glass-blur: 18px;
    --shadow-tint: rgba(15, 23, 42, 0.28); /* slate-900 tintado, no negro puro */
}

/* ---------- Fondo con blur (solo la imagen, no el contenido) ---------- */
.bg-blur::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url('https://quelen-public.s3.us-east-2.amazonaws.com/fondo2.png');
    background-size: cover;
    background-position: center;
    filter: blur(4px);
    transform: scale(1.03); /* evita el halo claro en los bordes del blur */
    z-index: -1;
}

/* ---------- Glass ---------- */
.glass-effect {
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 8px 32px 0 var(--shadow-tint);
}
.glass-effect-strong {
    background: linear-gradient(155deg, rgba(31, 41, 55, 0.62), rgba(17, 24, 39, 0.55));
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid rgba(255, 255, 255, 0.08);
    /* sombra tintada + highlight interno superior para dar profundidad */
    box-shadow: 0 10px 32px 0 var(--shadow-tint), inset 0 1px 0 0 rgba(255, 255, 255, 0.07);
}

/* ---------- Tarjeta de indicador (KPI) ---------- */
.stat-card { transition: transform 0.2s, box-shadow 0.2s; }
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 38px 0 rgba(15, 23, 42, 0.4), inset 0 1px 0 0 rgba(255, 255, 255, 0.1);
}
/* Icono como marca de agua: grande, gris claro, en 2do plano, cortado por
   los bordes de la tarjeta (la tarjeta usa overflow-hidden) */
.stat-watermark {
    position: absolute;
    right: -0.75rem; bottom: -1.25rem;
    font-size: 6.5rem; line-height: 1;
    color: rgba(255, 255, 255, 0.07);
    pointer-events: none;
    z-index: 0;
}

/* Marca de agua grande para los contenedores de graficos (abajo-derecha) */
.chart-watermark {
    position: absolute;
    right: -3.5rem; bottom: -6rem;
    font-size: 30rem; line-height: 1;
    color: rgba(255, 255, 255, 0.05);
    pointer-events: none;
    z-index: 0;
}

/* ---------- Breadcrumb (mismo glass que tarjetas, fuente clara) ---------- */
.breadcrumb-bar {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.45rem 0.95rem; border-radius: 9999px;
    font-size: 0.85rem;
    background: linear-gradient(155deg, rgba(31, 41, 55, 0.62), rgba(17, 24, 39, 0.55));
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px 0 var(--shadow-tint);
}
.breadcrumb-bar a { color: rgba(255, 255, 255, 0.8); font-weight: 500; transition: color 0.2s; }
.breadcrumb-bar a:hover { color: #fff; }
.breadcrumb-bar .sep { color: rgba(255, 255, 255, 0.4); font-size: 0.7rem; }
.breadcrumb-bar .current { color: #34d399; font-weight: 600; }

/* ---------- Layout / Sidebar ---------- */
.sidebar-transition { transition: all 0.3s ease-in-out; }
.content-transition { transition: margin-left 0.3s ease-in-out; width: calc(100% - 12rem); }
.content-collapsed { width: calc(100% - 6rem); }
.floating-sidebar { margin: 1rem 0 1rem 1rem; border-radius: 1rem; height: calc(100vh - 2rem); }
.menu-active { background-color: rgba(255, 255, 255, 0.15); border-radius: 0.5rem; }

/* ---------- Items de navegacion (centralizado) ---------- */
.nav-item {
    display: flex; align-items: center;
    margin: 0.05rem 0.5rem;
    padding: 0.32rem 0.65rem;
    border-radius: 0.5rem;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.82rem; font-weight: 500;
    border-left: 2px solid transparent;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.09); color: #fff; }
.nav-item i { width: 1.15rem; text-align: center; font-size: 0.85rem; flex-shrink: 0; }
.nav-item .menu-text { margin-left: 0.55rem; }
.nav-item.is-active {
    background: rgba(5, 150, 105, 0.2);
    color: #fff; font-weight: 600;
    border-left-color: var(--accent);
}
.nav-item.is-active i { color: #34d399; }
/* Sub-items (reportes): mas compactos */
.nav-sub { padding: 0.2rem 0.65rem; font-size: 0.75rem; color: rgba(255, 255, 255, 0.78); font-weight: 400; }
.nav-sub i { font-size: 0.72rem; }
.sidebar-collapsed .nav-item { justify-content: center; padding-left: 0; padding-right: 0; border-left-color: transparent; }
.sidebar-collapsed { width: 5rem !important; }
.sidebar-collapsed .full-logo,
.sidebar-collapsed .menu-text,
.sidebar-collapsed .profile-details,
.sidebar-collapsed .filtros-container,
.sidebar-collapsed .section-title { display: none; }
.sidebar-collapsed #logo-container { justify-content: center; padding: 0.5rem; }
#small-logo { width: auto; height: 2rem; object-fit: contain; aspect-ratio: auto; }

/* Nav scrolleable: evita que los ítems se salgan del sidebar */
.sidebar-nav { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.25) transparent; }
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.22); border-radius: 3px; }

.section-title {
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0.35rem 0 0.1rem 0.9rem;
}

/* Selects de filtros del sidebar */
.sidebar-select {
    display: block; width: 100%;
    border-radius: 0.45rem;
    padding: 0.25rem 0.45rem;
    font-size: 0.75rem;
    color: #fff;
    background: rgba(17, 24, 39, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.12);
    text-overflow: ellipsis;
}
.sidebar-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }

/* Multi-select (dropdown con checkboxes) */
.ms-filter { position: relative; }
.ms-toggle {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.4rem; cursor: pointer; text-align: left;
}
.ms-toggle .ms-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-caret { font-size: 0.6rem; opacity: 0.6; flex-shrink: 0; }
.ms-panel {
    position: absolute; z-index: 50; top: calc(100% + 0.2rem); left: 0; right: 0;
    max-height: 14rem; overflow-y: auto;
    background: rgba(17, 24, 39, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.45rem; padding: 0.25rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.ms-search {
    position: sticky; top: 0; z-index: 1;
    display: block; width: 100%; margin-bottom: 0.25rem;
    padding: 0.3rem 0.45rem; font-size: 0.75rem; color: #fff;
    background: rgba(17, 24, 39, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 0.35rem;
}
.ms-search:focus { outline: none; border-color: var(--accent); }
.ms-search::placeholder { color: rgba(255, 255, 255, 0.4); }
.ms-opt {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.25rem 0.4rem; font-size: 0.75rem; color: #fff;
    border-radius: 0.3rem; cursor: pointer;
}
.ms-opt:hover { background: rgba(255, 255, 255, 0.08); }
.ms-opt input { accent-color: var(--accent); flex-shrink: 0; }

/* Avatar del perfil */
.profile-avatar {
    width: 2.25rem; height: 2.25rem; border-radius: 9999px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(5, 150, 105, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
}

/* ---------- Loading ---------- */
.loading-overlay {
    position: fixed; inset: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none; justify-content: center; align-items: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.loading-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem; border-radius: var(--radius);
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}
.loading-spinner {
    border: 4px solid #f3f4f6;
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    width: 40px; height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: #374151; font-weight: 600; font-size: 1.1rem; }
.loading-subtext { color: #6b7280; font-size: 0.9rem; margin-top: 0.5rem; }

/* ---------- Componentes reutilizables ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.5rem 1rem; border-radius: var(--radius);
    font-size: 0.875rem; font-weight: 500;
    transition: background-color 0.2s, transform 0.05s;
    cursor: pointer;
}
.btn:active { transform: translateY(1px); }            /* feedback tactil */
.btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
/* Scrim oscuro: garantiza contraste del texto blanco sobre el fondo-foto */
.btn-secondary { background: rgba(17, 24, 39, 0.55); color: #fff; border: 1px solid rgba(255,255,255,0.18); }
.btn-secondary:hover { background: rgba(17, 24, 39, 0.7); }

.input-glass {
    width: 100%; border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    background: rgba(17, 24, 39, 0.45);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.input-glass::placeholder { color: rgba(255, 255, 255, 0.6); }
.input-glass:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }

.badge { padding: 0.15rem 0.6rem; font-size: 0.7rem; border-radius: 9999px; }

/* ---------- Accesibilidad: movimiento reducido (6.B) ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
