/* public/css/style.css */

/* Import Google Fonts - Poppins */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* --- CSS Variables for easier theme management --- */
:root {
    /* Light Mode Defaults */
    --locapay-blue: #006699; /* Primary LOCAPAY accent */
    --locapay-dark-blue: #003366;
    --uba-red: #E4002B; /* UBA accent color (red) */
    --light-grey: #F8F8F8;
    --dark-grey: #333333;
    --text-grey: #666666;
    --border-color: #DDDDDD; /* Standard border color */
    --success-green: #28a745; /* Standard green for success */
    --error-red: #dc3545; /* Standard red for errors (used in Bootstrap) */
    --font-family: 'Poppins', sans-serif; /* Preferred font */

    /* Background and Text Colors */
    --body-bg: var(--light-grey);
    --container-bg: #fff;
    --text-color: var(--dark-grey);
    --label-color: var(--text-grey);
    --placeholder-color: var(--text-grey);
    --input-bg: #fff;
    --input-border: var(--border-color);
    --currency-prefix-bg: #e9ecef;
    --currency-prefix-border: var(--border-color);
    --currency-prefix-color: var(--text-grey);
    --cvv-tooltip-bg: var(--dark-grey);
    --cvv-tooltip-text: #fff;
    --toggle-bg: #e0e0e0;
    --toggle-slider: #fff;

    /* Shadow variables for consistency */
    --shadow-light: 0 2px 5px rgba(0, 0, 0, 0.05);
    --shadow-medium: 0 8px 20px rgba(0, 0, 0, 0.1);
    --shadow-deep: 0 15px 30px rgba(0, 0, 0, 0.15);
}

/* Dark Mode Variables */
body.dark-mode {
    --body-bg: #222831; /* Darker background */
    --container-bg: #393e46; /* Slightly lighter dark for container */
    --text-color: #EEEEEE; /* Light text */
    --label-color: #BBBBBB;
    --placeholder-color: #AAAAAA;
    --input-bg: #4c525a;
    --input-border: #666c74;
    --currency-prefix-bg: #5a626a;
    --currency-prefix-border: #666c74;
    --currency-prefix-color: #DDDDDD;
    --cvv-tooltip-bg: #1a1e24;
    --cvv-tooltip-text: #fff;
    --toggle-bg: #5a626a;
    --toggle-slider: #EEEEEE;

    /* Adjust shadows for dark mode if desired, or keep as is */
    --shadow-medium: 0 8px 20px rgba(0, 0, 0, 0.3);
}


/* --- Base Styles --- */
body {
    font-family: var(--font-family); /* Use the defined font family */
    line-height: 1.6;
    color: var(--text-color); /* Use variable for main text */
    background-color: var(--body-bg); /* Use variable for background */
    margin: 0;
    padding: 20px;
    display: flex; /* Use flexbox for centering */
    justify-content: center; /* Center horizontally */
    align-items: flex-start; /* Align to top instead of center to allow scroll */
    min-height: 100vh; /* Ensure full viewport height */
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
    transition: background-color 0.3s ease, color 0.3s ease; /* Smooth theme transition */
}

/* --- Container for the Form --- */
.container {
    background-color: var(--container-bg);
    padding: 30px;
    border-radius: 10px; /* Slightly larger radius */
    box-shadow: var(--shadow-medium); /* Use defined shadow */
    width: 100%;
    max-width: 500px;
    box-sizing: border-box; /* Essential */
    margin-top: 50px; /* Space from theme toggle */
    margin-bottom: 50px; /* Space at the bottom */
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* --- Headings --- */
h1, h2 { /* Targeting both h1 and h2 */
    text-align: center;
    color: var(--text-color); /* Default text color */
    margin-bottom: 20px;
    font-weight: 600; /* Poppins Semi-Bold */
    transition: color 0.3s ease;
}

/* Make h1 more prominent */
h1 {
    color: var(--locapay-blue); /* Primary brand color for main title */
    font-size: 2.2em; /* Larger font size */
    margin-bottom: 10px; /* Less space if subtitle follows */
}

/* Subtitle/description below H1 */
p.text-center small {
    display: block; /* Ensure it takes full width */
    margin-bottom: 20px;
    color: var(--label-color); /* Use label color for small text */
    font-size: 0.9em;
}

/* --- Form Groups --- */
.form-group {
    margin-bottom: 1.5rem; /* Consistent spacing */
    position: relative; /* For positioning validation icons and error messages */
}

/* New: For side-by-side fields like ZIP/Phone */
.row-group {
    display: flex;
    gap: 15px; /* Space between items in the row */
    margin-bottom: 1.5rem; /* Consistent spacing */
}

.row-group .form-group {
    flex: 1; /* Each takes roughly half the width */
    margin-bottom: 0; /* Remove individual form-group margin if part of row-group */
}

/* --- Labels --- */
label {
    display: block;
    margin-bottom: 0.5rem; /* Space between label and input */
    color: var(--label-color);
    font-weight: 500; /* Poppins Medium */
    transition: color 0.3s ease;
}

/* --- Input Fields (Consolidated and improved) --- */
/* This class must be added to your input elements in HTML for styles to apply */
.form-control {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem; /* Consistent padding */
    border: 1px solid var(--input-border); /* Use variable for border */
    border-radius: 0.5rem; /* Consistent border radius */
    box-sizing: border-box; /* Crucial for width calculation */
    font-size: 1rem; /* Consistent font size */
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--input-bg);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, background-color 0.3s ease, color 0.3s ease;
}

.form-control::placeholder {
    color: var(--placeholder-color);
    opacity: 0.7;
}

.form-control:focus {
    border-color: var(--locapay-blue); /* Highlight on focus */
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(0, 102, 153, 0.25); /* Focus ring with LOCAPAY blue */
}

/* Style for select dropdown */
.form-control[type="select"] {
    appearance: none; /* Remove default arrow */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23333' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding-right: 2.25rem; /* Space for the custom arrow */
}
body.dark-mode .form-control[type="select"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23EEEEEE' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E");
}


/* --- Specific Input Group for Amount (USD prefix) --- */
.amount-input-wrapper {
    display: flex;
    align-items: center;
    position: relative;
}

.amount-input-wrapper .currency-prefix {
    background-color: var(--currency-prefix-bg); /* Light grey background */
    border: 1px solid var(--currency-prefix-border);
    border-right: none; /* No border on the right */
    padding: 0.75rem 0.75rem; /* Match input padding */
    border-radius: 0.5rem 0 0 0.5rem; /* Rounded left corners */
    color: var(--currency-prefix-color); /* Darker text */
    font-weight: 500;
    line-height: 1.5;
    height: calc(1rem + 1.5rem + 2px); /* Calc based on font-size + padding + border */
    display: flex;
    align-items: center;
    box-sizing: border-box;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.amount-input-wrapper input#amount { /* Target the input specifically */
    flex-grow: 1; /* Input takes remaining space */
    border-radius: 0 0.5rem 0.5rem 0 !important; /* Rounded right corners, override form-control */
    border-left: none !important; /* No border on left */
    padding-left: 0.75rem; /* Ensure text isn't too close to the prefix */
}

/* --- Validation States (Bootstrap-like) --- */
.form-control.is-invalid {
    border-color: var(--error-red);
}

.form-control.is-valid {
    border-color: var(--success-green);
}

/* Validation Icons (check/exclamation) */
.form-group .validation-icon {
    position: absolute;
    /* Adjusted top to account for label and input padding */
    top: calc(0.5rem + 0.75rem + 1px); /* label margin + input padding + half border */
    right: 1rem; /* Adjusted right position for input padding */
    transform: translateY(-50%); /* Fine-tune vertical centering */
    font-size: 1.1rem;
    pointer-events: none; /* Don't block clicks on the input */
    display: none; /* Hidden by default, shown by JS */
    z-index: 2; /* Ensure it's above input */
}

/* When input is in amount-input-wrapper, adjust icon position */
.amount-input-wrapper .validation-icon {
    right: 1rem; /* Adjust for combined input/span */
    top: 50%; /* Re-center vertically for this specific wrapper */
}

/* Specific colors for validation icons */
/* The general approach is: if input is-valid, show check. If is-invalid, show exclamation. */
/* Hide the other icon depending on the state */
.form-control.is-valid + .validation-icon.fa-check-circle {
    color: var(--success-green);
    display: block;
}

.form-control.is-invalid + .validation-icon.fa-exclamation-circle {
    color: var(--error-red);
    display: block;
}

.form-control.is-valid + .validation-icon.fa-exclamation-circle {
    display: none; /* Hide exclamation when valid */
}
.form-control.is-invalid + .validation-icon.fa-check-circle {
    display: none; /* Hide check when invalid */
}

/* Card Number specific icons */
.card-number-wrapper .card-type-icon {
    position: absolute;
    right: 2.75rem; /* Positioned to the left of validation icon */
    /* Adjusted top to account for label and input padding */
    top: calc(0.5rem + 0.75rem + 1px);
    transform: translateY(-50%);
    font-size: 1.5rem; /* Larger for card type icon */
    color: var(--label-color); /* Use label color for general icons */
    pointer-events: none;
    z-index: 2;
    transition: color 0.3s ease;
}


/* --- Error Messages --- */
.error-message {
    color: var(--error-red);
    font-size: 0.875rem; /* Smaller text for errors */
    margin-top: 0.25rem; /* Small margin above */
    display: none; /* Hidden by default, shown by JS */
}

/* --- Expiration and CVV group --- */
.expiration-cvv-group {
    display: flex;
    gap: 15px; /* Space between expiry and CVV */
}

.expiration-cvv-group .form-group {
    flex: 1; /* Each takes half the width */
}

/* CVV Info Icon and Tooltip */
.cvv-info-icon {
    font-size: 0.85em; /* Slightly larger */
    color: var(--label-color);
    margin-left: 5px;
    cursor: pointer;
    position: relative; /* For tooltip positioning */
    vertical-align: middle; /* Align with text */
    transition: color 0.3s ease;
}

.cvv-tooltip {
    position: absolute;
    background-color: var(--cvv-tooltip-bg);
    color: var(--cvv-tooltip-text);
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 10;
    bottom: calc(100% + 5px); /* Position above the icon with a small gap */
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, background-color 0.3s ease, color 0.3s ease;
    pointer-events: none; /* Crucial: allows clicking through when hidden */
}

.cvv-info-icon:focus + .cvv-tooltip,
.cvv-info-icon:hover + .cvv-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Save card option (checkbox) */
.save-card-option {
    display: flex;
    align-items: center;
    margin-top: 1rem;
    margin-bottom: 1.5rem; /* Consistent spacing before button */
}

.save-card-option input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    margin-right: 0.5rem;
    flex-shrink: 0; /* Prevent checkbox from shrinking */
    cursor: pointer;
}

.save-card-option label {
    margin-bottom: 0;
    font-weight: 400; /* Regular weight */
    font-size: 0.95rem;
    color: var(--label-color);
    cursor: pointer;
    transition: color 0.3s ease;
}

/* --- Submit Button (.submit-button) --- */
.submit-button {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--locapay-blue); /* Use LOCAPAY blue */
    color: white;
    padding: 0.875rem 1.5rem; /* Consistent padding */
    border: 1px solid var(--locapay-blue); /* Consistent border */
    border-radius: 0.5rem; /* Consistent radius */
    cursor: pointer;
    width: 100%; /* Full width */
    font-size: 1.1rem; /* Slightly larger font */
    font-weight: 600; /* Poppins Semi-Bold */
    transition: background-color 0.3s ease, border-color 0.3s ease, opacity 0.3s ease;
    box-sizing: border-box; /* Essential */
    position: relative; /* For spinner positioning */
    overflow: hidden; /* Hide spinner overflow */
}

.submit-button:hover:not(:disabled) {
    background-color: var(--locapay-dark-blue); /* Darker blue on hover */
    border-color: var(--locapay-dark-blue);
}

.submit-button:disabled {
    background-color: #cccccc; /* Greyed out when disabled */
    border-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.7; /* Slightly transparent */
}

.submit-button .spinner {
    display: none; /* Hidden by default */
    border: 3px solid rgba(255, 255, 255, 0.3); /* Light border */
    border-top: 3px solid #fff; /* White rotating part */
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    margin-left: 10px; /* Space from text */
    flex-shrink: 0; /* Prevent spinner from shrinking */
}

.submit-button.loading {
    cursor: not-allowed;
    opacity: 0.8;
}

.submit-button.loading .spinner {
    display: inline-block;
}

.submit-button.loading span { /* Target the text inside the button */
    visibility: hidden; /* Hide "Pay Now" text when loading */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Security Info Section */
.security-info {
    text-align: center;
    margin-top: 30px;
    font-size: 0.85rem;
    color: var(--label-color); /* Use label color for security info */
    transition: color 0.3s ease;
}

.security-info img {
    height: 25px; /* Adjust as needed */
    margin: 0 8px; /* More space between icons */
    vertical-align: middle;
    filter: grayscale(80%); /* Optional: make icons more subtle */
    opacity: 0.7;
}

.security-info a {
    color: var(--locapay-blue);
    text-decoration: none;
    font-weight: 500;
}

.security-info a:hover {
    text-decoration: underline;
}

/* --- Theme Toggle Button --- */
.theme-toggle-wrapper {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
}

.theme-toggle-button {
    background-color: var(--toggle-bg);
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: var(--shadow-light);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    outline: none; /* Remove default outline */
}

.theme-toggle-button:hover {
    box-shadow: var(--shadow-medium);
}

.theme-toggle-button i {
    font-size: 1.3em;
    color: var(--text-color); /* Icon color changes with theme */
    transition: opacity 0.3s ease, color 0.3s ease;
}

/* Hide one icon based on the body class */
body.light-mode .theme-toggle-button .dark-mode-icon {
    display: none;
    opacity: 0;
}

body.dark-mode .theme-toggle-button .light-mode-icon {
    display: none;
    opacity: 0;
}

body.light-mode .theme-toggle-button .light-mode-icon {
    display: block;
    opacity: 1;
}

body.dark-mode .theme-toggle-button .dark-mode-icon {
    display: block;
    opacity: 1;
}


/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    body {
        padding: 10px;
        min-height: auto; /* Allow body to shrink on small screens */
        align-items: flex-start; /* Align to top instead of center to prevent large gaps */
    }
    .container {
        padding: 20px;
        border-radius: 0; /* No rounded corners on very small screens */
        box-shadow: none; /* No shadow on very small screens */
        margin-top: 0;
        margin-bottom: 0;
    }
    .expiration-cvv-group,
    .row-group { /* Apply to both horizontal groups */
        flex-direction: column; /* Stack expiry and CVV on small screens */
        gap: 0; /* Remove gap when stacked vertically */
    }
    /* Adjust icon positions for smaller screens if needed */
    .form-group .validation-icon {
        right: 0.75rem;
    }
    .card-number-wrapper .card-type-icon {
        right: 2.25rem;
    }
    .theme-toggle-wrapper {
        top: 10px;
        right: 10px;
    }
}