/* SPG Payment Gateway Styles */

/* Payment Form Wrapper - Controls visibility */
.spg-payment-form-wrapper {
    margin: 20px 0;
    animation: slideIn 0.3s ease-out;
}

.spg-payment-form-wrapper.hidden {
    display: none !important;
}

/* Payment Form Section - Inline on Checkout Page */
#spg_payment_form {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 20px 24px;
    margin: 0;
    display: block;
}

#spg_payment_form fieldset {
    border: none;
    margin: 0;
    padding: 0;
}

#spg_payment_form legend {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 18px;
    padding: 0;
    display: flex;
    align-items: center;
    width: 100%;
}

#spg_payment_form legend::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 16px;
    background: #3498db;
    border-radius: 2px;
    margin-right: 10px;
    flex-shrink: 0;
}

.spg-form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.spg-form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
    display: block;
}

.spg-form-group label .required {
    color: #e74c3c;
    margin-left: 2px;
}

.spg-form-group input {
    padding: 10px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: #fafafa;
}

.spg-form-group input:focus {
    outline: none;
    border-color: #3498db;
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

.spg-form-group input:disabled {
    background: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

.spg-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Success and Error States */
.spg-form-group input:valid {
    border-color: #27ae60;
}

.spg-form-group input.error {
    border-color: #e74c3c;
    background: #fdeaea;
}

/* Loading and Animation */
#spg_payment_form {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    #spg_payment_form {
        background: #1e1e1e;
        border-color: #444;
    }

    .spg-form-group label {
        color: #e0e0e0;
    }

    .spg-form-group input {
        background: #2d2d2d;
        border-color: #444;
        color: #e0e0e0;
    }

    .spg-form-group input:focus {
        border-color: #5ba3d0;
        background: #1e1e1e;
    }

    .spg-form-group input:disabled {
        background: #1a1a1a;
        color: #666;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    #spg_payment_form {
        padding: 16px 16px;
    }

    .spg-form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .spg-form-group input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* High Contrast Support */
@media (prefers-contrast: more) {
    .spg-form-group input {
        border-width: 2px;
    }

    .spg-form-group input:focus {
        outline: 2px solid #3498db;
        outline-offset: 2px;
    }
}

/* Print Styles */
@media print {
    #spg_payment_form {
        display: none !important;
    }
}

/* Legacy Styles (if needed for backward compatibility) */
.spg-payment-form-section {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 20px 24px;
    margin: 20px 0;
    display: none;
}

.spg-payment-form-section.visible {
    display: block;
}

#spg-payment-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.spg-submit-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 16px;
}

.spg-submit-btn:hover {
    background: #2980b9;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.spg-submit-btn:active {
    transform: translateY(1px);
}

.spg-submit-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Loading Spinner */
.spg-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.spg-loading-spinner {
    text-align: center;
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.3s ease-out;
}

.spg-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spg-loading-spinner p {
    margin: 0;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
}

.spg-form-group input {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: white;
}

.spg-form-group input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

.spg-form-group input::placeholder {
    color: #aaa;
}

.spg-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.spg-submit-btn {
    width: 100%;
    padding: 12px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-top: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

.spg-submit-btn:hover {
    background: #2980b9;
}

.spg-submit-btn:active {
    transform: scale(0.98);
}

.spg-submit-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .spg-loading-spinner {
        padding: 30px;
    }

    .spg-spinner {
        width: 40px;
        height: 40px;
        border-width: 3px;
    }

    .spg-loading-spinner p {
        font-size: 13px;
    }

    .spg-payment-form-section {
        padding: 20px;
        margin: 16px 0;
    }

    .spg-payment-form-section h3 {
        font-size: 16px;
        margin-bottom: 16px;
    }

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

@media (max-width: 480px) {
    .spg-loading-spinner {
        padding: 20px;
        width: 90%;
        max-width: 280px;
    }

    .spg-spinner {
        width: 35px;
        height: 35px;
        border-width: 2px;
    }

    .spg-loading-spinner p {
        font-size: 12px;
    }

    .spg-payment-form-section {
        padding: 16px;
        margin: 12px 0;
        border-radius: 4px;
    }

    .spg-payment-form-section h3 {
        font-size: 14px;
        margin-bottom: 14px;
    }

    .spg-form-group {
        margin-bottom: 12px;
    }

    .spg-form-group input {
        font-size: 13px;
        padding: 9px 10px;
    }

    .spg-submit-btn {
        padding: 10px;
        font-size: 14px;
        margin-top: 8px;
    }

    .spg-form-row {
        gap: 8px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .spg-loading-spinner {
        background: #222;
        color: #fff;
    }

    .spg-loading-spinner p {
        color: #ccc;
    }

    .spg-spinner {
        border-color: #444;
        border-top-color: #3498db;
    }

    .spg-payment-form-section {
        background: #1a1a1a;
        border-color: #333;
    }

    .spg-payment-form-section h3 {
        color: #fff;
    }

    .spg-form-group label {
        color: #ddd;
    }

    .spg-form-group input {
        background: #333;
        color: #fff;
        border-color: #555;
    }

    .spg-form-group input:focus {
        border-color: #3498db;
        box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
    }

    .spg-form-group input::placeholder {
        color: #777;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: more) {
    .spg-spinner {
        border-width: 5px;
    }

    .spg-payment-form-section {
        border-width: 2px;
    }

    .spg-form-group input {
        border-width: 2px;
    }

    .spg-submit-btn {
        border: 2px solid #3498db;
        font-weight: 700;
    }

    .spg-payment-form-section h3::before {
        width: 6px;
    }
}

/* Print Styles */
@media print {
    .spg-loading-overlay {
        display: none !important;
    }
}