/**
 * Multi-Step Popup CSS
 * Responsive modal styles with slide animations
 */

/* Overlay */
.em-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Prevent body scroll when popup is open */
body.em-popup-open {
    overflow: hidden;
}

/* Container */
.em-popup-container {
    background: #ffffff;
    border-radius: 8px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: emPopupSlideIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

@keyframes emPopupSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Progress Bar (at top) */
.em-popup-progress {
    background: white;
    border-radius: 8px 8px 0 0;
    flex-shrink: 0;
}

.em-progress-bar {
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px 3px 0 0;
    overflow: hidden;
}

.em-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    transition: width 0.4s ease;
}

.em-progress-text {
    text-align: center;
    font-size: 13px;
    color: #666;
    padding: 6px 0 0 0;
    background: white;
}

/* Sticky Header */
.em-popup-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: white;
    flex-shrink: 0;
    gap: 10px;
}

.em-header-left {
    display: flex;
    justify-content: flex-start;
}

.em-header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* Keep logo and center content in compact mode (login) */
.em-compact-mode .em-header-center {
    justify-content: center;
}

.em-header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.em-popup-logo {
    height: 20px;
    display: block;
    flex-shrink: 0;
}

.em-popup-header h2 {
    margin: 0;
    font-size: 20px;
    color: #333;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.3;
}

@media (max-width: 768px) {
    .em-popup-header {
        padding: 10px 12px;
        grid-template-columns: 10px 1fr auto;
    }
    
    .em-header-left {
        width: 10px;
    }
    
    /* Logo and title on left */
    .em-header-center {
        justify-content: flex-start;
        gap: 8px;
    }
    
    .em-popup-logo {
        height: 14px;
    }
    
    .em-popup-header h2 {
        font-size: 12px;
    }
    
    /* Buttons on right */
    .em-header-right {
        gap: 6px;
    }
    
    .em-mode-toggle-btn {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .em-popup-close {
        width: 24px;
        height: 24px;
        font-size: 42px;
    }
}

.em-mode-toggle-btn {
    background: transparent;
    border: 1px solid #ddd;
    color: #666;
    padding: 6px 16px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.em-mode-toggle-btn:hover {
    border-color: #999;
    color: #333;
    background: #f9f9f9;
}

/* Close button */
.em-popup-close {
    background: transparent;
    border: none;
    font-size: 54px;
    line-height: 0;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
    padding: 0;
    width: 32px;
    height: 32px;
}

.em-popup-close:hover {
    color: #e74c3c;
}


/* Scrollable Content */
.em-popup-content {
    flex: 1;
    overflow-y: auto;
    padding: 25px 30px;
    min-height: 0;
}

/* Welcome Message */
.em-welcome-message {
    background: #e8f5e9;
    border-left: 4px solid #4CAF50;
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 4px;
}

.em-welcome-text {
    margin: 0;
    color: #2e7d32;
    font-size: 16px;
    font-weight: 600;
}

/* Slides */
.em-popup-slide {
    display: none;
}

.em-popup-slide.em-slide-active {
    display: block;
    animation: emSlideIn 0.3s ease-out;
}

@keyframes emSlideIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Compact Table Form */
.em-form-table {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 70%;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .em-form-table {
        max-width: 95%;
    }
}

.em-form-table-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    align-items: center;
    gap: 15px;
}

.em-form-table-row label {
    font-weight: 600;
    color: #333;
    font-size: 15px;
    text-align: left;
    margin: 0;
}

.em-form-table-row label .required {
    color: #e74c3c;
}

.em-form-table-row input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px !important;
}

.em-form-table-row input:focus {
    outline: none;
    border-color: #4CAF50;
}

/* Form groups */
.em-form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.em-form-row .em-form-group {
    flex: 1;
    margin-bottom: 0;
}

.em-form-group {
    margin-bottom: 20px;
}

.em-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #333;
    font-size: 18px;
    max-width: 70%;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 768px) {
    .em-form-group label {
        max-width: 95%;
    }
}

.em-field-hint {
    display: none;
}

.em-form-group .required {
    color: #e74c3c;
}

.em-form-group input[type="text"],
.em-form-group input[type="email"],
.em-form-group input[type="password"],
.em-form-group input[type="tel"],
.em-form-group select {
    width: 70%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    margin: 0 auto;
    display: block;
}

@media (max-width: 768px) {
    .em-form-group input[type="text"],
    .em-form-group input[type="email"],
    .em-form-group input[type="password"],
    .em-form-group input[type="tel"],
    .em-form-group select {
        width: 95%;
    }
}

/* Login Mode Styles */
.em-slide-1.em-login-mode {
    max-width: 400px;
    margin: 0 auto;
}

.em-popup-container.em-compact-mode {
    max-height: 500px;
}

.em-popup-container.em-compact-mode .em-popup-content {
    padding: 30px;
}

/* Forgot Password */
.em-forgot-password {
    display: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

/* Center forgot password in login mode */
.em-slide-login .em-forgot-password {
    text-align: center;
    display: block;
    margin: 10px auto 0;
    max-width: 70%;
}

.em-form-group input:focus,
.em-form-group select:focus {
    outline: none;
    border-color: #4CAF50;
}

.em-form-group select {
    background: white;
    cursor: pointer;
}

/* Radio groups */
.em-radio-group {
    display: flex;
    gap: 15px;
    justify-content: space-between;
}

.em-radio-group label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px 20px;
    border: 2px solid #ddd;
    border-radius: 50px;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 0;
    transition: all 0.3s;
    background: white;
}

.em-radio-group label:hover {
    border-color: #4CAF50;
    background: #f8fdf8;
}

.em-radio-group label:has(input[type="radio"]:checked) {
    border-color: #4CAF50;
    border-width: 3px;
    background: #e8f5e9;
    color: #2e7d32;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.em-radio-group input[type="radio"] {
    display: none;
}

/* Checkbox groups */
.em-checkbox-group {
    background: #f9f9f9;
    padding: 12px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.em-checkbox-label {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    font-weight: normal !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
}

/* Override for custom checkbox when using bzc-checkbox-wrapper */
.em-checkbox-label.bzc-checkbox-wrapper {
    align-items: flex-start;
    gap: 0;
}

.em-checkbox-label.bzc-checkbox-wrapper .bzc-checkbox-custom {
    position: relative;
    display: inline-block;
    height: 24px;
    width: 24px;
    min-width: 24px;
    background-color: #fff;
    border: 2px solid #ccc;
    border-radius: 6px;
    margin-right: 10px;
    margin-top: 0;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.em-checkbox-label.bzc-checkbox-wrapper .em-disclaimer-text {
    flex: 1;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.em-checkbox-label.bzc-checkbox-wrapper:hover .bzc-checkbox-custom {
    border-color: #667eea;
}

.em-checkbox-label.bzc-checkbox-wrapper input[type="checkbox"]:checked ~ .bzc-checkbox-custom {
    background-color: #10b981;
    border-color: #10b981;
}

.em-checkbox-label.bzc-checkbox-wrapper .bzc-checkbox-custom:after {
    content: "";
    position: absolute;
    display: none;
    left: 7px;
    top: 3px;
    width: 6px;
    height: 11px;
    border: solid white;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
}

.em-checkbox-label.bzc-checkbox-wrapper input[type="checkbox"]:checked ~ .bzc-checkbox-custom:after {
    display: block;
}

.em-checkbox-label.bzc-checkbox-wrapper input[type="checkbox"]:focus ~ .bzc-checkbox-custom {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.em-checkbox-label input[type="checkbox"] {
    margin-right: 10px;
    margin-top: 2px;
    cursor: pointer;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

/* Hide native checkbox when using custom styles */
.em-checkbox-label.bzc-checkbox-wrapper input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}

.em-disclaimer-text {
    font-size: 14px;
    color: #666;
    line-height: 1.4;
    margin-left: 0;
}

.em-disclaimer-text a {
    color: #4CAF50;
    text-decoration: underline;
    cursor: pointer;
}

.em-disclaimer-text a:hover {
    color: #45a049;
    text-decoration: none;
}

.em-disclaimer-expanded {
    display: block;
    white-space: pre-line;
}

/* Sticky Footer */
.em-popup-footer {
    padding: 15px 30px;
    border-top: 1px solid #e0e0e0;
    background: white;
    border-radius: 0 0 8px 8px;
    display: flex;
    gap: 15px;
    flex-shrink: 0;
}

/* Buttons */
.em-btn {
    padding: 10px 30px;
    border: none;
    border-radius: 4px;
    font-size: 22px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.em-btn-primary {
    background: #4CAF50;
    color: white;
    flex: 1;
}

.em-btn-primary:not(:disabled):hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.em-btn-primary.em-btn-disabled {
    background: #ccc;
    cursor: pointer;
    opacity: 0.6;
}

.em-btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.em-btn-secondary {
    background: #f0f0f0;
    color: #333;
    flex: 0 0 auto;
}

.em-btn-secondary:hover {
    background: #e0e0e0;
}

/* Loading state */
.em-popup-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 100;
}

.em-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4CAF50;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: emSpin 1s linear infinite;
}

@keyframes emSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes emShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.em-form-group.em-field-incomplete {
    animation: emShake 0.5s;
}

.em-form-group.em-field-incomplete input,
.em-form-group.em-field-incomplete select,
.em-form-group.em-field-incomplete textarea {
    border-color: #e74c3c !important;
    border-width: 2px !important;
}

.em-form-group.em-field-incomplete > label {
    color: #e74c3c !important;
}

.em-form-group.em-field-incomplete .em-radio-group {
    animation: emShake 0.5s;
}

.em-form-group.em-field-incomplete .em-radio-group label {
    border-color: #e74c3c !important;
    border-width: 2px !important;
}

.em-checkbox-group.em-field-incomplete {
    animation: emShake 0.5s;
    border-left: 3px solid #e74c3c;
    padding-left: 10px;
    margin-left: -13px;
}

/* Form table row incomplete styling */
.em-form-table-row.em-field-incomplete {
    animation: emShake 0.5s;
}

.em-form-table-row.em-field-incomplete input,
.em-form-table-row.em-field-incomplete select,
.em-form-table-row.em-field-incomplete textarea {
    border-color: #e74c3c !important;
    border-width: 2px !important;
}

.em-form-table-row.em-field-incomplete > label {
    color: #e74c3c !important;
}

.em-popup-loading p {
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

/* Overlay spinner (shown when redirecting) */
.em-overlay-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 100;
}

.em-overlay-spinner .em-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.2);
    border-top: 5px solid #fff;
}

.em-overlay-spinner p {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    margin-top: 20px;
}

/* Conditional fields */
.em-conditional-field {
    margin-top: 15px;
    padding-left: 20px;
    border-left: 3px solid #4CAF50;
}

/* Responsive */
@media (max-width: 640px) {
    .em-popup-overlay {
        padding: 0 !important;
        align-items: flex-start !important;
    }
    
    .em-popup-container {
        margin: 0 !important;
        max-height: 100vh !important;
        height: 100dvh !important;
        width: 100% !important;
        border-radius: 0 !important;
    }
    
    .em-popup-progress {
        border-radius: 0;
    }
    
    .em-progress-text {
        padding: 8px 0 6px 0;
        font-size: 12px;
    }
    
    .em-popup-header {
        padding: 8px 20px 12px;
        border-radius: 0;
        grid-template-columns: 40px 1fr 80px;
    }
    
    .em-header-center {
        justify-content: center;
        align-items: center;
        gap: 8px;
    }
    
    /* In compact mode (login), keep everything centered */
    .em-compact-mode .em-header-center {
        justify-content: center;
        align-items: center;
    }
    
    .em-popup-logo {
        height: 18px;
    }
    
    .em-popup-header h2 {
        font-size: 17px;
        white-space: normal;
        line-height: 1.3;
        text-align: left;
        padding-right: 0;
        margin-bottom: 0;
    }
    
    .em-mode-toggle-btn {
        top: 15px;
        right: 60px;
        padding: 8px 14px;
        font-size: 14px;
    }
    
    .em-popup-close {
        top: 8px;
        right: 15px;
        font-size: 36px;
        width: 40px;
        height: 40px;
    }
    
    .em-popup-content {
        padding: 20px;
    }
    
    .em-form-table-row {
        grid-template-columns: 75px 1fr;
        gap: 10px;
    }
    
    .em-form-table-row label {
        font-size: 14px;
    }
    
    .em-form-table-row input {
        font-size: 16px;
        padding: 8px 10px;
    }
    
    .em-form-row {
        flex-direction: column;
        gap: 0;
        margin-bottom: 0;
    }
    
    .em-form-row .em-form-group {
        margin-bottom: 20px;
    }
    
    .em-radio-group {
        flex-direction: row;
        gap: 10px;
    }
    
    .em-popup-footer {
        padding: 15px 20px;
        flex-direction: column-reverse;
        border-radius: 0;
    }
    
    .em-btn-secondary {
        width: 100%;
    }
    
    .em-btn {
        padding: 12px 20px;
        font-size: 15px;
    }
}

/* Very small/ancient phones - stack labels above inputs */
@media (max-width: 360px) {
    .em-form-table-row {
        grid-template-columns: 1fr;
        gap: 5px;
    }
    
    .em-form-table-row label {
        text-align: left;
    }
}

/* Timeline Slider */
.em-timeline-slider-group {
    margin-bottom: 30px;
}

.em-timeline-slider-group > label {
    font-size: 22px !important;
    margin-bottom: 12px !important;
}

.em-timeline-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    padding: 0 20px;
    margin-top: 12px;
}

.em-timeline-browsing {
    flex-shrink: 0;
    padding-top: 20px;
}

.em-timeline-browsing input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.em-timeline-browsing label {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    text-align: center;
    font-weight: normal !important;
}

.em-timeline-browsing input[type="radio"]:checked + label .em-timeline-dot {
    background: #4CAF50;
    border-color: #4CAF50;
    border-width: 4px;
    transform: scale(1.3);
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.2);
}

.em-timeline-browsing input[type="radio"]:checked + label .em-timeline-label {
    color: #2e7d32;
    font-weight: 700;
}

.em-timeline-slider {
    position: relative;
    padding: 20px 0 0 20px;
    flex: 1;
    min-height: 80px;
}

.em-timeline-slider input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.em-timeline-track {
    position: absolute;
    top: 29px;
    left: 5%;
    right: 5%;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    z-index: 1;
}

.em-timeline-progress {
    position: absolute;
    top: 29px;
    left: 5%;
    height: 4px;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    border-radius: 2px;
    width: 0;
    transition: width 0.3s ease;
    z-index: 2;
}

.em-timeline-slider label {
    position: absolute;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 3;
    font-weight: normal !important;
}

/* Desktop: All labels above the line */
.em-timeline-slider label {
    top: 0;
}

.em-timeline-slider label .em-timeline-label {
    margin-bottom: 8px;
}

.em-timeline-slider label .em-timeline-dot {
    margin: 0;
}

.em-timeline-slider label[data-position="0"] { left: 5%; transform: translateX(0); }
.em-timeline-slider label[data-position="1"] { left: 23%; transform: translateX(-50%); }
.em-timeline-slider label[data-position="2"] { left: 41%; transform: translateX(-50%); }
.em-timeline-slider label[data-position="3"] { left: 59%; transform: translateX(-50%); }
.em-timeline-slider label[data-position="4"] { left: 77%; transform: translateX(-50%); }
.em-timeline-slider label[data-position="5"] { left: 95%; transform: translateX(-100%); }

.em-timeline-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 3px solid #ccc;
    display: block;
    margin-bottom: 8px;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.em-timeline-label {
    font-size: 13px;
    font-weight: 600;
    color: #666;
    line-height: 1.2;
    white-space: nowrap;
    transition: all 0.3s;
}

.em-timeline-subtitle {
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 11px;
    color: #999;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.em-timeline-slider label:hover .em-timeline-dot {
    border-color: #4CAF50;
    transform: scale(1.15);
}

.em-timeline-slider label:hover .em-timeline-label {
    color: #4CAF50;
}

.em-timeline-slider input[type="radio"]:checked + label .em-timeline-dot {
    background: #4CAF50;
    border-color: #4CAF50;
    border-width: 4px;
    transform: scale(1.3);
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.2);
}

.em-timeline-slider input[type="radio"]:checked + label .em-timeline-label {
    color: #2e7d32;
    font-weight: 700;
}

/* Update progress bar based on selection */
.em-timeline-slider:has(#ttb-1:checked) .em-timeline-progress { width: 0%; }
.em-timeline-slider:has(#ttb-2:checked) .em-timeline-progress { width: 19%; }
.em-timeline-slider:has(#ttb-3:checked) .em-timeline-progress { width: 38%; }
.em-timeline-slider:has(#ttb-4:checked) .em-timeline-progress { width: 57%; }
.em-timeline-slider:has(#ttb-5:checked) .em-timeline-progress { width: 76%; }
.em-timeline-slider:has(#ttb-6:checked) .em-timeline-progress { width: 90%; }

/* Mobile: Alternate labels above and below */
@media (max-width: 768px) {
    .em-timeline-container {
        flex-direction: column;
        gap: 2rem;
    }
    
    .em-timeline-slider {
        min-height: 120px;
        padding: 40px 0 30px;
        position: relative;
    }
    
    /* Above timeline - text above, dot at 40px */
    .em-timeline-slider label.em-timeline-above {
        top: 0;
    }
    
    .em-timeline-slider label.em-timeline-above .em-timeline-label {
        margin-bottom: 8px;
    }
    
    .em-timeline-slider label.em-timeline-above .em-timeline-dot {
        margin: 0;
    }
    
    /* Below timeline - dot at 40px, text below */
    .em-timeline-slider label.em-timeline-below {
        top: 40px;
    }
    
    .em-timeline-slider label.em-timeline-below .em-timeline-label {
        margin-top: 8px;
        order: 2;
    }
    
    .em-timeline-slider label.em-timeline-below .em-timeline-dot {
        margin: 0;
        order: 1;
    }
    
    .em-timeline-track {
        top: 40px;
    }
    
    .em-timeline-progress {
        top: 40px;
    }
    
    .em-timeline-subtitle {
        top: 90px;
    }
}

/* Trigger button styling (default) */
.em-popup-trigger-btn {
    background: #4CAF50;
    color: white;
    padding: 14px 30px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.em-popup-trigger-btn:hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}
