/**
 * Dashboard Modular Styles
 * SIGES SAEMPRO - Dashboard Architecture v2.0
 */

/* Variables CSS */
:root {
    --dashboard-primary: #007bff;
    --dashboard-secondary: #6c757d;
    --dashboard-success: #28a745;
    --dashboard-info: #17a2b8;
    --dashboard-warning: #ffc107;
    --dashboard-danger: #dc3545;
    --dashboard-light: #f8f9fa;
    --dashboard-dark: #343a40;
    
    --dashboard-border-radius: 0.5rem;
    --dashboard-box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --dashboard-box-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    
    --dashboard-transition: all 0.3s ease;
    --dashboard-animation-duration: 0.6s;

    /* Sidebar - Azul Rey */
    --sidebar-bg: #FFFFFF;       /* usa fondo blanco por defecto del aside */
    --sidebar-hover: rgba(0,0,0,0.06); /* hover suave gris */
    --sidebar-active: rgba(0,0,0,0.08);/* activo suave gris */
    --sidebar-text: #111111;     /* texto negro solicitado */
    --sidebar-border: #e5e7eb;   /* borde gris claro */
    --sidebar-transition: 0.2s ease-in-out;
    --sidebar-accordion-duration: 0.3s ease;
}

html.dark {
    --sidebar-bg: #0b1220;
    --sidebar-hover: rgba(255,255,255,0.06);
    --sidebar-active: rgba(255,255,255,0.10);
    --sidebar-text: #e5e7eb;
    --sidebar-border: #1f2937;
}

/* Layout Base */
.dashboard-container {
    padding: 1rem;
    max-width: 100%;
    margin: 0 auto;
}

/* Header Styles */
.dashboard-header {
    background: linear-gradient(135deg, var(--dashboard-primary), #0056b3);
    color: white;
    padding: 1.5rem;
    border-radius: var(--dashboard-border-radius);
    margin-bottom: 1.5rem;
    box-shadow: var(--dashboard-box-shadow-lg);
}

.dashboard-header h2 {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.dashboard-header .badge {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
}

/* Metrics Container */
.metrics-container {
    margin-bottom: 2rem;
}

.metrics-container .card {
    border: none;
    border-radius: var(--dashboard-border-radius);
    box-shadow: var(--dashboard-box-shadow);
    transition: var(--dashboard-transition);
    cursor: pointer;
}

.metrics-container .card:hover {
    transform: translateY(-2px);
    box-shadow: var(--dashboard-box-shadow-lg);
}

.metrics-container .card-body {
    padding: 1.5rem;
}

.metrics-container .card h3 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0;
}

.metrics-container .card h6 {
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Module Cards */
.module-card {
    margin-bottom: 2rem;
}

.module-card .card {
    border: none;
    border-radius: var(--dashboard-border-radius);
    box-shadow: var(--dashboard-box-shadow);
    overflow: hidden;
    transition: var(--dashboard-transition);
}

.module-card .card:hover {
    box-shadow: var(--dashboard-box-shadow-lg);
}

.module-card .card-header {
    border-bottom: none;
    padding: 1.25rem 1.5rem;
    font-weight: 600;
}

.module-card .card-body {
    padding: 1.5rem;
}

/* Submodule Buttons */
.module-card .btn {
    border-radius: var(--dashboard-border-radius);
    font-weight: 500;
    transition: var(--dashboard-transition);
    text-decoration: none !important;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    padding: 1rem;
}

.module-card .btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--dashboard-box-shadow);
}

.module-card .btn span {
    font-size: 1.25rem;
}

/* Compact Modules */
.compact-modules .btn {
    min-height: 100px;
    flex-direction: column;
    gap: 0.5rem;
}

.compact-modules .btn .fs-3 {
    font-size: 2rem !important;
}

.compact-modules .btn small {
    font-size: 0.75rem;
    line-height: 1.2;
}

/* Notifications */
.dashboard-notifications .alert {
    border: none;
    border-radius: var(--dashboard-border-radius);
    box-shadow: var(--dashboard-box-shadow);
    margin-bottom: 1rem;
}

.dashboard-notifications .border-start {
    border-left-width: 4px !important;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp var(--dashboard-animation-duration) ease-out forwards;
    opacity: 0;
}

/* Loading States */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Responsive Design */

/* Mobile First */
@media (max-width: 767.98px) {
    .dashboard-container {
        padding: 0.5rem;
    }
    
    .dashboard-header {
        padding: 1rem;
        text-align: center;
    }
    
    .dashboard-header .col-md-4 {
        margin-top: 1rem;
    }
    
    .metrics-container .card h3 {
        font-size: 1.5rem;
    }
    
    .module-card .btn {
        min-height: 60px;
        font-size: 0.875rem;
    }
    
    .compact-modules .btn {
        min-height: 80px;
    }
    
    .compact-modules .btn .fs-3 {
        font-size: 1.5rem !important;
    }
}

/* Sidebar Accordion (Azul Rey) */
#app-sidebar {
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text) !important;
    border-right: 1px solid var(--sidebar-border);
}

.sidebar-nav {
    color: var(--sidebar-text);
}

.sidebar-section { margin-bottom: 0.25rem; }

.section-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start; /* alinear a la izquierda */
    gap: 0.5rem; /* reducir separación para ganar espacio */
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    background: transparent;
    color: var(--sidebar-text);
    cursor: pointer;
    transition: background-color var(--sidebar-transition), transform var(--sidebar-transition), color var(--sidebar-transition);
}
.section-header:hover {
    background-color: var(--sidebar-hover);
    color: var(--sidebar-text);
}
.section-header:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--sidebar-border);
    border-radius: 0.75rem;
}
.section-title { font-weight: 600; flex: 1; }

/* ocultar el chevron derecho para liberar espacio */
.chevron { display: none; }

/* asegurar ancho constante para iconos y texto alineado */
.section-icon { min-width: 22px; text-align: center; }

.section-content {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height var(--sidebar-accordion-duration), opacity var(--sidebar-accordion-duration);
}
.section-content.open {
    max-height: 800px; /* suficiente para el contenido */
    opacity: 1;
}

.sidebar-option {
    display: flex; /* icono y texto alineados a la izquierda */
    align-items: center;
    gap: 0.5rem;
    margin: 2px 0;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    color: #111111;
    text-decoration: none;
    transition: background-color var(--sidebar-transition), transform var(--sidebar-transition), color var(--sidebar-transition), border-left var(--sidebar-transition);
}
.sidebar-option:hover {
    background-color: var(--sidebar-hover);
    color: #111111;
}
.sidebar-option.is-active {
    background-color: var(--sidebar-active);
    color: #111111;
    border-left: 4px solid var(--sidebar-border);
}

/* normalizar icono/texto dentro de opciones */
.option-icon { min-width: 22px; text-align: center; }
.option-text { flex: 1; }

/* Tablet */
@media (min-width: 768px) and (max-width: 1023.98px) {
    .dashboard-container {
        padding: 0.75rem;
    }
    
    .metrics-container .card h3 {
        font-size: 1.75rem;
    }
    
    .module-card .btn {
        min-height: 70px;
    }
    
    .compact-modules .btn {
        min-height: 90px;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .dashboard-container {
        padding: 1rem;
        max-width: 1200px;
    }
}

/* Wide Screen */
@media (min-width: 1400px) {
    .dashboard-container {
        max-width: 1400px;
    }
    
    .metrics-container .card h3 {
        font-size: 2.25rem;
    }
}

/* Layout Classes */
.mobile-layout {
    --dashboard-border-radius: 0.375rem;
}

.tablet-layout {
    --dashboard-border-radius: 0.5rem;
}

.desktop-layout {
    --dashboard-border-radius: 0.5rem;
}

.wide-layout {
    --dashboard-border-radius: 0.75rem;
}

/* Compact Mode */
.compact-mode .dashboard-header {
    padding: 1rem 1.5rem;
}

.compact-mode .metrics-container .card-body {
    padding: 1rem;
}

.compact-mode .module-card .card-body {
    padding: 1rem;
}

.compact-mode .module-card .btn {
    min-height: 60px;
    font-size: 0.875rem;
}

/* Dark Theme Support */
.dark {
    --dashboard-light: #2d3748;
    --dashboard-dark: #f7fafc;
}

.dark .dashboard-container {
    background-color: #1a202c;
    color: #f7fafc;
}

.dark .card {
    background-color: #2d3748;
    border-color: #4a5568;
}

.dark .alert {
    background-color: #2d3748;
    border-color: #4a5568;
    color: #f7fafc;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .dashboard-container {
        --dashboard-box-shadow: 0 0 0 2px #000;
    }
    
    .card {
        border: 2px solid #000;
    }
    
    .btn {
        border: 2px solid #000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .fade-in-up {
        animation: none;
        opacity: 1;
    }
}

/* Print Styles */
@media print {
    .dashboard-header,
    .dashboard-notifications {
        break-inside: avoid;
    }
    
    .module-card {
        break-inside: avoid;
        margin-bottom: 1rem;
    }
    
    .btn {
        border: 1px solid #000 !important;
        background: transparent !important;
        color: #000 !important;
    }
}

/* Accessibility Improvements */
.btn:focus,
.card:focus {
    outline: 2px solid var(--dashboard-primary);
    outline-offset: 2px;
}

.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;
}

/* Utility Classes */
.text-gradient {
    background: linear-gradient(135deg, var(--dashboard-primary), #0056b3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.shadow-soft {
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.1);
}

.border-gradient {
    border: 2px solid;
    border-image: linear-gradient(135deg, var(--dashboard-primary), #0056b3) 1;
}
