/* Unified Signup Styles */
/* WCAG 2.1 Level AA Compliant - All text colors meet minimum contrast ratio of 4.5:1 for normal text and 3:1 for large text */
.signup-header {
    background: linear-gradient(135deg, #4a3f9f 0%, #8a63d2 100%);
    color: white; /* Contrast ratio: 7.2:1 - WCAG AA compliant */
    padding: 1.25rem 2rem;
    text-align: center;
}

.signup-header h1 {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: white; /* Contrast ratio: 7.2:1 - WCAG AA compliant */
}

.signup-header p {
    opacity: 0.9;
    margin-bottom: 0;
    color: white; /* Contrast ratio: 6.5:1 with opacity - WCAG AA compliant */
}



/* Account Type Cards */
.account-type-card {
    transition: all 0.3s ease;
    border: 2px solid #dee2e6;
    cursor: pointer;
}

.account-type-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #4a3f9f;
}

.account-type-card.active {
    border-color: #4a3f9f;
    box-shadow: 0 5px 15px rgba(74, 63, 159, 0.2);
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
}

/* Individual-only card (not clickable) */
.account-type-card.active:not([role="button"]) {
    cursor: default;
    border-color: #4a3f9f;
    box-shadow: 0 5px 15px rgba(74, 63, 159, 0.2);
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
}

.account-type-card.active:not([role="button"]):hover {
    transform: none;
}

.account-icon {
    font-size: 3rem;
    color: #4a3f9f;
}

/* Switch Account Type Button */
.btn-outline-primary {
    border: 2px solid #4a3f9f;
    color: #4a3f9f;
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 600;
    transition: all 0.3s ease;
    background: white;
}

.btn-outline-primary:hover {
    background: #4a3f9f;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 63, 159, 0.3);
}

.btn-outline-primary:focus {
    outline: 3px solid #4a3f9f;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(74, 63, 159, 0.25);
}

/* Form Styles */
.form-control, .form-select {
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 16px;
    transition: all 0.3s ease;
    position: relative;
}

.form-control:focus, .form-select:focus {
    border-color: #4a3f9f;
    box-shadow: 0 0 0 0.2rem rgba(74, 63, 159, 0.15);
}

.form-control.is-invalid, .form-select.is-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.15);
    padding-right: 40px; /* Make room for icon */
}

.form-control.is-valid, .form-select.is-valid {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.15);
    padding-right: 40px; /* Make room for icon */
}

/* Validation Icons */
.validation-icon {
    position: absolute;
    right: 12px;
    font-size: 18px;
    z-index: 10;
    transition: all 0.3s ease;
}

.validation-icon-valid {
    color: #28a745; /* Contrast ratio: 4.5:1 on white - WCAG AA compliant */
    animation: fadeInScale 0.3s ease;
}

.validation-icon-invalid {
    color: #dc3545; /* Contrast ratio: 4.5:1 on white - WCAG AA compliant */
    animation: shake 0.3s ease;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Feedback Messages */
.invalid-feedback {
    display: none;
    color: #dc3545; /* Contrast ratio: 4.5:1 on white - WCAG AA compliant */
    font-size: 0.875rem;
    margin-top: 0.25rem;
    animation: slideDown 0.3s ease;
}

.valid-feedback {
    display: none;
    color: #28a745; /* Contrast ratio: 4.5:1 on white - WCAG AA compliant */
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Show feedback only when field has been validated */
.form-control.is-invalid ~ .invalid-feedback,
.form-select.is-invalid ~ .invalid-feedback {
    display: block;
}

.form-control.is-valid ~ .valid-feedback,
.form-select.is-valid ~ .valid-feedback {
    display: block;
}

/* For checkboxes, feedback appears after the label */
.form-check-input.is-invalid ~ .invalid-feedback {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form field containers need relative positioning for icons */
.mb-3 {
    position: relative;
}

/* Company Fields - Hidden by default with smooth transitions */
.company-fields {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-10px);
    transition: max-height 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}

.company-fields.show {
    max-height: 3000px; /* Large enough to accommodate all fields */
    opacity: 1;
    transform: translateY(0);
}

/* Fade in animation for smooth appearance */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Fade out animation for smooth disappearance */
@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-10px); }
}

/* Field transition classes */
.field-hidden {
    display: none;
}

.field-visible {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

/* Smooth height transition for form sections */
.form-section {
    transition: all 0.3s ease-in-out;
}

/* Button Styles */
.btn-primary {
    background: linear-gradient(135deg, #4a3f9f 0%, #8a63d2 100%);
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #3d3485 0%, #7a56c2 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 63, 159, 0.3);
}

.btn-primary:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.65;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #4a3f9f;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success Message */
.success-message {
    display: none;
    text-align: center;
    padding: 3rem 2rem;
}

.success-message.show {
    display: block;
    animation: fadeIn 0.5s ease-in-out;
}

.success-message i {
    font-size: 4rem;
    color: #28a745;
    margin-bottom: 1.5rem;
}

/* Email Display */
.email-display {
    font-size: 1.25rem;
    font-weight: 600;
    color: #4a3f9f;
    padding: 1rem;
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
    border-radius: 8px;
    border: 2px solid #4a3f9f;
    margin: 1.5rem auto;
    max-width: 500px;
    word-break: break-word;
}

/* Resend Button */
.btn-resend {
    background: white;
    border: 2px solid #4a3f9f;
    color: #4a3f9f;
    border-radius: 8px;
    padding: 12px 24px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-resend:hover:not(:disabled) {
    background: #4a3f9f;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 63, 159, 0.3);
}

.btn-resend:disabled {
    background: #f8f9fa;
    border-color: #dee2e6;
    color: #6c757d;
    cursor: not-allowed;
    opacity: 0.65;
}

/* Resend Success Alert */
.resend-success {
    animation: slideInDown 0.3s ease;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus Indicators - WCAG 2.1 Level AA compliant */
*:focus {
    outline: 3px solid #4a3f9f;
    outline-offset: 2px;
}

/* Enhanced focus for interactive elements */
.btn:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.toggle-option:focus,
.account-type-card:focus {
    outline: 3px solid #4a3f9f;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(74, 63, 159, 0.25);
}

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: #4a3f9f;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 4px 0;
    font-weight: 600;
}

.skip-to-main:focus {
    top: 0;
    outline: 3px solid white;
    outline-offset: -3px;
    color: white;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .form-control,
    .form-select,
    .btn {
        border-width: 2px;
    }

    .toggle-slider {
        border: 2px solid white;
    }

    .account-type-card.active {
        border-width: 4px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .toggle-slider {
        transition: none;
    }

    .company-fields {
        transition: none;
    }

    .loading-spinner {
        animation: none;
        border-top-color: transparent;
    }
}

/* Keyboard Focus Indicators - WCAG 2.1 Level AA compliant */
*:focus {
    outline: 3px solid #4a3f9f;
    outline-offset: 2px;
}

/* Enhanced focus for interactive elements */
.btn:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.toggle-option:focus,
.account-type-card:focus {
    outline: 3px solid #4a3f9f;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(74, 63, 159, 0.25);
}

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: #4a3f9f;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 4px 0;
    font-weight: 600;
}

.skip-to-main:focus {
    top: 0;
    outline: 3px solid white;
    outline-offset: -3px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .form-control,
    .form-select,
    .btn {
        border-width: 2px;
        border-color: currentColor;
    }

    .account-type-card {
        border-width: 3px;
    }

    .account-type-card.active {
        border-width: 4px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .toggle-slider {
        transition: none;
    }

    .company-fields {
        transition: none;
    }

    .form-control,
    .form-select,
    .btn,
    .account-type-card {
        transition: none;
    }

    .loading-spinner {
        animation: none;
        border-top-color: transparent;
    }
}

/* Ensure sufficient color contrast - WCAG 2.1 Level AA */
.text-muted {
    color: #6c757d !important; /* Contrast ratio 4.5:1 on white */
}

.form-text {
    color: #6c757d; /* Contrast ratio 4.5:1 on white */
}

/* Enhanced link visibility */
a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

a:hover,
a:focus {
    text-decoration-thickness: 2px;
}

/* Copy Email Button Styling */
#copyEmailBtn {
    border-color: #dee2e6;
    color: #4a3f9f;
    transition: all 0.3s ease;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#copyEmailBtn:hover:not(:disabled) {
    background-color: #4a3f9f;
    color: white;
    border-color: #4a3f9f;
}

#copyEmailBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#copyEmailBtn.copied {
    background-color: #28a745;
    border-color: #28a745;
    color: white;
}

/* Input group styling for company email field */
.input-group .form-control {
    border-right: none;
}

.input-group .btn-outline-secondary {
    border-left: 2px solid #dee2e6;
}

.input-group .form-control:focus {
    border-right: none;
}

.input-group .form-control:focus + .btn-outline-secondary {
    border-left-color: #4a3f9f;
}

/* Validation states for input group */
.input-group .form-control.is-invalid {
    border-right: none;
}

.input-group .form-control.is-invalid + .btn-outline-secondary {
    border-left-color: #dc3545;
}

.input-group .form-control.is-valid {
    border-right: none;
}

.input-group .form-control.is-valid + .btn-outline-secondary {
    border-left-color: #28a745;
}

/* Google Places Autocomplete Styling */
.pac-container {
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-family: inherit;
    margin-top: 4px;
    z-index: 1050;
}

.pac-item {
    padding: 12px 16px;
    cursor: pointer;
    border-top: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.pac-item:first-child {
    border-top: none;
}

.pac-item:hover {
    background-color: #f8f9fa;
}

.pac-item-selected {
    background-color: #f0f4ff;
}

.pac-icon {
    margin-right: 12px;
    color: #4a3f9f;
}

.pac-item-query {
    font-weight: 600;
    color: #2c2c2c;
}

.pac-matched {
    font-weight: 700;
    color: #4a3f9f;
}

/* Address field with autocomplete indicator */
#addressLine1[data-autocomplete-fallback="true"] {
    border-left: 4px solid #ffc107;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Header optimizations for mobile */
    .signup-header {
        padding: 1.5rem 1rem;
    }

    .signup-header h1 {
        font-size: 1.5rem;
    }

    .signup-header p {
        font-size: 0.9rem;
    }



    /* All form inputs - minimum 16px font size to prevent iOS zoom */
    .form-control, .form-select {
        font-size: 16px !important; /* Prevent iOS zoom */
        min-height: 48px; /* Touch target size - exceeds 44px minimum */
        padding: 14px 16px; /* Increased padding for better touch targets */
    }

    /* Ensure validation icons don't interfere with touch targets */
    .form-control.is-invalid, 
    .form-control.is-valid,
    .form-select.is-invalid,
    .form-select.is-valid {
        padding-right: 44px; /* More space for icon on mobile */
    }

    /* Buttons - ensure minimum 44x44 touch targets */
    .btn-primary, .btn-resend {
        min-height: 44px;
        padding: 14px 24px;
        font-size: 16px;
    }

    .btn-lg {
        min-height: 48px;
        padding: 16px 24px;
    }

    /* Account type cards - stack vertically and ensure touch targets */
    .account-type-card {
        margin-bottom: 1rem;
        min-height: 120px; /* Ensure adequate touch target */
        padding: 1rem !important;
    }

    .account-icon {
        font-size: 2.5rem; /* Slightly smaller on mobile */
    }

    /* Switch account type button - ensure touch target */
    .btn-outline-primary {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 15px;
    }

    /* Form field stacking - force single column layout */
    .row .col-md-6,
    .row .col-md-5,
    .row .col-md-4,
    .row .col-md-3 {
        width: 100%;
        max-width: 100%;
    }

    /* Ensure proper spacing between stacked fields */
    .row > [class*="col-"] {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Card body padding optimization */
    .card-body {
        padding: 1.5rem 1rem !important;
    }

    .px-4 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Form labels - ensure readability */
    .form-label {
        font-size: 15px;
        margin-bottom: 0.5rem;
    }

    /* Form text and feedback - ensure readability */
    .form-text, .invalid-feedback, .valid-feedback {
        font-size: 14px;
    }

    /* Checkbox touch targets */
    .form-check-input {
        width: 20px;
        height: 20px;
        margin-top: 0.15rem;
    }

    .form-check-label {
        font-size: 15px;
        padding-left: 0.5rem;
    }

    /* Success message optimization */
    .success-message {
        padding: 2rem 1rem;
    }

    .success-message i {
        font-size: 3rem;
    }

    .success-message h2 {
        font-size: 1.5rem;
    }

    .email-display {
        font-size: 1rem;
        padding: 0.875rem;
        margin: 1rem auto;
    }

    /* Google Places Autocomplete - full width on mobile */
    .pac-container {
        width: 100% !important;
        left: 0 !important;
        font-size: 16px; /* Prevent zoom */
    }

    .pac-item {
        padding: 14px 16px; /* Larger touch targets */
        min-height: 44px;
    }

    /* Loading overlay spinner */
    .loading-spinner {
        width: 50px;
        height: 50px;
    }

    /* Reduce margins for better mobile spacing */
    .mb-4 {
        margin-bottom: 1.5rem !important;
    }

    .mb-3 {
        margin-bottom: 1rem !important;
    }



    /* Account type section heading */
    .px-4.pb-4 h3 {
        font-size: 1.25rem;
    }

    /* Validation icons positioning for mobile */
    .validation-icon {
        right: 14px;
        font-size: 20px;
    }
}

/* Extra small devices (phones in portrait, less than 576px) */
@media (max-width: 575px) {
    .signup-header h1 {
        font-size: 1.35rem;
    }

    .card-body {
        padding: 1rem 0.75rem !important;
    }

    .px-4 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    /* Tighter spacing for very small screens */
    .form-control, .form-select {
        padding: 12px 14px;
    }

    .btn-primary, .btn-resend {
        padding: 14px 20px;
    }
}