/* RESET COMPLETO PARA SCROLL */
html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden; /* Previene scroll horizontal en móviles */
    overflow-y: auto;
}

/* Modelo de caja consistente para evitar desbordes por padding/border */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Medios flexibles por defecto */
img, video, canvas, svg {
    max-width: 100%;
    height: auto;
}

/* CONTENEDOR PRINCIPAL CON SCROLL */
.portal-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #ffffff;
    color: #1f2937;
    line-height: 1.5;

    /* SCROLL CONFIGURATION */
    min-height: 100vh;
    height: auto;
    overflow-y: auto;
    overflow-x: hidden; /* Evita desbordes horizontales de hijos */
    display: flex;
    flex-direction: column;
}

/* MAIN QUE CRECE Y PERMITE SCROLL */
.portal-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    margin-top: 16px;

    /* PERMITIR CRECIMIENTO */
    flex: 1;
    width: 100%;
    max-width: 100%;
}

/* Cards */
.portal-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s ease;
    max-width: 100%;
}

.portal-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

/* Botones */
.portal-btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 12px;
    font-weight: 500;
    font-size: 14px;
    text-align: center;
    text-decoration: none;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.portal-btn-primary {
    background: #0901ffac;
    color: white;
    border-color: #0901ffac;
}

.portal-btn-primary:hover {
    background: #0901ffac;
    border-color: #0901ffac;
    transform: translateY(-1px);
}

.portal-btn-ghost {
    background: white;
    color: #1f2937;
    border-color: #e5e7eb;
}

.portal-btn-ghost:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

/* Layout */
.portal-header-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    margin-bottom: 16px;
}

.portal-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

/* Textos */
.portal-title {
    font-size: 24px;
    font-weight: bold;
    color: #111827;
    margin-bottom: 4px;
}

.portal-subtitle {
    font-size: 14px;
    color: #6b7280;
}

.portal-section-title {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 12px;
}

.portal-text-sm {
    font-size: 14px;
}

.portal-text-gray {
    color: #6b7280;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.portal-text-dark {
    color: #111827;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.portal-font-medium {
    font-weight: 500;
}

/* Utilidades */
.portal-flex {
    display: flex;
}

.portal-flex-col {
    flex-direction: column;
}

.portal-items-center {
    align-items: center;
}

.portal-justify-between {
    justify-content: space-between;
}

.portal-gap-2 {
    gap: 8px;
}

.portal-gap-4 {
    gap: 16px;
}

.portal-mt-2 {
    margin-top: 8px;
}

.portal-mt-4 {
    margin-top: 16px;
}

.portal-space-y-2>*+* {
    margin-top: 8px;
}

.portal-space-y-3>*+* {
    margin-top: 12px;
}

.portal-w-full {
    width: 100%;
}

.portal-p-5 {
    padding: 20px;
}

.portal-p-6 {
    padding: 24px;
}

/* Estilos para el Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
    border-radius: 12px 12px 0 0;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.modal-close-btn {
    background: none;
    border: none;
    word-break: break-word;
    overflow-wrap: anywhere;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    color: #374151;
    background: #e5e7eb;
}

.modal-body {
    flex: 1;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden; /* Evita que contenido ancho rompa el viewport */
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    background: #f8fafc;
    border-radius: 0 0 12px 12px;
}

/* Grid de facturas */
.facturas-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
}

.factura-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    transition: all 0.2s;
}

.factura-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.factura-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.factura-id {
    font-weight: 600;
    color: #1f2937;
}

.factura-estado {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.factura-estado.pagado {
    background: #0ea643;
    color: #ffffff;
}

.factura-estado.pendiente {
    background: #e5ff00;
    color: #000000;
}

.factura-estado.vencida {
    background: #dc1a17;
    color: #ffffff;
}

.factura-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.factura-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.factura-row span:first-child {
    color: #6b7280;
}

.factura-row span:last-child {
    color: #1f2937;
    font-weight: 500;
}

.factura-actions {
    display: flex;
    gap: 8px;
}

.btn-descargar,
.btn-ver-detalle {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    color: #374151;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-descargar:hover {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.btn-ver-detalle:hover {
    background: #6b7280;
    color: white;
    border-color: #6b7280;
}

/* Scroll personalizado */
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Estilos adicionales para los nuevos estados y carga */
.factura-estado.vencida {
    background: #fee2e2;
    color: #0901ffac;
}

.cargando-facturas,
.sin-facturas {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: #6b7280;
    font-size: 1.1rem;
}

.cargando-facturas p,
.sin-facturas p {
    margin: 0;
}

/* Mejoras en el diseño de las facturas */
.factura-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.factura-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    padding: 2px 0;
}

.factura-row span:first-child {
    color: #6b7280;
    min-width: 120px;
}

.factura-row span:last-child {
    color: #1f2937;
    font-weight: 500;
    text-align: right;
}

.factura-monto {
    color: #059669 !important;
    font-weight: 600 !important;
    font-size: 1rem !important;
}

/* Estilos para el formulario de ticket */
.modal-ticket {
    max-width: 700px;
}

.ticket-form {
    padding: 0 10px;
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #374151;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
}

.form-separator {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 20px 0;
}

/* Estilos para input de archivo */
.file-input-container {
    position: relative;
    margin-bottom: 8px;
}

.file-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-input-label {
    display: inline-block;
    padding: 10px 16px;
    background: #f8fafc;
    border: 1px dashed #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    text-align: center;
}

.file-input-label:hover {
    background: #f1f5f9;
    border-color: #3b82f6;
}

.file-placeholder {
    color: #6b7280;
    font-size: 14px;
    text-align: center;
    padding: 8px;
    background: #f9fafb;
    border-radius: 4px;
}

/* Barra de herramientas de texto */
.text-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    padding: 10px;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.toolbar-btn {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.toolbar-btn:active {
    background: #e5e7eb;
}

/* Estados de carga */
.modal-footer .portal-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
    }

    .portal-main {
        padding: 12px;
        margin-top: 12px;
    }

    .portal-container {
        padding: 0;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal-ticket {
        margin: 10px;
        width: calc(100% - 20px);
    }

    .modal-content {
        max-width: 100%;
    }
}

/* Responsive */
@media (min-width: 768px) {
    .portal-header-section {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

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

    .portal-title {
        font-size: 30px;
    }
}

@media (min-width: 1024px) {
    .portal-main {
        padding: 24px;
    }
}

/* Animación para los puntos de carga */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}