/* Import Google font for better consistency */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #003366;
    --primary-hover: #004d80;
    --secondary: #F3F4F6;
    --text: #1F2937;
    --text-light: #6B7280;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Form container */
.container.mt-5 {
    margin-bottom: 30px;
    max-width: 800px;
}

/* Progress bar styling */
.progress {
    height: 8px;
    background-color: #f3f6fa;
}

#form-progress-bar {
    background: linear-gradient(90deg, #003366, #0066cc);
    transition: width 0.5s ease;
}

/* Form headers and tips */
.form-header {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #003366, #004d80) !important;
    border-radius: 0.5rem 0.5rem 0 0;
}

.form-header h3 {
    color: #ffffff !important;
}

.form-tips {
    background-color: rgba(0, 51, 102, 0.05);
    border-left: 4px solid #003366;
    padding: 1rem;
    margin-top: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 0 0.5rem 0.5rem 0;
}

.tip-content {
    display: flex;
    align-items: flex-start;
}

.tip-icon {
    color: #FFC107;
    font-size: 1.2rem;
    margin-right: 0.75rem;
    margin-top: 0.25rem;
    flex-shrink: 0;
}

.tip-content p {
    margin-bottom: 0;
    color: #4B5563;
    font-size: 0.95rem;
}

/* Form card styling */
.form-card {
    border: 1px solid #E5E7EB;
    border-top: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    /* Fix for inconsistent heights */
    min-height: 200px;
}

.form-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Form floating labels - Enhanced for better visibility */
.form-floating {
    position: relative;
    margin-bottom: 1.5rem;
}

.form-floating:last-child {
    margin-bottom: 0;
}

.form-floating label {
    color: var(--text-light);
    transition: all 0.2s ease-in-out;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    padding: 1rem;
    pointer-events: none;
    border: 1px solid transparent;
    transform-origin: 0 0;
    font-size: 1rem;
    opacity: 0.7;
}

/* Enhanced label positioning for better visibility */
.form-control:focus~label,
.form-control:not(:placeholder-shown)~label,
.form-select:focus~label,
.form-select:not([value=""]):valid~label,
.form-control[value]:not([value=""])~label {
    transform: scale(0.75) translateY(-0.5rem) translateX(0.15rem);
    background-color: white;
    padding: 0.25rem 0.5rem;
    height: auto;
    opacity: 1;
    color: var(--primary);
    font-weight: 500;
    z-index: 2;
}

/* Ensure labels stay up when form is filled via JavaScript */
.form-floating input:not(:placeholder-shown)~label,
.form-floating select:not([value=""])~label,
.form-floating input[value]:not([value=""])~label {
    transform: scale(0.75) translateY(-0.5rem) translateX(0.15rem);
    background-color: white;
    padding: 0.25rem 0.5rem;
    height: auto;
    opacity: 1;
    color: var(--primary);
    font-weight: 500;
    z-index: 2;
}

.form-control,
.form-select {
    border-radius: 8px;
    padding: 0.75rem 1rem;
    height: auto;
    min-height: calc(2.75rem + 2px);
    line-height: 1.25;
    border: 2px solid #E5E7EB;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background-color: white;
    position: relative;
    z-index: 1;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.1);
    outline: none;
}

/* Standard form labels - always visible above inputs */
.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #374151;
    font-size: 0.95rem;
}

/* Enhanced form control with value styling */
.form-control.has-value,
.form-select:not([value=""]) {
    border-color: var(--primary);
}

/* Step indicators */
.step-indicator {
    text-align: center;
    z-index: 1;
    width: 85px;
}

.step-bubble {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #E5E7EB;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.step-indicator.active .step-bubble {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 0 0 5px rgba(0, 51, 102, 0.1);
}

.step-indicator.completed .step-bubble {
    background: #10B981;
    color: white;
}

.step-title {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
    transition: color 0.3s ease;
    letter-spacing: 0.01em;
}

/* Unique step title override with higher specificity */
.step-indicator .step-title-small {
    display: block;
    font-size: 0.65rem !important;
    color: var(--text-light);
    font-weight: 400 !important;
    transition: color 0.3s ease;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    line-height: 1.2;
}

.step-indicator.active .step-title,
.step-indicator.active .step-title-small {
    color: var(--primary);
    font-weight: 600 !important;
}

.progress-line {
    position: absolute;
    top: 25px;
    left: 50px;
    right: 50px;
    height: 4px;
    background: #E5E7EB;
    z-index: 0;
}

/* Button styles */
.btn-primary {
    background: var(--primary);
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 51, 102, 0.2);
}

.btn-outline-secondary {
    color: #374151;
    border: 2px solid #d1d5db;
    background: #ffffff;
    transition: all 0.3s ease;
    font-weight: 600;
}

.btn-outline-secondary:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #1f2937;
}

.btn-success {
    background: linear-gradient(135deg, #10B981, #059669);
    border: none;
    transition: all 0.3s ease;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.btn-success:disabled {
    background: linear-gradient(135deg, #9ca3af, #6b7280);
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-lg {
    padding: 0.85rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
}

/* Form steps */
.form-step {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s ease;
    display: none;
    /* Fix for consistent heights */
    margin-bottom: 0;
}

.form-step.active {
    opacity: 1;
    transform: translateY(0);
    display: block;
}

/* Witness section styling */
.witness-section {
    background-color: #F9FAFB;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary);
}

.witness-section:last-child {
    margin-bottom: 0;
}

.witness-title {
    color: var(--primary);
    font-weight: 600;
}

/* Enhanced Selection Boxes */
.deed-poll-option {
    border: 2px solid #E5E7EB;
    border-radius: 16px;
    padding: 1.5rem;
    cursor: pointer;
    height: 100%;
    transition: all 0.3s ease;
    background: #FFFFFF;
    position: relative;
    overflow: hidden;
}

.deed-poll-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.deed-poll-icon {
    width: 90px;
    height: 90px;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 51, 102, 0.05);
    border-radius: 50%;
    padding: 15px;
    transition: all 0.3s ease;
}

.deed-poll-option:hover .deed-poll-icon,
.deed-poll-option.selected .deed-poll-icon {
    background: rgba(0, 51, 102, 0.1);
    transform: scale(1.05);
}

.deed-poll-text h5 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.deed-poll-option:hover {
    border-color: var(--primary);
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 51, 102, 0.1);
}

.deed-poll-option:before {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    bottom: -2px;
    left: -2px;
    border: 2px solid transparent;
    border-radius: 16px;
    transition: all 0.3s ease;
}

.deed-poll-radio:checked+.deed-poll-label .deed-poll-option:before,
.deed-poll-option.selected:before {
    border-color: var(--primary);
    background: linear-gradient(to bottom right, rgba(0, 51, 102, 0), rgba(0, 51, 102, 0.05));
}

.deed-poll-radio:checked+.deed-poll-label .deed-poll-text h5,
.deed-poll-option.selected .deed-poll-text h5 {
    color: var(--primary);
    font-weight: 700;
}

/* Fixes for inconsistent form heights */
.card-body {
    padding: 1.5rem;
    height: 100%;
}

#step-4 .form-card,
#step-5 .form-card {
    min-height: 250px;
}

/* Make form cards consistent */
.form-floating:last-of-type {
    margin-bottom: 0;
}

/* Form validation styles */

.is-invalid {
    border-color: #dc3545 !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.has-error {
    border: 1px solid #dc3545;
    border-radius: 8px;
    padding: 8px;
    background-color: rgba(220, 53, 69, 0.05);
}

.error-message {
    font-size: 0.85rem;
    margin-top: 0.25rem;
    color: #dc3545;
}

.validation-alert {
    position: relative;
    margin-top: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
}

/* Fix floating labels with validation */
.form-floating .is-invalid~label {
    color: #dc3545;
}

.form-floating .is-invalid:focus~label {
    color: #dc3545;
}

/* Custom styling for checkbox validation */
.form-check .is-invalid {
    background-image: none;
}

.form-check.has-error {
    background-color: transparent;
    border: none;
    padding-left: 0;
}

.form-check .error-message {
    margin-left: 1.5rem;
}

/* Ensure child section displays correctly */
#special-sections-container.active {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    position: static !important;
    left: auto !important;
    visibility: visible !important;
    z-index: 1 !important;
}

#child-deed-poll-section.active {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    position: static !important;
    left: auto !important;
    visibility: visible !important;
    z-index: 1 !important;
}

.validation-alert {
    margin-bottom: 1rem;
}

/* Confirmation section styling */
.confirmation-section {
    background-color: rgba(0, 51, 102, 0.02);
    border: 1px solid rgba(0, 51, 102, 0.1);
    border-radius: 0.5rem;
    padding: 1.25rem;
    margin-top: 1.5rem;
}

.confirmation-section .form-check {
    margin-bottom: 0;
}

.confirmation-section .form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #003366;
    border-radius: 0.25rem;
    margin-right: 0.75rem;
    margin-top: 0.125rem;
}

.confirmation-section .form-check-input:checked {
    background-color: #003366;
    border-color: #003366;
}

.confirmation-section .form-check-input:focus {
    border-color: #004d80;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(0, 51, 102, 0.25);
}

.confirmation-section .form-check-input.is-invalid {
    border-color: #dc3545;
    animation: shake 0.3s ease-in-out;
}

.confirmation-section .form-check-label {
    font-size: 0.95rem;
    color: #374151;
    line-height: 1.5;
    cursor: pointer;
    font-weight: 500;
}

/* Continue button disabled state */
.btn.next-step:disabled {
    background-color: #9CA3AF;
    border-color: #9CA3AF;
    color: #6B7280;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn.next-step:disabled:hover {
    background-color: #9CA3AF;
    border-color: #9CA3AF;
    transform: none;
}

/* Shake animation for invalid checkbox */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {

    /* Fix progress bar step indicators text overlap on mobile */
    .step-indicator {
        width: 50px;
        /* Slightly larger to accommodate readable text */
        margin: 0 1px;
        /* Small horizontal margin */
    }

    .step-bubble {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
        margin-bottom: 6px;
    }

    .step-indicator .step-title-small {
        font-size: 0.55rem !important;
        /* Larger, more readable font */
        line-height: 1.1;
        word-wrap: break-word;
        max-width: 50px;
        overflow: visible;
        /* Allow text to wrap instead of hiding */
        text-overflow: clip;
        white-space: normal;
        /* Allow text wrapping */
        text-align: center;
        height: auto;
    }

    .progress-line {
        left: 25px;
        right: 25px;
        top: 16px;
    }

    /* Container adjustment */
    .d-flex.justify-content-between {
        gap: 12px;
        padding: 0 4px;
    }

    .d-flex.justify-content-between .btn-lg {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
        border-radius: 10px;
        flex: 1;
    }

    /* Mobile form fixes */
    .form-select,
    .mobile-friendly-select {
        font-size: 0.9rem !important;
        padding: 0.75rem 0.5rem !important;
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
        word-wrap: break-word !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .form-select option,
    .mobile-friendly-select option {
        font-size: 0.85rem !important;
        padding: 0.5rem !important;
        white-space: normal !important;
        word-wrap: break-word !important;
    }

    .delivery-method-group {
        margin-bottom: 1.5rem !important;
    }

    .form-card {
        margin: 0 auto !important;
        border-radius: 0.5rem !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .card-body {
        padding: 1.25rem !important;
    }

    /* Stack delivery address header vertically on mobile */
    #delivery-address-section>.d-flex.justify-content-between {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    #delivery-checkbox-container {
        width: 100% !important;
        justify-content: center !important;
    }
}

@media (max-width: 480px) {

    /* Even more compact for very small screens but still readable */
    .step-indicator {
        width: 45px;
        margin: 0 1px;
    }

    .step-bubble {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
        margin-bottom: 5px;
    }

    .step-indicator .step-title-small {
        font-size: 0.5rem !important;
        /* Still readable on very small screens */
        max-width: 45px;
        line-height: 1.0;
        white-space: normal;
        /* Allow wrapping */
        overflow: visible;
    }

    .progress-line {
        left: 22px;
        right: 22px;
        top: 14px;
    }

    /* Additional container padding for very small screens */
    .d-flex.justify-content-between {
        padding: 0 2px;
        gap: 10px;
    }

    .d-flex.justify-content-between .btn-lg {
        padding: 0.7rem 1rem;
        font-size: 0.9rem;
    }

    /* Extra aggressive mobile form fixes for very small screens */
    .form-select,
    .mobile-friendly-select {
        font-size: 0.8rem !important;
        padding: 0.6rem 0.4rem !important;
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
        word-wrap: break-word !important;
        border-radius: 0.375rem !important;
    }

    .form-select option,
    .mobile-friendly-select option {
        font-size: 0.75rem !important;
        padding: 0.4rem !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        line-height: 1.2 !important;
    }

    .delivery-method-group {
        margin-bottom: 1rem !important;
    }

    .form-label {
        font-size: 0.9rem !important;
        margin-bottom: 0.5rem !important;
        font-weight: 600 !important;
    }

    .form-text {
        font-size: 0.75rem !important;
        margin-top: 0.25rem !important;
    }

    .form-card {
        margin: 0 auto !important;
        border-radius: 0.25rem !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .card-body {
        padding: 1rem !important;
    }

    /* Ensure container doesn't overflow */
    .container,
    .container-fluid {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    /* Ensure form elements stay centered */
    #step-4 .form-card,
    #step-5 .form-card {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}