/**
 * Redsys Express Custom Fields Modal Styles
 *
 * @author José Conti <info@joseconti.com>
 * @copyright 2024 José Conti
 */

/* Modal Base */
.redsys-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.redsys-modal.redsys-modal-open {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Body scroll lock */
body.redsys-modal-body-open {
    overflow: hidden;
}

/* Overlay */
.redsys-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Container */
.redsys-modal-container {
    position: relative;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: redsys-modal-appear 0.3s ease-out;
}

@keyframes redsys-modal-appear {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Header */
.redsys-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.redsys-modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
}

.redsys-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin: -8px;
    border-radius: 8px;
    color: #6b7280;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.redsys-modal-close:hover {
    background-color: #f3f4f6;
    color: #111827;
}

.redsys-modal-close:focus {
    outline: none;
    box-shadow: 0 0 0 2px #3b82f6;
}

/* Body */
.redsys-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.redsys-modal-subtitle {
    margin: 0 0 24px 0;
    font-size: 0.9375rem;
    color: #6b7280;
    line-height: 1.5;
}

/* Form Elements */
.redsys-modal-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.redsys-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.redsys-form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

.redsys-required {
    color: #ef4444;
    margin-left: 2px;
}

.redsys-form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    line-height: 1.5;
    color: #111827;
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

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

.redsys-form-control::placeholder {
    color: #9ca3af;
}

.redsys-form-control:invalid:not(:placeholder-shown) {
    border-color: #ef4444;
}

.redsys-help-text {
    font-size: 0.8125rem;
    color: #6b7280;
}

/* Checkbox Group */
.redsys-form-group-checkbox {
    gap: 0;
}

.redsys-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-size: 0.9375rem;
    color: #374151;
    line-height: 1.5;
}

.redsys-checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    cursor: pointer;
    accent-color: #3b82f6;
    flex-shrink: 0;
}

.redsys-checkbox-text {
    flex: 1;
}

.redsys-checkbox-text a {
    color: #3b82f6;
    text-decoration: none;
}

.redsys-checkbox-text a:hover {
    text-decoration: underline;
}

/* Field Errors */
.redsys-field-error {
    font-size: 0.8125rem;
    color: #ef4444;
    min-height: 0;
}

.redsys-field-error:not(:empty) {
    margin-top: 4px;
}

/* General Errors */
.redsys-modal-errors {
    display: none;
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 16px;
}

.redsys-modal-errors ul {
    margin: 0;
    padding-left: 20px;
}

.redsys-modal-errors li {
    color: #991b1b;
    font-size: 0.875rem;
}

.redsys-modal-errors p {
    margin: 0;
    color: #991b1b;
    font-size: 0.875rem;
}

/* Footer */
.redsys-modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    background-color: #f9fafb;
}

/* Buttons */
.redsys-modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
}

.redsys-modal-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #3b82f6;
}

.redsys-modal-btn-primary {
    background-color: #3b82f6;
    color: #ffffff;
}

.redsys-modal-btn-primary:hover:not(:disabled) {
    background-color: #2563eb;
}

.redsys-modal-btn-primary:disabled {
    background-color: #93c5fd;
    cursor: not-allowed;
}

.redsys-modal-btn-secondary {
    background-color: #ffffff;
    color: #374151;
    border: 1px solid #d1d5db;
}

.redsys-modal-btn-secondary:hover:not(:disabled) {
    background-color: #f3f4f6;
}

/* Loading State */
.redsys-modal-btn.redsys-loading {
    position: relative;
    color: transparent;
}

.redsys-modal-btn.redsys-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: redsys-spin 0.8s linear infinite;
}

.redsys-modal-btn-primary.redsys-loading::after {
    border-top-color: #ffffff;
}

@keyframes redsys-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 480px) {
    .redsys-modal-container {
        width: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
    }

    .redsys-modal-header,
    .redsys-modal-body,
    .redsys-modal-footer {
        padding-left: 16px;
        padding-right: 16px;
    }

    .redsys-modal-footer {
        flex-direction: column;
    }

    .redsys-modal-btn {
        width: 100%;
    }

    .redsys-modal-btn-secondary {
        order: 1;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .redsys-modal-container {
        background: #1f2937;
    }

    .redsys-modal-header {
        border-bottom-color: #374151;
    }

    .redsys-modal-title {
        color: #f9fafb;
    }

    .redsys-modal-subtitle {
        color: #9ca3af;
    }

    .redsys-form-label {
        color: #e5e7eb;
    }

    .redsys-form-control {
        background-color: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }

    .redsys-form-control::placeholder {
        color: #6b7280;
    }

    .redsys-checkbox-label {
        color: #e5e7eb;
    }

    .redsys-modal-footer {
        background-color: #111827;
        border-top-color: #374151;
    }

    .redsys-modal-btn-secondary {
        background-color: #374151;
        color: #e5e7eb;
        border-color: #4b5563;
    }

    .redsys-modal-btn-secondary:hover:not(:disabled) {
        background-color: #4b5563;
    }
}
