/* ============================================================
   ADMINLTE STYLE SYSTEM - FRONTGROUP
   Diseño moderno modular para paneles de Administración y Empresa.
   Colores principales: #0078ff (Azul primario)
============================================================ */

/* ==================== 1. VARIABLES & DESIGN TOKENS ==================== */
:root {
    /* Colores principales */
    --primary: #0078ff;
    --primary-dark: #005fcc;
    --primary-light: #3395ff;

    /* Sidebar */
    --sidebar-bg: #343a40;
    --sidebar-text: #c2c7d0;
    --sidebar-hover: #007bff;
    --sidebar-active: #0078ff;

    /* Backgrounds */
    --body-bg: #f4f6f9;
    --white: #ffffff;
    --light: #f8f9fa;

    /* Text */
    --text-dark: #495057;
    --text-muted: #6c757d;

    /* Borders */
    --border-color: #dee2e6;

    /* Shadows */
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

/* ==================== 2. RESET & BASE TYPOGRAPHY ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--body-bg);
    color: var(--text-dark);
    font-size: 1rem;
    line-height: 1.5;
}

/* ==================== 3. NAVIGATION SIDEBAR ==================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 250px;
    background: var(--sidebar-bg);
    z-index: 1000;
    overflow-y: auto;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar-brand {
    padding: 1rem 1.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: #ffffff;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-menu {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
}

.sidebar-menu li {
    margin: 0;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.3s;
}

.sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
    padding-left: 1.75rem;
}

.sidebar-menu a.active {
    background: var(--sidebar-active);
    color: #ffffff;
    border-left: 3px solid #ffffff;
}

.sidebar-menu i {
    margin-right: 0.75rem;
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.logout-link {
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.logout-link:hover {
    color: #ffffff;
}

/* ==================== 4. LAYOUT & CONTENT WRAPPER ==================== */
.content-wrapper {
    margin-left: 250px;
    min-height: 100vh;
    padding: 1.5rem;
}

.content-header {
    margin-bottom: 1.5rem;
}

.content-header h1 {
    font-size: 1.8rem;
    font-weight: 400;
    color: var(--text-dark);
    margin: 0;
}

/* ==================== 5. CARDS & CONTAINERS ==================== */
.card {
    background: var(--white);
    border-radius: 0.25rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    border: 0;
}

.card-header {
    padding: 0.75rem 1.25rem;
    background: transparent;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
    color: var(--text-dark);
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 0.75rem 1.25rem;
    background: var(--light);
    border-top: 1px solid var(--border-color);
}

/* ==================== 6. TABLES & DATA LISTS ==================== */
.table {
    width: 100%;
    margin-bottom: 0;
    color: var(--text-dark);
}

.table thead th {
    border-bottom: 2px solid var(--border-color);
    padding: 0.75rem;
    font-weight: 600;
    background: var(--light);
    color: var(--text-dark);
}

.table tbody td {
    padding: 0.75rem;
    border-top: 1px solid var(--border-color);
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background: rgba(0, 0, 0, 0.02);
}

.table-striped tbody tr:nth-of-type(odd) {
    background: rgba(0, 0, 0, 0.02);
}

/* ==================== 7. BUTTONS & ACTIONS ==================== */
.btn {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 0.25rem;
    transition: all 0.15s;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #ffffff;
}

.btn-success {
    background: #28a745;
    border-color: #28a745;
    color: #ffffff;
}

.btn-success:hover {
    background: #218838;
    border-color: #1e7e34;
}

.btn-danger {
    background: #dc3545;
    border-color: #dc3545;
    color: #ffffff;
}

.btn-danger:hover {
    background: #c82333;
    border-color: #bd2130;
}

.btn-info {
    background: #17a2b8;
    border-color: #17a2b8;
    color: #ffffff;
}

.btn-secondary {
    background: #6c757d;
    border-color: #6c757d;
    color: #ffffff;
}

.btn-secondary:hover {
    background: #5a6268;
    border-color: #545b62;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.btn-block {
    display: block;
    width: 100%;
    padding: 0.75rem;
    font-size: 1.1rem;
}

/* ==================== 8. FORM GROUPS & CONTROLS ==================== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark);
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-dark);
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    transition: border-color 0.15s;
}

.form-control:focus {
    border-color: var(--primary);
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 120, 255, 0.25);
}

/* ==================== 9. LOGIN PAGE LAYOUT ==================== */
.login-page {
    display: flex;
    min-height: 100vh;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background-color: var(--body-bg);
}

.login-bg-side {
    flex: 1;
    background-image: url('../img/backgrounds/login.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    min-height: 100vh;
}

.login-sidebar {
    width: 450px;
    max-width: 100%;
    background: var(--white);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2.5rem 2rem;
    box-shadow: -0.5rem 0 1.5rem rgba(0, 0, 0, 0.1);
    z-index: 10;
    min-height: 100vh;
    overflow-y: auto;
}

.login-sidebar-content {
    width: 100%;
    max-width: 360px;
    margin: auto 0;
}

.login-logo {
    max-width: 240px;
    height: auto;
    display: block;
    margin: 0 auto 1.5rem auto;
}

.login-box {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: var(--white);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-card-header {
    text-align: center;
    padding-bottom: 1rem;
}

.login-card-header h1 {
    font-size: 1.5rem;
    font-weight: 400;
    margin: 0;
}

.login-card-body {
    padding: 0.5rem 0;
}

/* ==================== 10. DASHBOARD WIDGETS & CHARTS ==================== */
.info-box {
    display: flex;
    background: var(--white);
    border-radius: 0.25rem;
    box-shadow: var(--shadow-sm);
    padding: 1rem;
    margin-bottom: 1rem;
}

.info-box-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    border-radius: 0.25rem;
    font-size: 2rem;
    color: #ffffff;
}

.info-box-icon.bg-primary {
    background: var(--primary);
}

.info-box-content {
    flex: 1;
    padding-left: 1rem;
}

.info-box-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
}

.info-box-number {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

/* Cuadrícula compacta de gráficas del dashboard */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

.chart-card {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.chart-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.75rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 220px;
    max-height: 220px;
}

/* ==================== 11. PERSONALIZACIÓN DE MARCA (PREVIEWS) ==================== */
.personalizacion-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.personalizacion-box {
    background: var(--light);
    padding: 1.25rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.preview-box {
    width: 100%;
    max-width: 320px;
    height: 160px;
    border: 2px dashed var(--border-color);
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-top: 0.75rem;
    background: var(--white);
    padding: 0.5rem;
}

.preview-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ==================== 12. PLANTILLAS & SECCIONES DINÁMICAS ==================== */
.encuesta-form {
    background: var(--white);
    padding: 2rem;
    border-radius: 0.25rem;
    box-shadow: var(--shadow-sm);
}

.seccion-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary);
}

.seccion-card h3 {
    margin: 0 0 1rem 0;
    color: var(--primary);
}

.seccion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.seccion-header input {
    flex: 1;
    margin-right: 1rem;
}

.pregunta-card {
    background: var(--white);
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

.pregunta-card label {
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.pregunta-card input[type="radio"],
.pregunta-card input[type="checkbox"] {
    margin-right: 0.5rem;
}

.pregunta-card textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    min-height: 100px;
}

.opcion {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.opcion input {
    flex: 1;
}

/* ==================== 13. REPORTES ANALÍTICOS ==================== */
.seccion-header-reporte {
    border-left: 5px solid var(--primary);
}

.summary-card {
    transition: transform 0.2s;
}

.summary-card:hover {
    transform: translateY(-5px);
}

.report-chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    margin-top: 20px;
}

.mini-chart {
    height: 200px;
    margin-top: 10px;
}

.filtros-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
}

.filtros-card .card-header {
    background-color: rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.filtro-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 5px;
}

.badge-filter {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    margin-right: 5px;
    margin-bottom: 5px;
    display: inline-block;
}

.badge-filter i {
    margin-left: 5px;
    cursor: pointer;
}

.badge-filter i:hover {
    color: #ffc107;
}

.btn-filter-reset {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-filter-reset:hover {
    background-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

.filtros-activos {
    background-color: #e9ecef;
    border-radius: 8px;
    padding: 10px;
    margin-top: 10px;
}

.export-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.info-peso {
    background-color: #e3f2fd;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.9rem;
}

.table-ponderada th {
    background-color: #d1ecf1;
}

.word-cloud-container {
    width: 100%;
    height: 300px;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    position: relative;
    overflow: hidden;
}

.word-cloud-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.cloud-loading, .cloud-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
}

.cloud-empty {
    font-style: italic;
}

.chart-wrapper {
    height: 300px;
    width: 100%;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    padding: 10px;
}

.view-tabs .btn {
    border-radius: 0;
}

.view-tabs .btn.active {
    background-color: var(--primary);
    color: #ffffff;
}

.view-tabs .btn:not(.active) {
    background-color: var(--light);
    color: #333333;
}

.view-tabs .btn:hover:not(.active) {
    background-color: #e9ecef;
}

.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ==================== 14. MODALES ==================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1050;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    outline: 0;
}

.modal.fade {
    transition: opacity 0.15s linear;
}

.modal.show {
    display: block !important;
    opacity: 1;
}

.modal-dialog {
    position: relative;
    width: auto;
    margin: 1.75rem auto;
    max-width: 500px;
    pointer-events: none;
}

.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
    transform: translate(0, -50px);
}

.modal.show .modal-dialog {
    transform: none;
}

.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    background-color: var(--white);
    background-clip: padding-box;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 0.5rem;
    outline: 0;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    width: 100vw;
    height: 100vh;
    background-color: #000000;
}

.modal-backdrop.fade {
    opacity: 0;
}

.modal-backdrop.show {
    opacity: 0.5;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
}

.modal-title {
    margin: 0;
    line-height: 1.5;
    font-size: 1.25rem;
}

.modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 1rem;
}

.modal-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    padding: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.btn-close {
    box-sizing: content-box;
    width: 1em;
    height: 1em;
    padding: 0.25em;
    color: #000000;
    background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
    border: 0;
    border-radius: 0.25rem;
    opacity: 0.5;
    cursor: pointer;
}

.btn-close:hover {
    opacity: 0.75;
}

.btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.d-none {
    display: none !important;
}

/* ==================== 15. UTILITIES & ALERTS ==================== */
.alert {
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: 0.25rem;
    position: relative;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeeba;
}

.alert .close {
    position: absolute;
    top: 0;
    right: 0;
    padding: 0.75rem 1.25rem;
    color: inherit;
    background: transparent;
    border: 0;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.5;
}

.alert .close:hover {
    opacity: 0.75;
}

.text-center {
    text-align: center !important;
}

.text-primary {
    color: var(--primary) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.mb-3 {
    margin-bottom: 1rem !important;
}

.mt-4 {
    margin-top: 1.5rem !important;
}

.d-flex {
    display: flex !important;
}

.align-items-center {
    align-items: center !important;
}

.justify-content-center {
    justify-content: center !important;
}

/* ==================== 16. RESPONSIVE MEDIA QUERIES ==================== */
@media (max-width: 992px) {
    .charts-grid {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    }
}

@media (max-width: 768px) {
    .sidebar {
        margin-left: -250px;
    }

    .content-wrapper {
        margin-left: 0;
    }

    .login-page {
        flex-direction: column;
    }

    .login-bg-side {
        display: none;
    }

    .login-sidebar {
        width: 100%;
        min-height: 100vh;
        box-shadow: none;
        padding: 2rem 1.5rem;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .personalizacion-grid {
        grid-template-columns: 1fr;
    }
}