.tv-qr-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    box-sizing: border-box;
}

.tv-qr-modal.hidden {
    display: none !important;
}

.tv-qr-modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-primary);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.tv-qr-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0;
}

.tv-qr-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.tv-qr-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

.tv-qr-modal-close:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.tv-qr-modal-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

.tv-qr-scanner-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.tv-qr-camera-container {
    margin-top: 20px;
    text-align: center;
    overflow: hidden;
    border-radius: var(--radius-md);
}

.tv-qr-camera-container.hidden {
    display: none !important;
}

.tv-qr-camera-instructions {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

.tv-qr-video-wrapper {
    width: 100%;
    max-width: 400px;
    height: 300px;
    max-height: 60vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    margin: 16px auto;
}

.tv-qr-camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform-origin: center center;
    transition: none;
}

.tv-qr-scanner-canvas {
    display: none;
}

.tv-qr-zoom-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
}

.zoom-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.zoom-slider {
    width: min(200px, calc(100vw - 120px));
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.zoom-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.zoom-value {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    min-width: 25px;
    text-align: center;
    user-select: none;
}

.tv-qr-status {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    text-align: center;
    margin-top: 16px;
    transition: all 0.3s ease;
}

.tv-qr-status:empty {
    display: none;
}

.tv-qr-status.success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--success);
    color: var(--success);
}

.tv-qr-status.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid #ef4444;
    color: #ef4444;
}


.tv-qr-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--border-primary);
    flex-shrink: 0;
}

.tv-qr-modal-cancel {
    background: var(--bg-card-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

.tv-qr-modal-cancel:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-secondary);
}

@media (max-width: 480px) {
    .tv-qr-modal {
        padding: 12px;
    }
    
    .tv-qr-modal-content {
        max-width: none;
        width: 100%;
        max-height: 95vh;
    }
    
    .tv-qr-modal-header {
        padding: 16px 20px;
    }
    
    .tv-qr-modal-header h3 {
        font-size: 16px;
    }
    
    .tv-qr-modal-body {
        padding: 20px;
    }
    
    .tv-qr-camera-container {
        max-width: none;
        width: 100%;
    }
    
    .tv-qr-camera-instructions {
        font-size: 13px;
    }
    
    .tv-qr-video-wrapper {
        height: 250px;
    }
    
    .tv-qr-zoom-controls {
        padding: 6px 12px;
        gap: 10px;
    }
    
    .zoom-slider {
        width: min(150px, calc(100vw - 100px));
    }
    
    .tv-qr-modal-footer {
        padding: 16px 20px;
    }
}

@media (max-width: 360px) {
    .tv-qr-modal {
        padding: 8px;
    }
    
    .tv-qr-modal-header {
        padding: 12px 16px;
    }
    
    .tv-qr-modal-body {
        padding: 16px;
    }
    
    .tv-qr-camera-instructions {
        font-size: 12px;
    }
    
    .tv-qr-zoom-controls {
        padding: 4px 8px;
        gap: 8px;
    }
    
    .zoom-slider {
        width: min(120px, calc(100vw - 80px));
    }
    
    .zoom-value {
        font-size: 13px;
        min-width: 20px;
    }
    
    .tv-qr-modal-footer {
        padding: 12px 16px;
    }
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.tv-qr-modal:not(.hidden) .tv-qr-modal-content {
    animation: modalFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tv-qr-modal-content {
    background: var(--bg-card, #1e2a3a);
    color: var(--text-primary, #ffffff);
}

body.theme-light .tv-qr-modal-content {
    background: var(--bg-card, #ffffff);
    color: var(--text-primary, #1a1a1a);
}

/* ===== Вкладки ===== */
.tv-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border-primary, rgba(255, 255, 255, 0.1));
    padding-bottom: 0;
}

.tv-tab {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: var(--text-secondary, rgba(255, 255, 255, 0.6));
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    position: relative;
    bottom: -2px;
    user-select: none;
    -webkit-user-select: none;
}

.tv-tab:hover {
    color: var(--text-primary, rgba(255, 255, 255, 0.9));
}

.tv-tab.active {
    color: var(--accent-primary, #ff0066);
    border-bottom-color: var(--accent-primary, #ff0066);
}

.tv-tab-text {
    display: inline-block;
}

/* Контент вкладок */
.tv-tab-content {
    display: none;
    animation: tabFadeIn 0.3s ease;
}

.tv-tab-content.active {
    display: block;
}

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

/* ===== Секция ввода кода ===== */
.tv-code-input-section {
    padding: 20px 0;
    text-align: center;
}

.tv-code-instructions {
    margin-bottom: 28px;
    font-size: 15px;
    color: var(--text-secondary, rgba(255, 255, 255, 0.8));
    line-height: 1.5;
}

.tv-code-inputs {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 28px;
}

.tv-code-digit {
    width: 52px;
    height: 64px;
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    background: var(--bg-secondary, rgba(255, 255, 255, 0.05));
    border: 2px solid var(--border-primary, rgba(255, 255, 255, 0.2));
    border-radius: var(--radius-md, 10px);
    color: var(--text-primary, white);
    transition: all 0.3s ease;
    outline: none;
    caret-color: var(--accent-primary, #ff0066);
}

.tv-code-digit:focus {
    border-color: var(--accent-primary, #ff0066);
    background: var(--bg-card-hover, rgba(255, 255, 255, 0.1));
    transform: scale(1.05);
    box-shadow: 0 0 0 3px var(--accent-primary-alpha, rgba(255, 0, 102, 0.2));
}

.tv-code-digit:not(:placeholder-shown) {
    border-color: var(--success, #10b981);
}

.tv-code-submit {
    padding: 14px 40px;
    font-size: 16px;
    font-weight: 600;
    background: var(--accent-primary, #ff0066);
    color: white;
    border: none;
    border-radius: var(--radius-md, 10px);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(255, 0, 102, 0.3);
    user-select: none;
    -webkit-user-select: none;
}

.tv-code-submit:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.tv-code-submit:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 0, 102, 0.4);
}

.tv-code-submit:not(:disabled):active {
    transform: translateY(0);
}

/* ===== Адаптивность для вкладок и ввода кода ===== */
@media (max-width: 480px) {
    .tv-tabs {
        gap: 6px;
    }

    .tv-tab {
        padding: 10px 16px;
        font-size: 14px;
    }

    .tv-code-inputs {
        gap: 8px;
        margin-bottom: 24px;
    }

    .tv-code-digit {
        width: 46px;
        height: 58px;
        font-size: 24px;
    }

    .tv-code-instructions {
        font-size: 14px;
        margin-bottom: 24px;
    }

    .tv-code-submit {
        padding: 12px 32px;
        font-size: 15px;
    }
}

@media (max-width: 360px) {
    .tv-tabs {
        gap: 4px;
    }

    .tv-tab {
        padding: 8px 12px;
        font-size: 13px;
    }

    .tv-code-inputs {
        gap: 6px;
    }

    .tv-code-digit {
        width: 42px;
        height: 54px;
        font-size: 22px;
    }

    .tv-code-instructions {
        font-size: 13px;
        margin-bottom: 20px;
    }

    .tv-code-submit {
        padding: 10px 28px;
        font-size: 14px;
    }
}

