/**
 * Pharma Quiz Popup - Frontend Styles
 * 
 * @package PharmaQuizPopup
 * @author Tanmeet Singh - WebsiteCreatorz
 */

/* Sticky Button - PharmaAccess Branded */
.pqp-sticky-btn {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(90deg, #F08900 0%, #1F9E91 100%);
    color: white;
    padding: 15px 12px;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    box-shadow: -2px 4px 15px rgba(31, 158, 145, 0.3);
    z-index: 9998;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-weight: 600;
    display: none;
    border: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    letter-spacing: 0.5px;
    font-size: 14px;
}

.pqp-sticky-btn:hover {
    right: 0;
    box-shadow: -4px 6px 25px rgba(31, 158, 145, 0.4);
    transform: translateY(-50%) scale(1.05);
    padding-right: 15px;
}

.pqp-sticky-btn.show {
    display: block;
    animation: pqpSlideIn 0.5s ease;
}

@keyframes pqpSlideIn {
    from {
        right: -100px;
        opacity: 0;
    }
    to {
        right: 20px;
        opacity: 1;
    }
}

/* Popup Overlay */
.pqp-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    animation: pqpFadeIn 0.3s ease;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.pqp-overlay.active {
    display: flex;
}

/* Popup Container */
.pqp-popup {
    background: white;
    border-radius: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    position: relative;
    animation: pqpSlideUp 0.4s ease;
    box-shadow: 0 10px 50px rgba(0,0,0,0.3);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    margin: 20px;
}

/* Body scroll lock when popup is open */
html.pqp-body-locked,
html.pqp-body-locked body {
    overflow: hidden !important;
    height: 100% !important;
}
body.pqp-body-locked {
    position: fixed !important;
    width: 100% !important;
    left: 0 !important;
}

/* Close Button */
.pqp-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #666;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.pqp-close:hover {
    background: #f0f0f0;
    color: #F08900;
    transform: rotate(90deg) scale(1.1);
}

/* Content Area */
.pqp-content {
    padding: 40px;
    padding-top: 50px;
}

/* Progress Bar - Brand Gradient */
.pqp-progress-container {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 10px;
    margin-bottom: 20px;
    overflow: hidden;
}

.pqp-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #F08900 0%, #1F9E91 100%);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 10px;
    width: 0;
    box-shadow: 0 2px 8px rgba(31, 158, 145, 0.3);
}

/* Step Indicator */
.pqp-step-indicator {
    text-align: center;
    color: #888;
    font-size: 14px;
    margin-bottom: 10px;
    font-weight: 500;
}

/* Headings */
.pqp-popup h2 {
    color: #333;
    font-size: 28px;
    margin-bottom: 10px;
    font-weight: 700;
    line-height: 1.3;
}

.pqp-subtitle {
    color: #666;
    margin-bottom: 25px;
    font-size: 16px;
    line-height: 1.6;
}

/* Form Groups */
.pqp-form-group {
    margin-bottom: 25px;
}

.pqp-form-group label {
    display: block;
    margin-bottom: 10px;
    color: #333;
    font-weight: 600;
    font-size: 15px;
}

.pqp-form-group input[type="text"],
.pqp-form-group input[type="email"],
.pqp-form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s ease;
    font-family: inherit;
    box-sizing: border-box;
}

.pqp-form-group input:focus,
.pqp-form-group select:focus {
    outline: none;
    border-color: #1F9E91;
    box-shadow: 0 0 0 3px rgba(31, 158, 145, 0.1);
}

/* Phone field hint text */
.pqp-field-hint {
    display: block;
    color: #999;
    font-size: 12px;
    margin-top: 5px;
}

.pqp-form-group input[type="tel"] {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s ease;
    font-family: inherit;
    box-sizing: border-box;
}

.pqp-form-group input[type="tel"]:focus {
    outline: none;
    border-color: #1F9E91;
    box-shadow: 0 0 0 3px rgba(31, 158, 145, 0.1);
}

/* Option Groups - Brand Colors */
.pqp-option-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pqp-option-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    user-select: none;
}

.pqp-option-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, rgba(240, 137, 0, 0.05) 0%, rgba(31, 158, 145, 0.05) 100%);
    transition: left 0.3s ease;
}

.pqp-option-item:hover::before {
    left: 0;
}

.pqp-option-item:hover {
    border-color: #1F9E91;
    background: rgba(31, 158, 145, 0.02);
    transform: translateX(5px);
}

.pqp-option-item input[type="checkbox"],
.pqp-option-item input[type="radio"] {
    margin-right: 12px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: #1F9E91;
    position: relative;
    z-index: 2;
}

.pqp-option-item.selected {
    border-color: #1F9E91;
    background: linear-gradient(90deg, rgba(240, 137, 0, 0.05) 0%, rgba(31, 158, 145, 0.08) 100%);
    box-shadow: 0 2px 8px rgba(31, 158, 145, 0.15);
}

.pqp-option-item span {
    flex: 1;
    position: relative;
    z-index: 2;
}

/* Buttons */
.pqp-btn-container {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.pqp-btn {
    flex: 1;
    padding: 14px 30px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

/* Primary Button — teal gradient expands from left on hover (matches PharmaAccess "Start a project") */
.pqp-btn-primary {
    background: linear-gradient(90deg, #F08900 0%, #1F9E91 100%);
    color: #ffffff;
    position: relative;
    overflow: hidden;
}

.pqp-btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #1a8c80 0%, #1F9E91 100%);
    transition: width 0.4s ease;
    z-index: 1;
}

.pqp-btn-primary:hover:not(:disabled)::before {
    width: 100%;
}

/* Button text span — always above the ::before overlay */
.pqp-btn-primary span {
    position: relative;
    z-index: 2;
    color: #ffffff;
}

.pqp-btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(31, 158, 145, 0.4);
}

.pqp-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.pqp-btn-secondary {
    background: #f0f0f0;
    color: #666;
}

.pqp-btn-secondary:hover {
    background: #e0e0e0;
}

/* Summary Box - Brand Styled */
.pqp-summary-box {
    background: linear-gradient(135deg, rgba(31, 158, 145, 0.05) 0%, rgba(240, 137, 0, 0.05) 100%);
    border-left: 4px solid #1F9E91;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(31, 158, 145, 0.1);
}

.pqp-summary-box h3 {
    color: #1F9E91;
    margin-bottom: 10px;
    margin-top: 0;
    font-size: 18px;
    font-weight: 700;
}

.pqp-summary-box p {
    color: #555;
    line-height: 1.6;
    margin: 5px 0;
}

.pqp-summary-box p strong {
    color: #F08900;
}

/* Encouraging Text - Brand Accent */
.pqp-encouraging-text {
    background: linear-gradient(90deg, rgba(240, 137, 0, 0.1) 0%, rgba(246, 141, 30, 0.05) 100%);
    border-left: 3px solid #F08900;
    padding: 12px 15px;
    margin: 15px 0;
    border-radius: 5px;
    font-size: 14px;
    color: #666;
}

/* Step Content */
.pqp-step {
    display: none;
}

.pqp-step.active {
    display: block;
    animation: pqpFadeIn 0.3s ease;
}

/* Animations */
@keyframes pqpFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pqpSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar Styling */
.pqp-popup::-webkit-scrollbar {
    width: 8px;
}

.pqp-popup::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.pqp-popup::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.pqp-popup::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive Design */
@media (max-width: 768px) {
    .pqp-popup {
        width: 95%;
        max-height: 90vh;
        border-radius: 15px;
        margin: 10px;
    }
    
    .pqp-content {
        padding: 25px 18px;
        padding-top: 40px;
    }
    
    .pqp-popup h2 {
        font-size: 22px;
    }
    
    /* Keep buttons in one row on mobile */
    .pqp-btn-container {
        flex-direction: row;
        gap: 10px;
        margin-top: 20px;
    }
    
    .pqp-btn {
        padding: 12px 16px;
        font-size: 15px;
    }
    
    .pqp-form-group input[type="tel"] {
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    /* Sticky button flush to bottom, no gap */
    .pqp-sticky-btn {
        font-size: 14px;
        padding: 12px 20px;
        writing-mode: horizontal-tb;
        top: auto;
        bottom: 0;
        border-radius: 12px 12px 0 0;
        left: 50%;
        transform: translateX(-50%);
        right: auto;
        white-space: nowrap;
    }
    
    .pqp-sticky-btn:hover {
        transform: translateX(-50%);
    }
    
    .pqp-sticky-btn.show {
        animation: pqpSlideUpMobile 0.5s ease forwards;
    }
    
    @keyframes pqpSlideUpMobile {
        from {
            bottom: -60px;
            opacity: 0;
        }
        to {
            bottom: 0;
            opacity: 1;
        }
    }
    
    .pqp-option-item {
        padding: 12px;
        font-size: 14px;
    }
    
    /* Touch-friendly tap targets */
    .pqp-close {
        width: 44px;
        height: 44px;
        font-size: 32px;
        top: 8px;
        right: 8px;
    }
    
    /* Swipe indicator for mobile */
    .pqp-popup::after {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: #e0e0e0;
        border-radius: 2px;
    }
    
    .pqp-form-group {
        margin-bottom: 18px;
    }
    
    .pqp-subtitle {
        margin-bottom: 18px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .pqp-content {
        padding: 20px 14px;
        padding-top: 36px;
    }
    
    .pqp-popup h2 {
        font-size: 20px;
    }
    
    .pqp-option-item {
        padding: 10px;
    }
    
    .pqp-btn {
        padding: 11px 12px;
        font-size: 14px;
    }
    
    .pqp-form-group input[type="text"],
    .pqp-form-group input[type="email"],
    .pqp-form-group input[type="tel"],
    .pqp-form-group select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Tablet landscape */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .pqp-popup {
        max-height: 85vh;
    }
}

/* Loading Spinner */
.pqp-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: pqpSpin 0.8s linear infinite;
}

@keyframes pqpSpin {
    to { transform: rotate(360deg); }
}

/* Touch feedback */
.pqp-option-item:active {
    transform: scale(0.98);
}

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

/* Accessibility - Focus visible */
.pqp-btn:focus-visible,
.pqp-option-item:focus-visible,
.pqp-close:focus-visible {
    outline: 2px solid #1F9E91;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .pqp-option-item {
        border-width: 3px;
    }
    
    .pqp-option-item.selected {
        border-width: 4px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .pqp-overlay,
    .pqp-popup,
    .pqp-sticky-btn,
    .pqp-progress-bar,
    .pqp-btn,
    .pqp-option-item {
        animation: none !important;
        transition: none !important;
    }
}
