/* ==========================================================================
   Estilos principales – MaxxNet: Análisis Mensual de Ventas
   
   Paleta MaxxNet:
     - Fondo principal:  #f8f9fb (gris muy claro)
     - Superficie:       #ffffff
     - Texto principal:  #1a1a2e
     - Texto secundario: #6b7280
     - Primario (rojo):  #1A365D
     - Primario hover:   #45638F
     - Secundario:       #404040
     - Éxito:            #059669
     - Error:            #dc2626
     - Borde:            #e5e7eb
   ========================================================================== */

/* --- Reset y base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8f9fb;
    color: #1a1a2e;
    line-height: 1.6;
    min-height: 100vh;
}

/* === MODIFICADORES DE BODY === */
/* Login body */
.body--login {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

/* Panel body (Admin/Digitalizador) */
.body--panel {
    background-color: #f3f4f6; /* Ligeramente más oscuro para contrastar con tarjetas */
}

/* === LOGIN Y FORMULARIOS INDIVIDUALES === */
.login-container, .app-container {
    width: 100%;
    max-width: 560px;
    animation: fadeSlideUp 0.6s ease-out;
    margin: 0 auto;
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    padding: 2.5rem 2rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    text-align: center;
    margin-bottom: 2rem;
}

.login-card__logo { margin-bottom: 1.5rem; }
.login-card__logo-img {
    width: 300px;
    max-width: 90%;
    height: auto;
    object-fit: contain;
}
.login-card__title { font-size: 1.5rem; font-weight: 700; color: #1a1a2e; margin-bottom: 0.25rem; }
.login-card__subtitle { font-size: 0.875rem; color: #6b7280; margin-bottom: 2rem; }

/* --- Layout del Panel (Sidebar + Contenido) --- */
.panel-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    transition: transform 0.3s ease;
}

.sidebar__logo {
    padding: 1.5rem;
    border-bottom: 1px solid #f3f4f6;
    text-align: center;
}

.sidebar__logo-img { max-width: 140px; }

.sidebar__nav {
    padding: 1.5rem 1rem;
    flex: 1;
    overflow-y: auto;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #4b5563;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9375rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.sidebar__link:hover {
    background: #f3f4f6;
    color: #1a1a2e;
}

.sidebar__link--active {
    background: #D7E4F5;
    color: #1A365D;
}

.sidebar__link--active svg { color: #1A365D; }

/* Submenús */
.sidebar__dropdown-toggle {
    width: 100%;
    cursor: pointer;
    background: transparent;
    text-align: left;
    position: relative;
}

.sidebar__chevron {
    margin-left: auto;
    transition: transform 0.3s ease;
}

.sidebar__submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding-left: 2.75rem;
    display: flex;
    flex-direction: column;
}

.sidebar__dropdown--open .sidebar__submenu {
    max-height: 200px;
}

.sidebar__dropdown--open .sidebar__chevron {
    transform: rotate(180deg);
}

.sidebar__sublink {
    padding: 0.5rem 0;
    font-size: 0.875rem;
    color: #6b7280;
    text-decoration: none;
    transition: color 0.2s;
}

.sidebar__sublink:hover {
    color: #1a1a2e;
}

.sidebar__sublink--active {
    color: #1A365D;
    font-weight: 600;
}

.sidebar__footer {
    padding: 1.25rem 1rem;
    border-top: 1px solid #f3f4f6;
}

.sidebar__user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0 0.5rem;
}

.sidebar__user-avatar {
    width: 36px;
    height: 36px;
    background: #1A365D;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.sidebar__user-info { display: flex; flex-direction: column; }
.sidebar__user-name { font-size: 0.875rem; font-weight: 600; color: #1a1a2e; }
.sidebar__user-role { font-size: 0.75rem; color: #6b7280; }

.sidebar__link--logout {
    color: #dc2626;
}
.sidebar__link--logout:hover {
    background: #fef2f2;
    color: #991b1b;
}

/* Contenido Principal */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem 2.5rem;
    min-width: 0; /* Previene desbordamiento en flexbox */
}

.page-header { margin-bottom: 2rem; }
.page-title { font-size: 1.75rem; font-weight: 700; color: #1a1a2e; margin-bottom: 0.25rem; }
.page-subtitle { font-size: 0.9375rem; color: #6b7280; }

.flex-between { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.text-center { text-align: center; }
.text-muted { color: #6b7280; }
.font-medium { font-weight: 500; }
.text-sm { font-size: 0.875rem; }
.text-success { color: #059669; }
.w-auto { width: auto !important; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: #6b7280;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}
.back-link:hover { color: #1a1a2e; }

/* --- Componentes --- */

/* Tarjetas */
.card, .form-card {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.form-card { padding: 2rem; }

/* Filtros */
.filter-bar {
    background: #fff;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    margin-bottom: 1.5rem;
}
.filter-form {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}
.filter-group { flex: 1; min-width: 150px; }
.form-input--select { padding-right: 2rem; cursor: pointer; }

/* Tablas */
.table-responsive { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}
.data-table th {
    background: #f9fafb;
    padding: 1rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e5e7eb;
}
.data-table td {
    padding: 1rem 1.5rem;
    font-size: 0.875rem;
    color: #1a1a2e;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f9fafb; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge--pendiente { background: #f3f4f6; color: #4b5563; }
.badge--enviado { background: #D7E4F5; color: #1A365D; }
.badge--llenado { background: #ecfdf5; color: #065f46; }
.badge--admin { background: #eff6ff; color: #1d4ed8; }
.badge--digitalizador { background: #f3f4f6; color: #4b5563; }

/* Botones de acción (Tablas) */
.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-action--primary { background: #1A365D; color: #fff; }
.btn-action--primary:hover { background: #45638F; }
.btn-action--success { background: #059669; color: #fff; }
.btn-action--danger { background: #fee2e2; color: #b91c1c; }
.btn-action--danger:hover { background: #fecaca; }

/* --- Dashboard --- */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: #fff;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.stat-card__icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-card__icon svg { width: 24px; height: 24px; }
.stat-card__icon--gray { background: #f3f4f6; color: #4b5563; }
.stat-card__icon--red { background: #D7E4F5; color: #1A365D; }
.stat-card__icon--green { background: #ecfdf5; color: #059669; }
.stat-card__icon--blue { background: #eff6ff; color: #1d4ed8; }

.stat-card__info { display: flex; flex-direction: column; }
.stat-card__value { font-size: 1.5rem; font-weight: 700; color: #1a1a2e; line-height: 1.2; }
.stat-card__label { font-size: 0.875rem; color: #6b7280; font-weight: 500; }

.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}
.chart-card {
    background: #fff;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}
.chart-card__title { font-size: 1rem; font-weight: 600; color: #1a1a2e; margin-bottom: 1.5rem; }
.chart-container { position: relative; height: 300px; width: 100%; }
.chart-container--dona { height: 250px; }

/* --- Elementos de Formulario base (reusados) --- */
.form-group { margin-bottom: 1.25rem; position: relative; }
.form-label { display: block; font-size: 0.8125rem; font-weight: 600; color: #374151; margin-bottom: 0.5rem; }
.form-input {
    width: 100%; padding: 0.625rem 0.875rem; font-family: inherit; font-size: 0.9375rem;
    color: #1a1a2e; background: #f9fafb; border: 1.5px solid #e5e7eb; border-radius: 8px;
    outline: none; transition: all 0.2s ease;
}
.form-input:focus { border-color: #1A365D; background: #ffffff; box-shadow: 0 0 0 3px rgba(26, 54, 93, 0.1); }
.text-left { text-align: left; }

/* Botones principales */
.btn-submit {
    width: 100%; padding: 0.75rem 1.5rem; font-family: inherit; font-size: 0.9375rem;
    font-weight: 600; color: #ffffff; background: #1A365D; border: none; border-radius: 8px;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    gap: 0.5rem; transition: background 0.2s, transform 0.1s;
}
.btn-submit:hover { background: #45638F; }
.btn-submit--small { padding: 0.625rem 1.25rem; font-size: 0.875rem; }

.btn-submit svg { width: 18px; height: 18px; transition: transform 0.2s ease; }
.btn-submit:hover svg { transform: translateX(2px); }

/* Periodo badge */
.periodo-badge {
    display: inline-flex; align-items: center; gap: 0.5rem;
    background: #D7E4F5; border: 1px solid #849EC2; border-radius: 100px;
    padding: 0.5rem 1.125rem; font-size: 0.875rem; font-weight: 500; color: #45638F;
}
.periodo-badge svg { width: 16px; height: 16px; }

/* Alertas */
.alert {
    padding: 1rem 1.25rem; border-radius: 8px; font-size: 0.875rem; font-weight: 500;
    margin-bottom: 1.5rem; display: flex; align-items: center; gap: 0.625rem;
}
.alert svg { width: 20px; height: 20px; flex-shrink: 0; }
.alert--exito { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.alert--error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

/* Modales */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
    opacity: 0; visibility: hidden; transition: all 0.2s; padding: 1rem;
}
.modal-overlay--visible { opacity: 1; visibility: visible; }
.modal {
    background: #ffffff; border-radius: 12px; padding: 2rem; width: 100%; max-width: 450px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); transform: scale(0.95); transition: all 0.2s;
}
.modal-overlay--visible .modal { transform: scale(1); }
.modal__header { margin-bottom: 1.5rem; text-align: center; }
.modal__title { font-size: 1.25rem; font-weight: 700; color: #1a1a2e; }
.modal__subtitle { font-size: 0.875rem; color: #6b7280; margin-top: 0.25rem;}
.modal__actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.modal__btn {
    flex: 1; padding: 0.625rem 1rem; font-family: inherit; font-size: 0.875rem;
    font-weight: 600; border-radius: 8px; border: none; cursor: pointer; transition: background 0.2s;
}
.modal__btn--cancel { background: #f3f4f6; color: #374151; }
.modal__btn--cancel:hover { background: #e5e7eb; }
.modal__btn--confirm { background: #1A365D; color: #fff; }
.modal__btn--confirm:hover { background: #45638F; }

/* Sidebar Móvil Toggle */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 100;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
}

/* Footer genérico */
.app-footer { text-align: center; padding: 2rem 0; font-size: 0.75rem; color: #9ca3af; }

/* --- Responsive --- */
@media (max-width: 1024px) {
    .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar-toggle { display: block; }
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar--open { transform: translateX(0); }
    .sidebar-overlay--visible { display: block; }
    
    .main-content {
        margin-left: 0;
        padding: 4rem 1rem 2rem 1rem;
    }
    .flex-between { flex-direction: column; align-items: flex-start; }
}
