/**
 * ============================================================================
 * SGE PRO - MATERIAL DESIGN 3 (GOOGLE M3) DESIGN SYSTEM TOKENS & COMPONENTS
 * ============================================================================
 * Paleta oficial remasterizada basada en el Azul de SGE Pro.
 * Diseñado para alta legibilidad en monitores de PC y teléfonos Android (PWA).
 * ============================================================================
 */

:root {
    /* 🎨 PALETA OFICIAL GOOGLE WORKSPACE BLUE (MATERIAL DESIGN 3) */
    --md-sys-color-primary: #0B57D0;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #D3E3FD;
    --md-sys-color-on-primary-container: #041E49;

    --md-sys-color-secondary: #475569;
    --md-sys-color-secondary-container: #F0F4F9;
    --md-sys-color-on-secondary-container: #0F172A;

    --md-sys-color-surface: #FFFFFF;
    --md-sys-color-surface-dim: #DCE3E8;
    --md-sys-color-surface-bright: #F8FAFC;
    --md-sys-color-surface-container-lowest: #FFFFFF;
    --md-sys-color-surface-container-low: #F8FAFD;
    --md-sys-color-surface-container: #F0F4F9;
    --md-sys-color-surface-container-high: #E9EEF6;
    --md-sys-color-surface-container-highest: #CBD5E1;

    --md-sys-color-on-surface: #0F172A;
    --md-sys-color-on-surface-variant: #475569;
    --md-sys-color-outline: #74777F;
    --md-sys-color-outline-variant: #E2E8F0;

    /* Estados Funcionales Tonales */
    --md-sys-color-success: #15803D;
    --md-sys-color-success-container: #DCFCE7;
    --md-sys-color-on-success-container: #14532D;

    --md-sys-color-warning: #B45309;
    --md-sys-color-warning-container: #FEF3C7;
    --md-sys-color-on-warning-container: #78350F;

    --md-sys-color-error: #BA1A1A;
    --md-sys-color-error-container: #FFDAD6;
    --md-sys-color-on-error-container: #410002;

    /* Elevaciones y Sombras Sutiles M3 */
    --md-sys-elevation-1: 0px 1px 3px 1px rgba(0, 0, 0, 0.05), 0px 1px 2px 0px rgba(0, 0, 0, 0.08);
    --md-sys-elevation-2: 0px 2px 6px 2px rgba(0, 0, 0, 0.05), 0px 1px 2px 0px rgba(0, 0, 0, 0.10);
    --md-sys-elevation-3: 0px 4px 8px 3px rgba(0, 0, 0, 0.06), 0px 1px 3px 0px rgba(0, 0, 0, 0.12);

    /* Safe Area para Android & iOS */
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* Base Body Layout */
body {
    background-color: var(--md-sys-color-surface-container-low);
    color: var(--md-sys-color-on-surface);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

/* Scrollbar M3 Minimalista */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

/* ============================================================================
   FAMILIA DE BOTONES OFICIALES MATERIAL DESIGN 3
   ============================================================================ */
.m3-btn-filled {
    height: 40px;
    padding: 0 20px;
    border-radius: 9999px;
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    font-weight: 600;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: var(--md-sys-elevation-1);
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    border: none;
    cursor: pointer;
    text-decoration: none;
}
.m3-btn-filled:hover {
    background-color: #1648BD;
    box-shadow: var(--md-sys-elevation-2);
}
.m3-btn-filled:active {
    transform: scale(0.98);
}

.m3-btn-tonal {
    height: 40px;
    padding: 0 20px;
    border-radius: 9999px;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    font-weight: 600;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    border: none;
    cursor: pointer;
    text-decoration: none;
}
.m3-btn-tonal:hover {
    background-color: #CADAFA;
}
.m3-btn-tonal:active {
    transform: scale(0.98);
}

.m3-btn-outlined {
    height: 40px;
    padding: 0 20px;
    border-radius: 9999px;
    border: 1px solid var(--md-sys-color-outline-variant);
    background-color: transparent;
    color: var(--md-sys-color-primary);
    font-weight: 600;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    cursor: pointer;
    text-decoration: none;
}
.m3-btn-outlined:hover {
    background-color: rgba(26, 86, 219, 0.05);
    border-color: var(--md-sys-color-primary);
}

.m3-btn-text {
    height: 40px;
    padding: 0 16px;
    border-radius: 9999px;
    background-color: transparent;
    color: var(--md-sys-color-primary);
    font-weight: 600;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
}
.m3-btn-text:hover {
    background-color: rgba(26, 86, 219, 0.08);
}

.m3-btn-danger {
    height: 40px;
    padding: 0 20px;
    border-radius: 9999px;
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
    font-weight: 600;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
}
.m3-btn-danger:hover {
    background-color: #F8B4B4;
}

/* ============================================================================
   SISTEMA DE BADGES Y NOTIFICACIONES M3
   ============================================================================ */
.m3-badge {
    background-color: var(--md-sys-color-error);
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 9999px;
    min-width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}

.m3-badge-soft {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 2px 7px;
    border-radius: 9999px;
}

.m3-badge-dot {
    width: 8px;
    height: 8px;
    background-color: var(--md-sys-color-error);
    border-radius: 9999px;
    border: 2px solid #FFFFFF;
    display: inline-block;
}

/* Badge Fijo para Tarjetas de Módulos (Cero Parpadeo, Material Design 3) */
.m3-card-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    background-color: var(--md-sys-color-error);
    color: #FFFFFF;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.10);
    letter-spacing: 0.025em;
    pointer-events: none;
    z-index: 10;
}

/* ============================================================================
   TARJETAS Y CONTENEDORES M3 (SURFACE CONTAINERS)
   ============================================================================ */
.m3-card {
    background-color: var(--md-sys-color-surface);
    border-radius: 1.5rem; /* 24px */
    border: 1px solid var(--md-sys-color-outline-variant);
    box-shadow: var(--md-sys-elevation-1);
    transition: all 0.25s cubic-bezier(0.2, 0, 0, 1);
}
.m3-card:hover {
    box-shadow: var(--md-sys-elevation-2);
}

.m3-card-tonal {
    background-color: var(--md-sys-color-surface-container);
    border-radius: 1.5rem;
    border: 1px solid var(--md-sys-color-outline-variant);
}

/* Tarjeta Oficial de Módulo Dashboard (Google MD3) */
.m3-card-tile {
    background-color: #FFFFFF;
    padding: 1.25rem;
    border-radius: 1rem;
    border: 1px solid rgba(226, 232, 240, 0.85);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.04);
    transition: all 0.22s cubic-bezier(0.2, 0, 0, 1);
    position: relative;
    display: block;
    overflow: hidden;
    text-decoration: none;
}
@media (min-width: 640px) {
    .m3-card-tile {
        padding: 1.5rem;
    }
}
.m3-card-tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
}
.m3-card-tile:active {
    transform: scale(0.99);
}

.m3-card-tile .m3-tile-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0F172A;
    margin-bottom: 0.25rem;
    line-height: 1.35;
    transition: color 0.2s ease;
}
@media (min-width: 640px) {
    .m3-card-tile .m3-tile-title {
        font-size: 1.125rem;
    }
}
.m3-card-tile:hover .m3-tile-title {
    color: var(--md-sys-color-primary, #0B57D0);
}

.m3-card-tile .m3-tile-desc {
    font-size: 0.8125rem;
    line-height: 1.35rem;
    color: #64748B;
    font-weight: 400;
}
@media (min-width: 640px) {
    .m3-card-tile .m3-tile-desc {
        font-size: 0.875rem;
    }
}

/* ============================================================================
   CAMPOS DE FORMULARIO OUTLINED M3
   ============================================================================ */
.m3-input {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    border-radius: 0.75rem; /* 12px */
    border: 1px solid var(--md-sys-color-outline);
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    font-size: 0.875rem;
    font-weight: 500;
    outline: none;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
}
.m3-input:focus {
    border-color: var(--md-sys-color-primary);
    border-width: 2px;
    padding-left: 15px; /* Compensa el ancho de 2px de borde */
    background-color: #FAFCFF;
}

/* ============================================================================
   ESTILOS DE NAVEGACIÓN M3 (DRAWER & BOTTOM BAR)
   ============================================================================ */
.m3-nav-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
    text-decoration: none;
    transition: all 0.15s cubic-bezier(0.2, 0, 0, 1);
}
.m3-nav-pill:hover {
    background-color: rgba(226, 232, 240, 0.7);
    color: var(--md-sys-color-on-surface);
}
.m3-nav-pill.active {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    font-weight: 700;
}
.m3-nav-pill.active i {
    color: var(--md-sys-color-primary);
}

/* Fondo para Bottom Sheet en móvil */
.m3-bottom-sheet {
    background-color: var(--md-sys-color-surface);
    border-top-left-radius: 2rem;
    border-top-right-radius: 2rem;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
}
