/* ====================================
   Portal de Clientes - CSS Responsive
   Mobile-First Design
   ==================================== */

/* Variables CSS */
:root {
    --portal-primary: #3498db;
    --portal-primary-dark: #2980b9;
    --portal-secondary: #95a5a6;
    --portal-secondary-dark: #7f8c8d;
    --portal-success: #28a745;
    --portal-warning: #f0ad4e;
    --portal-danger: #d9534f;
    --portal-dark: #2c3e50;
    --portal-gray: #666;
    --portal-light-gray: #f5f5f5;
    --portal-white: #ffffff;
    --portal-border: #ddd;

    --portal-radius: 8px;
    --portal-shadow: 0 2px 10px rgba(0,0,0,0.1);
    --portal-transition: 0.2s ease;
}

/* Reset y Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #333;
    background-color: var(--portal-light-gray);
    -webkit-font-smoothing: antialiased;
}

/* ====================================
   Contenedor Principal
   ==================================== */

.portal-container {
    min-height: 100vh;
    padding: 0;
}

/* ====================================
   Header
   ==================================== */

.portal-header {
    background: var(--portal-dark);
    color: var(--portal-white);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.portal-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.btn-salir {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    color: var(--portal-white);
    text-decoration: none;
    transition: all var(--portal-transition);
}

.btn-salir:hover {
    background: var(--portal-danger);
    transform: scale(1.05);
}

.btn-salir svg {
    flex-shrink: 0;
}

/* ====================================
   Contenido Principal
   ==================================== */

.portal-content {
    background: var(--portal-white);
    padding: 1.5rem 1rem;
    min-height: calc(100vh - 80px);
}

.portal-content h2 {
    font-size: 1.5rem;
    color: var(--portal-dark);
    margin-bottom: 0.5rem;
}

.portal-content h3 {
    font-size: 1.25rem;
    color: var(--portal-dark);
    margin: 1.5rem 0 1rem 0;
}

.portal-content p {
    color: var(--portal-gray);
    margin-bottom: 1rem;
}

.portal-content hr {
    border: none;
    border-top: 1px solid var(--portal-border);
    margin: 1.5rem 0;
}

/* ====================================
   Alertas
   ==================================== */

.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--portal-radius);
    font-size: 0.95rem;
}

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

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ====================================
   Formularios
   ==================================== */

.form-group {
    margin-bottom: 1.25rem;
}

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

.form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--portal-border);
    border-radius: var(--portal-radius);
    font-size: 1rem;
    transition: border-color var(--portal-transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--portal-primary);
}

.form-hint {
    display: block;
    font-size: 0.85rem;
    color: var(--portal-gray);
    margin-top: 0.25rem;
}

.form-file {
    display: block;
    width: 100%;
    padding: 1rem;
    border: 2px dashed var(--portal-border);
    border-radius: var(--portal-radius);
    background: var(--portal-light-gray);
    cursor: pointer;
    text-align: center;
}

.form-file:focus {
    outline: none;
    border-color: var(--portal-primary);
}

/* ====================================
   Botones
   ==================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--portal-radius);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--portal-transition);
    min-height: 48px;
}

.btn-primary {
    background: var(--portal-primary);
    color: var(--portal-white);
}

.btn-primary:hover,
.btn-primary:active {
    background: var(--portal-primary-dark);
}

.btn-secondary {
    background: var(--portal-secondary);
    color: var(--portal-white);
}

.btn-secondary:hover,
.btn-secondary:active {
    background: var(--portal-secondary-dark);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* ====================================
   Info Box
   ==================================== */

.info-box {
    background: var(--portal-light-gray);
    padding: 1.25rem;
    border-radius: var(--portal-radius);
    margin-top: 2rem;
}

.info-box h3 {
    margin-top: 0;
    font-size: 1.1rem;
}

.info-box ol {
    margin: 0;
    padding-left: 1.25rem;
}

.info-box li {
    margin-bottom: 0.5rem;
    color: var(--portal-gray);
}

/* ====================================
   Cliente Info
   ==================================== */

.cliente-info {
    background: var(--portal-light-gray);
    padding: 1rem;
    border-radius: var(--portal-radius);
    margin-bottom: 1.5rem;
}

.cliente-info p {
    margin: 0;
    font-size: 0.95rem;
}

.cliente-info strong {
    color: var(--portal-dark);
}

/* ====================================
   Boletas Cards (Mobile)
   ==================================== */

.boletas-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.boleta-card {
    background: var(--portal-white);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.boleta-card-header {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: var(--portal-light-gray);
    gap: 0.75rem;
}

.boleta-card-header input[type="checkbox"] {
    width: 24px;
    height: 24px;
    cursor: pointer;
}

.boleta-card-header .boleta-numero {
    font-weight: 600;
    color: var(--portal-dark);
    flex: 1;
}

.boleta-card-header .boleta-estado {
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
}

.boleta-estado-pendiente {
    background: #fff3cd;
    color: #856404;
}

.boleta-estado-rechazada {
    background: #f8d7da;
    color: #721c24;
}

.boleta-estado-revision {
    background: #cce5ff;
    color: #004085;
}

.boleta-card-body {
    padding: 1rem;
}

.boleta-detail {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
}

.boleta-detail:last-child {
    border-bottom: none;
}

.boleta-detail-label {
    color: var(--portal-gray);
    font-size: 0.9rem;
}

.boleta-detail-value {
    font-weight: 500;
    color: var(--portal-dark);
}

.boleta-total {
    font-size: 1.25rem;
    color: var(--portal-primary);
}

.boleta-rechazo {
    background: #fff3cd;
    padding: 0.75rem;
    border-radius: var(--portal-radius);
    margin-top: 0.75rem;
    font-size: 0.9rem;
}

.boleta-rechazo strong {
    display: block;
    margin-bottom: 0.25rem;
    color: #856404;
}

/* ====================================
   Resumen de Pago
   ==================================== */

.pago-resumen {
    background: var(--portal-dark);
    color: var(--portal-white);
    padding: 1.25rem;
    border-radius: var(--portal-radius);
    margin: 1.5rem 0;
    text-align: center;
}

.pago-resumen-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.pago-resumen-total {
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

/* ====================================
   Select All Bar
   ==================================== */

.select-all-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--portal-light-gray);
    border-radius: var(--portal-radius);
    margin-bottom: 1rem;
}

.select-all-bar input[type="checkbox"] {
    width: 24px;
    height: 24px;
}

.select-all-bar label {
    font-weight: 500;
    color: var(--portal-dark);
}

/* ====================================
   Sin Boletas
   ==================================== */

.no-boletas {
    text-align: center;
    padding: 3rem 1.5rem;
    background: #d4edda;
    border-radius: var(--portal-radius);
}

.no-boletas-icon {
    font-size: 3rem;
    color: var(--portal-success);
    margin-bottom: 1rem;
}

.no-boletas h3 {
    color: #155724;
    margin-bottom: 0.5rem;
}

.no-boletas p {
    color: #155724;
    margin: 0;
}

/* ====================================
   Confirmacion
   ==================================== */

.confirmacion {
    text-align: center;
    padding: 2rem 1rem;
}

.confirmacion-icon {
    font-size: 4rem;
    color: var(--portal-success);
    margin-bottom: 1rem;
}

.confirmacion h2 {
    color: var(--portal-success);
    margin-bottom: 1rem;
}

.confirmacion p {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

/* ====================================
   Tabla Desktop (oculta en mobile)
   ==================================== */

.tabla-desktop {
    display: none;
}

/* ====================================
   Responsive - Tablet y Desktop
   ==================================== */

@media (min-width: 768px) {
    .portal-container {
        max-width: 900px;
        margin: 2rem auto;
        padding: 0 1rem;
    }

    .portal-header {
        border-radius: var(--portal-radius) var(--portal-radius) 0 0;
        padding: 1.5rem;
    }

    .portal-header h1 {
        font-size: 1.5rem;
    }

    .portal-content {
        padding: 2rem;
        border-radius: 0 0 var(--portal-radius) var(--portal-radius);
        box-shadow: var(--portal-shadow);
    }

    .btn-group {
        flex-direction: row;
        justify-content: flex-start;
    }

    .btn-block {
        width: auto;
    }

    /* Mostrar tabla en desktop, ocultar cards */
    .tabla-desktop {
        display: table;
        width: 100%;
        border-collapse: collapse;
    }

    .tabla-desktop th,
    .tabla-desktop td {
        padding: 0.875rem;
        border: 1px solid var(--portal-border);
        text-align: left;
    }

    .tabla-desktop th {
        background: var(--portal-light-gray);
        font-weight: 600;
        color: var(--portal-dark);
    }

    .tabla-desktop tr:hover {
        background: #fafafa;
    }

    .tabla-desktop .text-center {
        text-align: center;
    }

    .tabla-desktop .text-right {
        text-align: right;
    }

    .tabla-desktop tfoot tr {
        background: var(--portal-light-gray);
        font-weight: 600;
    }

    .boletas-list {
        display: none;
    }

    .pago-resumen {
        max-width: 300px;
        margin-left: auto;
        margin-right: 0;
    }
}

/* ====================================
   Utilidades
   ==================================== */

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

.text-muted {
    color: var(--portal-gray);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ====================================
   Sticky Bar de Pago
   ==================================== */

.pago-sticky-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--portal-primary);
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--portal-radius);
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.pago-sticky-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pago-sticky-count {
    font-size: 0.85rem;
    opacity: 0.9;
}

.pago-sticky-total {
    font-size: 1.25rem;
    font-weight: 700;
}

.btn-pagar {
    padding: 10px 20px;
    font-weight: 600;
    white-space: nowrap;
}

.btn-pagar:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ====================================
   Lista Compacta de Boletas
   ==================================== */

.boletas-lista-compact {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.boleta-item {
    background: white;
    border-radius: var(--portal-radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--portal-border);
}

.boleta-item.boleta-rechazada {
    border-left: 4px solid var(--portal-danger);
}

.boleta-item.en-revision {
    border-left: 4px solid var(--portal-primary);
    opacity: 0.85;
}

.boleta-row {
    display: flex;
    align-items: center;
    padding: 12px;
    gap: 12px;
}

.boleta-row input[type="checkbox"] {
    width: 22px;
    height: 22px;
    cursor: pointer;
    flex-shrink: 0;
}

.boleta-info-compact {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.boleta-numero {
    font-weight: 600;
    color: var(--portal-dark);
}

.boleta-periodo {
    font-size: 0.85rem;
    color: var(--portal-gray);
}

.boleta-estado-tag {
    font-size: 0.75rem;
    background: #cce5ff;
    color: #004085;
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
    width: fit-content;
}

.boleta-monto {
    font-weight: bold;
    font-size: 1.1em;
    color: var(--portal-primary);
    white-space: nowrap;
}

.boleta-acciones {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--portal-gray);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all var(--portal-transition);
}

.btn-icon:hover {
    background: var(--portal-light-gray);
    color: var(--portal-primary);
}

.btn-expandir {
    transition: transform var(--portal-transition);
}

.btn-expandir.rotated {
    transform: rotate(180deg);
}

/* Detalle expandible */
.boleta-detalle {
    display: none;
    background: var(--portal-light-gray);
    padding: 12px;
    border-top: 1px solid var(--portal-border);
}

.boleta-detalle.show {
    display: block;
}

.detalle-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.detalle-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detalle-label {
    font-size: 0.75rem;
    color: var(--portal-gray);
    text-transform: uppercase;
}

.detalle-value {
    font-weight: 500;
    color: var(--portal-dark);
}

.alerta-rechazo {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 10px 12px;
    margin-top: 12px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.alerta-rechazo strong {
    color: #856404;
}

.alerta-rechazo a {
    color: var(--portal-primary);
}

/* Info de revision */
.boleta-revision-info {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--portal-light-gray);
    font-size: 0.85rem;
}

.boleta-revision-info a {
    color: var(--portal-primary);
}

/* ====================================
   Seccion En Revision (Details)
   ==================================== */

.seccion-revision {
    margin-top: 24px;
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    overflow: hidden;
}

.seccion-revision summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--portal-light-gray);
    cursor: pointer;
    font-weight: 500;
    color: var(--portal-dark);
    list-style: none;
}

.seccion-revision summary::-webkit-details-marker {
    display: none;
}

.seccion-revision summary::after {
    content: '';
    margin-left: auto;
    border: solid var(--portal-gray);
    border-width: 0 2px 2px 0;
    padding: 4px;
    transform: rotate(45deg);
    transition: transform var(--portal-transition);
}

.seccion-revision[open] summary::after {
    transform: rotate(-135deg);
}

.revision-badge {
    background: var(--portal-primary);
    color: white;
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 10px;
}

.seccion-revision .boletas-lista-compact {
    padding: 12px;
}

/* ====================================
   Modal de Pago
   ==================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 500px;
    border-radius: 16px 16px 0 0;
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
}

.modal-overlay.show .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--portal-border);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--portal-dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--portal-gray);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--portal-dark);
}

.modal-body {
    padding: 20px;
}

.pago-resumen-modal {
    background: var(--portal-light-gray);
    padding: 16px;
    border-radius: var(--portal-radius);
    margin-bottom: 20px;
    text-align: center;
}

.pago-resumen-modal p {
    margin: 0;
}

.pago-resumen-modal .total-grande {
    font-size: 1.5rem;
    margin-top: 8px;
}

.pago-resumen-modal .total-grande strong {
    color: var(--portal-primary);
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--portal-border);
}

.modal-footer .btn {
    flex: 1;
}

/* ====================================
   Responsive - Desktop Modal
   ==================================== */

@media (min-width: 768px) {
    .modal-overlay {
        align-items: center;
    }

    .modal-content {
        border-radius: 16px;
        transform: translateY(20px) scale(0.95);
    }

    .modal-overlay.show .modal-content {
        transform: translateY(0) scale(1);
    }

    .detalle-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 400px) {
    .detalle-grid {
        grid-template-columns: 1fr 1fr;
    }

    .pago-sticky-bar {
        padding: 10px 12px;
    }

    .pago-sticky-total {
        font-size: 1.1rem;
    }

    .btn-pagar {
        padding: 8px 14px;
        font-size: 0.9rem;
    }
}

/* ====================================
   Accesibilidad
   ==================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
