/* =============== AUTH & PREMIUM STYLES =============== */

/* =============================================================================
   USER AREA IN HEADER
   ============================================================================= */

.modern-header {
    position: relative;
}

#headerUserArea {
    position: absolute;
    top: 15px;
    right: 15px;
}

.header-login-btn {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-lg);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-soft);
}

.header-login-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow-primary);
}

.header-user-btn {
    position: relative;
    background: white;
    border: 2px solid var(--color-border-light);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    padding: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-soft);
}

.header-user-btn:hover {
    border-color: var(--color-primary);
    transform: scale(1.05);
}

.header-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.premium-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    border: 2px solid white;
    border-radius: 50%;
}

/* =============================================================================
   AUTH MODAL
   ============================================================================= */

.auth-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-modal.active {
    display: flex;
}

.auth-modal-content {
    background: white;
    border-radius: var(--radius-xl);
    padding: 40px;
    max-width: 420px;
    width: 100%;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.auth-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--color-text-muted);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.auth-modal-close:hover {
    background: var(--color-border);
    color: var(--color-text);
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.auth-tab {
    flex: 1;
    background: var(--color-border);
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--color-primary);
    color: white;
}

.auth-tab:hover:not(.active) {
    background: var(--color-border-light);
    color: var(--color-text);
}

.auth-form .form-group {
    margin-bottom: 20px;
}

.auth-form label {
    display: block;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
    font-size: 14px;
}

.auth-form input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--color-border-light);
    border-radius: var(--radius-md);
    font-size: 16px;
    transition: all 0.2s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.auth-submit-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.auth-submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow-primary);
}

.auth-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 25px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border-light);
}

.auth-divider span {
    padding: 0 15px;
    color: var(--color-text-muted);
    font-size: 14px;
}

.auth-social {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-social-btn {
    width: 100%;
    padding: 14px 20px;
    border: 2px solid var(--color-border-light);
    border-radius: var(--radius-md);
    background: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.2s;
}

.auth-social-btn:hover {
    border-color: var(--color-text-muted);
    background: var(--color-border);
}

.auth-social-btn.google:hover {
    border-color: #4285f4;
}

.auth-social-btn.github:hover {
    border-color: #333;
}

.auth-error {
    margin-top: 20px;
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    color: #dc2626;
    font-size: 14px;
}

/* =============================================================================
   PROFILE DROPDOWN
   ============================================================================= */

.profile-dropdown {
    display: none;
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 999;
}

.profile-dropdown.active {
    display: block;
    animation: dropdownFadeIn 0.2s ease;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.profile-dropdown-content {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    min-width: 280px;
    overflow: hidden;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-bottom: 1px solid var(--color-border);
}

.profile-avatar-large {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid white;
    box-shadow: var(--shadow-soft);
}

.profile-info {
    display: flex;
    flex-direction: column;
}

.profile-name {
    font-weight: 700;
    color: var(--color-text);
}

.profile-email {
    font-size: 13px;
    color: var(--color-text-muted);
}

.profile-badge {
    padding: 15px 20px;
    border-bottom: 1px solid var(--color-border);
    text-align: center;
}

.premium-badge {
    display: inline-block;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius-lg);
    font-weight: 700;
    font-size: 14px;
}

.upgrade-btn-small {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.upgrade-btn-small:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow-primary);
}

.profile-menu {
    padding: 10px;
}

.profile-menu hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 10px 0;
}

.profile-menu-item {
    width: 100%;
    background: none;
    border: none;
    padding: 12px 15px;
    text-align: left;
    font-size: 15px;
    color: var(--color-text);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.profile-menu-item:hover {
    background: var(--color-border);
}

.profile-menu-item.danger {
    color: #dc2626;
}

.profile-menu-item.danger:hover {
    background: #fef2f2;
}

/* =============================================================================
   PREMIUM MODAL
   ============================================================================= */

.premium-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.premium-modal.active {
    display: flex;
}

.premium-modal-content {
    background: white;
    border-radius: var(--radius-2xl);
    padding: 40px;
    max-width: 480px;
    width: 100%;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalSlideIn 0.3s ease;
}

.premium-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--color-text-muted);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.premium-modal-close:hover {
    background: var(--color-border);
    color: var(--color-text);
}

.premium-header {
    text-align: center;
    margin-bottom: 25px;
}

.premium-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 10px;
}

.premium-header h2 {
    font-size: 28px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 5px;
}

.premium-subtitle {
    color: var(--color-text-muted);
    font-size: 15px;
}

.premium-price-tag {
    text-align: center;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 25px;
}

.premium-price {
    font-size: 42px;
    font-weight: 800;
    color: #92400e;
}

.premium-price-note {
    display: block;
    font-size: 14px;
    color: #b45309;
    margin-top: 5px;
}

.premium-features-list h3 {
    font-size: 16px;
    color: var(--color-text-muted);
    margin-bottom: 15px;
}

.premium-features-list ul {
    list-style: none;
    padding: 0;
}

.premium-features-list li {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

.premium-features-list li:last-child {
    border-bottom: none;
}

.premium-features-list .feature-icon {
    font-size: 24px;
}

.premium-features-list li div {
    flex: 1;
}

.premium-features-list li strong {
    display: block;
    color: var(--color-text);
    margin-bottom: 3px;
}

.premium-features-list li span {
    font-size: 13px;
    color: var(--color-text-muted);
}

.premium-checkout-btn {
    width: 100%;
    padding: 18px 30px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
    transition: all 0.3s;
}

.premium-checkout-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow-primary);
}

.premium-checkout-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.premium-checkout-btn .btn-price {
    background: rgba(255, 255, 255, 0.2);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
}

.premium-secure-note {
    text-align: center;
    margin-top: 15px;
    font-size: 13px;
    color: var(--color-text-muted);
}

/* =============================================================================
   PREMIUM LOCK OVERLAY
   ============================================================================= */

.premium-locked {
    position: relative;
    overflow: hidden;
}

.premium-lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

.premium-lock-content {
    text-align: center;
    padding: 30px;
}

.premium-lock-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 10px;
}

.premium-lock-text {
    display: block;
    font-weight: 700;
    font-size: 18px;
    color: var(--color-text);
    margin-bottom: 5px;
}

.premium-lock-price {
    display: block;
    font-size: 22px;
    font-weight: 800;
    color: var(--color-primary);
    margin-bottom: 10px;
}

.premium-lock-desc {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 15px;
    line-height: 1.5;
}

.premium-unlock-btn {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius-lg);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.premium-unlock-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow-primary);
}

/* =============================================================================
   TOAST NOTIFICATIONS
   ============================================================================= */

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1e293b;
    color: white;
    padding: 16px 30px;
    border-radius: var(--radius-lg);
    font-weight: 600;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-success {
    background: linear-gradient(135deg, #10b981, #059669);
}

.toast-error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.toast-info {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

/* =============================================================================
   SAVE TEST BUTTON
   ============================================================================= */

.save-test-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius-lg);
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
    margin-top: 15px;
}

.save-test-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(16, 185, 129, 0.3);
}

.save-test-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* =============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================= */

@media (max-width: 600px) {
    #headerUserArea {
        top: 10px;
        right: 10px;
    }

    .header-login-btn {
        padding: 8px 16px;
        font-size: 14px;
    }

    .header-user-btn {
        width: 42px;
        height: 42px;
    }

    .profile-dropdown {
        right: 10px;
        left: 10px;
        top: auto;
        bottom: 10px;
    }

    .profile-dropdown-content {
        min-width: 100%;
    }

    .auth-modal-content,
    .premium-modal-content {
        padding: 25px;
    }

    .premium-price {
        font-size: 36px;
    }
}

/* =============================================================================
   CLOUD SYNC STYLES
   ============================================================================= */

.tests-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.save-cloud-btn {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.save-cloud-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(14, 165, 233, 0.3);
}

.save-cloud-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.cloud-sync-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--color-text-muted);
    background: rgba(16, 185, 129, 0.1);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    margin-left: 10px;
    font-weight: normal;
}

.cloud-sync-status .sync-icon {
    font-size: 14px;
}

/* Syncing animation */
@keyframes syncSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.cloud-sync-status.syncing .sync-icon {
    animation: syncSpin 1s linear infinite;
}

/* Test item cloud indicator */
.test-item-synced {
    position: relative;
}

.test-item-synced::after {
    content: '☁️';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    opacity: 0.7;
}

/* =============================================================================
   TOOLTIPS & GLOSSARY
   ============================================================================= */

.tooltip-trigger {
    position: relative;
    cursor: help;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    cursor: help;
    transition: all 0.2s;
}

.tooltip-icon:hover {
    transform: scale(1.1);
    background: var(--color-primary-light);
}

.tooltip-content {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    width: max-content;
    max-width: 320px;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
    text-align: left;
    font-weight: 400;
    pointer-events: none;
}

.tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: #1e293b;
}

.tooltip-trigger:hover .tooltip-content,
.tooltip-icon:hover+.tooltip-content,
.tooltip-content:hover {
    opacity: 1;
    visibility: visible;
}

.tooltip-content strong {
    color: #fbbf24;
    display: block;
    margin-bottom: 4px;
}

/* Tooltip positioned below */
.tooltip-content.tooltip-bottom {
    bottom: auto;
    top: calc(100% + 10px);
}

.tooltip-content.tooltip-bottom::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #1e293b;
}

/* =============================================================================
   AI INTERPRETATION
   ============================================================================= */

.interpretation-container {
    margin-top: 20px;
}

.interpretation-box {
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border: 1px solid #bae6fd;
    border-radius: var(--radius-lg);
    padding: 25px;
}

.interpretation-box h4 {
    font-size: 18px;
    color: #0369a1;
    margin-bottom: 15px;
}

.interpretation-summary {
    font-size: 16px;
    color: #334155;
    padding: 15px;
    background: white;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    border-left: 4px solid #0ea5e9;
}

.interpretation-details {
    margin-bottom: 20px;
}

.interpretation-details p {
    margin-bottom: 12px;
    padding: 12px 15px;
    background: white;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.6;
    color: #475569;
}

.interpretation-details strong {
    color: #0369a1;
}

.interpretation-advice {
    background: white;
    padding: 15px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.interpretation-advice h5 {
    font-size: 15px;
    color: #334155;
    margin-bottom: 12px;
}

.interpretation-advice ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.interpretation-advice li {
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
    color: #475569;
}

.interpretation-advice li:last-child {
    border-bottom: none;
}

.interpretation-plan {
    background: white;
    padding: 15px;
    border-radius: var(--radius-md);
}

.interpretation-plan h5 {
    font-size: 15px;
    color: #334155;
    margin-bottom: 15px;
}

.weekly-plan-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

@media (max-width: 768px) {
    .weekly-plan-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.plan-day {
    padding: 10px 8px;
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 12px;
}

.plan-day strong {
    display: block;
    font-size: 13px;
    margin-bottom: 4px;
}

.plan-day span {
    display: block;
    line-height: 1.4;
}

.plan-day--rest {
    background: #f1f5f9;
    color: #64748b;
}

.plan-day--z1 {
    background: #dcfce7;
    color: #166534;
}

.plan-day--z2 {
    background: #dbeafe;
    color: #1e40af;
}

.plan-day--z3 {
    background: #fef3c7;
    color: #92400e;
}

.plan-day--z4 {
    background: #fee2e2;
    color: #991b1b;
}

.plan-day--z5 {
    background: #f3e8ff;
    color: #7c3aed;
}

/* =============================================================================
   PDF EXPORT BUTTON
   ============================================================================= */

.pdf-export-btn {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    margin: 15px 0;
}

.pdf-export-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(139, 92, 246, 0.3);
}

.pdf-export-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* =============================================================================
   TOOLTIP FIXES - Ensure parents don't clip tooltips
   ============================================================================= */

/* Fix overflow on common parent containers */
.info-box,
.result-box,
.threshold-results,
.threshold-box,
.method-selection,
.form-group,
.stage-input,
h3,
h4,
label {
    overflow: visible !important;
}

/* Fix tooltip position for elements at edge of screen */
.tooltip-content.tooltip-left {
    left: 0;
    transform: none;
}

.tooltip-content.tooltip-right {
    left: auto;
    right: 0;
    transform: none;
}

/* Ensure tooltip trigger can receive hover */
.tooltip-trigger {
    position: relative;
    z-index: 1;
}

/* Make tooltip visible on hover with more specificity */
.tooltip-trigger:hover>.tooltip-content,
.tooltip-trigger:focus>.tooltip-content,
.tooltip-trigger:focus-within>.tooltip-content {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}