/* Payment Page Styles */

.payment-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
}

/* Modal Overlay and Dialog */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    animation: fadeIn 0.3s ease;
    pointer-events: auto;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-dialog {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 100%;
    animation: slideUp 0.3s ease;
    max-height: 90vh;
    height: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid #f0f0f0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    flex-shrink: 0;
    overflow: hidden;
}

.modal-header .modal-title {
    margin: 0;
    color: white;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header .btn-close {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.modal-header .btn-close:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Wrapper del body para permitir scroll en iOS */
.modal-body-wrapper {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    /* iOS fix: asegurar que el overflow funciona */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.modal-form {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    width: 100%;
    overflow: hidden;
}

.modal-body {
    padding: 24px;
    overflow-y: scroll;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
    -webkit-user-select: text;
    user-select: text;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    /* iOS momentum scrolling */
    position: relative;
    display: block;
    /* Asegurar que el contenido se puede scrollear */
    scroll-behavior: smooth;
}

/* Scrollbar styling para navegadores webkit */
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #f0f0f0;
    background: #f9f9f9;
    flex-shrink: 0;
    overflow: hidden;
}

/* Error Modal Specific Styles */
.error-header {
    background: linear-gradient(135deg, #DC3545 0%, #c82333 100%);
}

.error-header .modal-title {
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

.error-header .btn-close {
    background: rgba(255, 255, 255, 0.3);
}

.error-header .btn-close:hover {
    background: rgba(255, 255, 255, 0.5);
}

.error-body {
    padding: 32px 24px;
}

.error-message-box {
    background: #f8d7da;
    border: 2px solid #f5c6cb;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
}

.error-text {
    color: #721c24;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.6;
    margin: 0;
}

.error-tips {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: 4px;
    padding: 16px;
    margin-bottom: 20px;
}

.error-tips h6 {
    color: #856404;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    margin: 0 0 8px 0;
}

.error-tips ul {
    color: #856404;
    font-size: 13px;
    margin: 0;
    padding-left: 20px;
}

.error-tips li {
    margin-bottom: 6px;
}

.error-tips li:last-child {
    margin-bottom: 0;
}

.transaction-info {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.transaction-label {
    color: #666;
    font-weight: 600;
}

.transaction-id {
    color: #333;
    font-family: 'Monaco', 'Courier New', monospace;
    font-weight: 500;
    background: white;
    padding: 6px 10px;
    border-radius: 3px;
    border: 1px solid #ddd;
}

.error-details-box {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 16px;
}

.error-details-box h6 {
    color: #333;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    margin: 0 0 8px 0;
}

.error-details-list {
    color: #555;
    font-size: 13px;
    margin: 0;
    padding-left: 20px;
}

.error-details-list li {
    margin-bottom: 6px;
    line-height: 1.5;
}

.error-details-list li:last-child {
    margin-bottom: 0;
}

.error-footer {
    padding: 16px 24px;
    background: #f9f9f9;
    border-top: 1px solid #f0f0f0;
}

.error-footer .btn {
    width: 100%;
}

/* Payment Summary */
.payment-summary {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
    border-left: 4px solid #667eea;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
    color: #555;
}

.summary-row.total {
    border-top: 1px solid #dee2e6;
    margin-top: 8px;
    padding-top: 12px;
    font-size: 16px;
    font-weight: 700;
    color: #333;
}

/* Form Section Title */
.form-section-title {
    color: #667eea;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 16px 0 12px 0;
}

/* Form Controls */
.form-label {
    color: #333;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 13px;
}

.form-control {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

.form-control:disabled {
    background: #f5f5f5;
    color: #999;
}

/* Validation Messages */
.validation-message {
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

.validation-summary {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-secondary {
    background: #e9ecef;
    color: #333;
}

.btn-secondary:hover:not(:disabled) {
    background: #dee2e6;
}

.btn-secondary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Spinner */
.spinner-border-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    color: white;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error State */
.error-state {
    background: white;
    border-radius: 12px;
    padding: 40px;
    max-width: 500px;
    margin: 40px auto;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.error-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.error-state h2 {
    color: #333;
    margin-bottom: 10px;
}

.error-state p {
    color: #666;
    margin-bottom: 30px;
}

.error-help {
    background: #FFF3CD;
    border: 2px solid #FFC107;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
    text-align: left;
}

.error-help h4 {
    color: #856404;
    margin-top: 0;
    margin-bottom: 10px;
    font-weight: 600;
}

.error-help p {
    color: #856404;
    margin: 8px 0;
    font-size: 13px;
    line-height: 1.6;
}

.error-help code {
    background: rgba(0, 0, 0, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-weight: 500;
}

/* Payment Layout */
.payment-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.payment-details,
.qr-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

/* Payment Details Section */
.payment-details {
    padding: 40px;
}

.payment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 20px;
}

.payment-header h1 {
    margin: 0;
    color: #333;
    font-size: 28px;
    font-weight: 600;
}

.status-badge {
    padding: 8px 16px;
    border-radius: 20px;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.details-section {
    margin-bottom: 30px;
}

.details-section h3 {
    color: #555;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    font-weight: 600;
}

/* Amount Display */
.amount-display {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 20px;
}

.amount-display .currency {
    font-size: 18px;
    color: #667eea;
    font-weight: 600;
}

.amount-display .amount {
    font-size: 36px;
    font-weight: 700;
    color: #333;
}

/* Info Rows */
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f5f5f5;
    font-size: 14px;
}

.info-row label {
    color: #999;
    font-weight: 500;
    min-width: 120px;
}

.info-row span {
    color: #333;
    font-weight: 600;
    text-align: right;
    flex: 1;
}

.info-row .reference {
    font-family: 'Monaco', 'Courier New', monospace;
    background: #f9f9f9;
    padding: 4px 8px;
    border-radius: 4px;
    color: #667eea;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #f0f0f0;
}

.action-buttons .btn {
    flex: 1;
}

/* QR Section */
.qr-section {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.qr-container {
    text-align: center;
}

.qr-container h3 {
    color: #333;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

.qr-box {
    background: #f9f9f9;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    min-width: 250px;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

.qr-info {
    color: #666;
    font-size: 13px;
    line-height: 1.6;
    margin: 0;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .payment-layout {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .payment-details,
    .qr-section {
        padding: 30px;
    }

    .payment-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .amount-display {
        gap: 15px;
    }

    .amount-display .amount {
        font-size: 28px;
    }

    .qr-box {
        min-width: 220px;
        min-height: 220px;
    }

    .modal-dialog {
        max-width: 90vw;
    }
}

@media (max-width: 768px) {
    .payment-container {
        padding: 20px 10px;
    }

    .payment-details,
    .qr-section {
        padding: 20px;
    }

    .payment-header h1 {
        font-size: 22px;
    }

    .amount-display {
        flex-direction: column;
        gap: 8px;
    }

    .amount-display .amount {
        font-size: 24px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .info-row {
        flex-direction: column;
        gap: 4px;
    }

    .info-row label {
        min-width: auto;
    }

    .info-row span {
        text-align: left;
    }

    .qr-box {
        min-width: 100%;
        min-height: 200px;
    }

    .qr-container h3 {
        font-size: 16px;
    }

    .modal-dialog {
        max-width: 95vw;
        margin: 0 auto;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
        flex-direction: column-reverse;
    }

    .modal-footer .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .payment-container {
        padding: 15px 10px;
        min-height: auto;
    }

    .payment-details,
    .qr-section {
        padding: 15px;
        border-radius: 8px;
    }

    .payment-header {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 20px;
    }

    .payment-header h1 {
        font-size: 18px;
    }

    .status-badge {
        padding: 6px 12px;
        font-size: 12px;
    }

    .details-section h3 {
        font-size: 12px;
    }

    .amount-display {
        gap: 5px;
        margin-bottom: 15px;
    }

    .amount-display .amount {
        font-size: 20px;
    }

    .info-row {
        padding: 10px 0;
        font-size: 13px;
    }

    .action-buttons {
        gap: 8px;
        margin-top: 20px;
    }

    .qr-box {
        min-width: 100%;
        min-height: 180px;
        padding: 15px;
    }

    .qr-container h3 {
        font-size: 14px;
        margin-bottom: 15px;
    }

    .qr-info {
        font-size: 12px;
    }

    .modal-dialog {
        max-width: 100vw;
        border-radius: 8px 8px 0 0;
    }

    .form-label {
        font-size: 12px;
    }

    .form-control {
        padding: 8px 10px;
        font-size: 13px;
    }
}

/* iOS-Specific Fixes for Modal Scrolling */
@supports (-webkit-touch-callout: none) {
    /* iOS only */
    .modal-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }

    .modal-dialog {
        /* Asegurar que el modal sea scrolleable en iOS */
        max-height: 90vh;
        overflow: hidden;
        -webkit-overflow-scrolling: touch;
        /* Prevenir que el fondo se desplace */
        position: static;
        display: flex;
        flex-direction: column;
    }

    .modal-content {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 0;
    }

    .modal-header {
        flex-shrink: 0;
        overflow: hidden;
    }

    .modal-body {
        /* Asegurar que solo el body sea scrolleable */
        overflow-y: scroll;
        -webkit-overflow-scrolling: touch;
        flex: 1;
        min-height: 0;
        overflow-x: hidden;
        position: relative;
    }

    .modal-body form {
        display: flex;
        flex-direction: column;
        min-height: 100%;
    }

    .modal-body EditForm {
        display: flex;
        flex-direction: column;
        min-height: 100%;
    }

    .modal-footer {
        flex-shrink: 0;
        overflow: hidden;
    }

    /* Prevenir que el body se desplace cuando el modal está abierto */
    body.modal-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100vh;
    }
}

/* Estilos para Rechazo de Pago */
.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

.btn-danger:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.reject-header {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
}

.reject-reasons {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

.form-check {
    margin-bottom: 15px;
    padding: 12px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.form-check:hover {
    background: #f8f9fa;
    border-color: #dc3545;
}

.form-check-input {
    width: 20px;
    height: 20px;
    margin-top: 3px;
    margin-right: 10px;
    cursor: pointer;
    accent-color: #dc3545;
}

.form-check-label {
    margin-bottom: 0;
    cursor: pointer;
    user-select: none;
}

.form-group label {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.form-control {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 10px;
    font-size: 14px;
}

.form-control:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
    outline: none;
}

.mt-3 {
    margin-top: 1rem;
}
