/**
 * Rainbow Captcha - Интегрированный стиль с сайтом
 */

 .rainbow-captcha {
    max-width: 420px;
    margin: 0 auto;
    padding: 28px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.1);
    color: #1e293b;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

/* Темная тема для капчи */
[data-theme="dark"] .rainbow-captcha {
    background: rgba(15, 23, 42, 0.95);
    border-color: rgba(139, 92, 246, 0.25);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    color: #f1f5f9;
}

@media (prefers-color-scheme: dark) {
    .rainbow-captcha {
        background: rgba(15, 23, 42, 0.95);
        border-color: rgba(139, 92, 246, 0.25);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
        color: #f1f5f9;
    }
}

.rainbow-captcha::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg,
        rgba(255,255,255,0.06) 0%,
        rgba(255,255,255,0) 50%,
        rgba(0,0,0,0.01) 100%);
    pointer-events: none;
    border-radius: 24px;
}

/* Заголовок */
.rainbow-header {
    margin-bottom: 24px;
    position: relative;
    z-index: 2;
}

.rainbow-header h3 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #1e293b;
    text-shadow: 0 1px 2px rgba(255,255,255,0.1);
    transition: color 0.2s ease;
}

[data-theme="dark"] .rainbow-header h3 {
    color: #f1f5f9;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

@media (prefers-color-scheme: dark) {
    .rainbow-header h3 {
        color: #f1f5f9;
        text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    }
}

.rainbow-header h3 i {
    background: linear-gradient(135deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1));
}

.rainbow-task {
    font-size: 14px;
    color: #475569;
    margin: 0;
    font-weight: 400;
    line-height: 1.5;
    transition: color 0.2s ease;
}

[data-theme="dark"] .rainbow-task {
    color: #cbd5e1;
}

@media (prefers-color-scheme: dark) {
    .rainbow-task {
        color: #cbd5e1;
    }
}

/* Область с радугой */
.rainbow-canvas {
    position: relative;
    margin: 22px 0;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 20px;
    padding: 24px;
    box-shadow:
        0 4px 12px rgba(0,0,0,0.02),
        inset 0 1px 1px rgba(255,255,255,0.05);
    transition: all 0.2s ease;
}

[data-theme="dark"] .rainbow-canvas {
    border-color: rgba(255,255,255,0.12);
    box-shadow:
        0 4px 12px rgba(0,0,0,0.15),
        inset 0 1px 1px rgba(255,255,255,0.02);
}

@media (prefers-color-scheme: dark) {
    .rainbow-canvas {
        border-color: rgba(255,255,255,0.12);
        box-shadow:
            0 4px 12px rgba(0,0,0,0.15),
            inset 0 1px 1px rgba(255,255,255,0.02);
    }
}

.rainbow-svg {
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 2px 12px rgba(0,0,0,0.03));
}

/* П.у. для элементов искр и фейерверков */
.rainbow-sparkles {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    border-radius: 20px;
    overflow: visible;
    z-index: 3;
}

/* Искры и фейерверки - УСКОРЕННЫЕ */
.sparkle, .firework {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    box-shadow: 0 0 6px currentColor;
    z-index: 4;
    will-change: transform, opacity;
}

/* Таймер круга */
.rainbow-timer {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 48px;
    height: 48px;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(14px);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 50%;
    box-shadow:
        0 2px 8px rgba(0,0,0,0.04),
        inset 0 1px 1px rgba(255,255,255,0.06);
    z-index: 5;
}

.timer-circle {
    position: relative;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-circle svg {
    width: 36px;
    height: 36px;
}

.timer-fill {
    stroke: #10b981;
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease;
}

.timer-text {
    position: absolute;
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    pointer-events: none;
}

/* Палитра цветов */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
    margin: 22px 0;
    padding: 20px;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 20px;
    backdrop-filter: blur(15px);
    box-shadow:
        inset 0 1px 1px rgba(255,255,255,0.1),
        0 3px 10px rgba(0,0,0,0.03);
}

.color-btn {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    border: 2px solid #1e293b;
    background: linear-gradient(135deg, #fc5c7d, #6a82fb);
    box-shadow:
        0 6px 10px rgba(0,0,0,0.1),
        inset 0 2px 4px rgba(255,255,255,0.3);
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform, box-shadow;
}

.color-btn:hover {
    transform: translateY(-4px) scale(1.08);
    border-color: #1e293b;
    box-shadow: 0 14px 30px rgba(138,43,226,0.3);
}

.color-btn.selected {
    border-color: #1e293b;
    box-shadow:
        0 18px 35px rgba(138,43,226,0.5);
    animation: pulse 1.2s infinite ease-in-out;
    transform: translateY(-6px) scale(1.12);
}

.color-btn .color-name {
    position: absolute;
    bottom: 6px;
    font-size: 11px;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.45);
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
}

.color-btn .color-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(circle, rgba(255,255,255,0.3), transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.color-btn.selected .color-ripple {
    width: 100px;
    height: 100px;
}

@keyframes pulse {
    0%, 100% { transform: translateY(-6px) scale(1.12); }
    50% { transform: translateY(-8px) scale(1.18); }
}

/* Кнопки управления */
.rainbow-controls {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin: 22px 0 0 0;
    z-index: 4;
}

.rainbow-controls button {
    padding: 14px 32px;
    font-weight: 600;
    font-size: 14px;
    color: white;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    border: 1.5px solid transparent;
    border-radius: 20px;
    box-shadow:
        0 4px 14px rgba(139, 92, 246, 0.25),
        inset 0 2px 6px rgba(255,255,255,0.3);
    cursor: pointer;
    transition: all 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    will-change: transform, box-shadow;
}

.rainbow-controls button:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    transform: translateY(-3px) scale(1.05);
    box-shadow:
        0 8px 24px rgba(139, 92, 246, 0.4),
        inset 0 2px 6px rgba(255,255,255,0.4);
}

/* Messages */
.rainbow-message {
    margin: 22px 0 0;
    padding: 14px 20px;
    border-radius: 20px;
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    backdrop-filter: blur(20px);
    border: 1.5px solid #1e293b;
    box-shadow:
        0 5px 20px rgba(138,43,226,0.1);
    display: none;
}

.rainbow-message.info {
    color: #2563eb;
    border-color:#93c5fd;
    box-shadow:
        0 5px 20px #93c5fd40;
}

.rainbow-message.error {
    color: #dc2626;
    border-color: #fca5a5;
    box-shadow:
        0 5px 20px #fca5a540;
}

.rainbow-message.success {
    color: #16a34a;
    border-color: #6ee7b7;
    box-shadow:
        0 5px 20px #6ee7b740;
}

/* Loading */
.rainbow-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(20px) saturate(150%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    z-index: 99;
    opacity: 0;
    transition: opacity 0.15s ease;
}

[data-theme="dark"] .rainbow-loading {
    background: rgba(15, 23, 42, 0.95);
}

@media (prefers-color-scheme: dark) {
    .rainbow-loading {
        background: rgba(15, 23, 42, 0.95);
    }
}

.rainbow-loading.visible {
    opacity: 1;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    will-change: transform;
}

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

/* Responsive */

@media (max-width: 480px) {
    .rainbow-captcha {
        max-width: 360px;
        padding: 20px;
    }
    
    .color-btn {
        width: 56px;
        height: 56px;
    }
    
    .color-btn .color-name {
        font-size: 10px;
    }
    
    .rainbow-controls button {
        min-width: 140px;
        padding: 10px 20px;
        font-size: 13px;
    }
    
    .rainbow-header h3 {
        font-size: 18px;
    }
    
    .rainbow-task {
        font-size: 13px;
    }
    
    .rainbow-loading {
        border-radius: 15px;
    }
    
    .captcha-instruction {
        padding: 20px 15px;
    }
    
    .instruction-content h3 {
        font-size: 20px;
    }
    
    .instruction-content p {
        font-size: 14px;
    }
    
    .start-captcha-btn {
        padding: 12px 24px;
        font-size: 14px;
    }
    
    .timeout-content {
        padding: 20px;
        max-width: 280px;
    }
    
    .timeout-icon i {
        font-size: 48px;
    }
    
    .timeout-content h3 {
        font-size: 20px;
    }
    
    .timeout-content p {
        font-size: 14px;
    }
    
    .retry-captcha-btn {
        padding: 12px 24px;
        font-size: 14px;
    }
}

/* Инструкция */
.captcha-instruction {
    text-align: center;
    padding: 30px 20px;
}

.instruction-content {
    max-width: 350px;
    margin: 0 auto;
}

.instruction-icon {
    margin-bottom: 20px;
}

.instruction-icon i {
    font-size: 48px;
    background: linear-gradient(135deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.instruction-content h3 {
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 12px 0;
    color: #1e293b;
}

.instruction-content p {
    font-size: 16px;
    color: #1e293b;
    margin: 0 0 24px 0;
    line-height: 1.5;
}

.instruction-example {
    background: #1e293b;
    border: 1px solid #1e293b;
    border-radius: 16px;
    padding: 20px;
    margin: 20px 0;
    backdrop-filter: blur(20px);
}

.example-rainbow {
    margin-bottom: 12px;
}

.example-rainbow svg {
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.1));
}

.instruction-example p {
    font-size: 14px;
    color: #64748b;
    margin: 0;
}

.start-captcha-btn {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    border: none;
    border-radius: 16px;
    padding: 16px 32px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 auto;
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.25);
}

.start-captcha-btn:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.25);
}

.start-captcha-btn i {
    font-size: 18px;
}

/* Диалог таймаута */
.timeout-dialog {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1e293b;
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.3s ease;
    z-index: 100;
    width: 100%;
    height: 100%;
}

.timeout-dialog.show {
    opacity: 1;
    transform: scale(1);
}

.timeout-content {
    text-align: center;
    padding: 30px;
    max-width: 300px;
}

.timeout-icon {
    margin-bottom: 20px;
}

.timeout-icon i {
    font-size: 64px;
    color: #ef4444;
    filter: drop-shadow(0 4px 12px rgba(239, 68, 68, 0.3));
}

.timeout-content h3 {
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 12px 0;
    color: #1e293b;
}

.timeout-content p {
    font-size: 16px;
    color: #1e293b;
    margin: 0 0 24px 0;
    line-height: 1.5;
}

.retry-captcha-btn {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    border: none;
    border-radius: 16px;
    padding: 16px 32px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 auto;
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.25);
}

.retry-captcha-btn:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.25);
}

.retry-captcha-btn i {
    font-size: 18px;
}

/* Main captcha container */
.captcha-main {
    position: relative;
}

/* Success checkmark */
.success-checkmark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
    text-align: center;
    opacity: 0;
    transition: all 0.5s ease;
}

.success-checkmark.show {
    opacity: 1;
}

.success-content {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(25px);
    border: 2px solid rgba(16, 185, 129, 0.3);
    border-radius: 24px;
    padding: 32px 28px;
    box-shadow: 
        0 20px 60px rgba(16, 185, 129, 0.25),
        0 8px 32px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    min-width: 280px;
}

.checkmark-circle {
    margin: 0 auto 24px;
    width: 80px;
    height: 80px;
}

.checkmark {
    width: 100%;
    height: 100%;
}

.checkmark-circle-bg {
    stroke: #10b981;
    stroke-width: 3;
    fill: none;
    stroke-dasharray: 157;
    stroke-dashoffset: 157;
    animation: draw-circle 0.6s ease-in-out forwards;
}

.checkmark-check {
    stroke: #10b981;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: draw-check 0.3s ease-in-out 0.6s forwards;
}

.success-text {
    color: #1e293b;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.success-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #10b981;
}

.success-time {
    font-size: 16px;
    font-weight: 500;
    opacity: 0.8;
}

@keyframes draw-circle {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes draw-check {
    to {
        stroke-dashoffset: 0;
    }
}

/* Dark theme support for success block */
[data-theme="dark"] .success-content {
    background: rgba(30, 41, 59, 0.98);
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 
        0 20px 60px rgba(16, 185, 129, 0.3),
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .success-text {
    color: #f1f5f9;
}

@media (prefers-color-scheme: dark) {
    .success-content {
        background: rgba(30, 41, 59, 0.98);
        border-color: rgba(16, 185, 129, 0.4);
        box-shadow: 
            0 20px 60px rgba(16, 185, 129, 0.3),
            0 8px 32px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
    
    .success-text {
        color: #f1f5f9;
    }
}

/* Глобальные исправления для предотвращения двойного скролла */
.rainbow-captcha,
.rainbow-captcha * {
    /* Убираем любые ограничения по высоте и overflow */
    max-height: none !important;
    overflow: visible !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
}

/* ПРИНУДИТЕЛЬНАЯ темная тема для капчи */
[data-theme="dark"] .rainbow-captcha {
    background: rgba(15, 23, 42, 0.95) !important;
    border-color: rgba(139, 92, 246, 0.25) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .rainbow-captcha * {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .rainbow-header h3 {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .rainbow-task {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .rainbow-canvas {
    border-color: rgba(255,255,255,0.12) !important;
    background: rgba(15, 23, 42, 0.5) !important;
}

[data-theme="dark"] .rainbow-controls button {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%) !important;
    color: white !important;
}

[data-theme="dark"] .rainbow-loading {
    background: rgba(15, 23, 42, 0.95) !important;
}

@media (prefers-color-scheme: dark) {
    .rainbow-captcha {
        background: rgba(15, 23, 42, 0.95) !important;
        border-color: rgba(139, 92, 246, 0.25) !important;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
        color: #f1f5f9 !important;
    }
    
    .rainbow-captcha * {
        color: #f1f5f9 !important;
    }
    
    .rainbow-header h3 {
        color: #f1f5f9 !important;
    }
    
    .rainbow-task {
        color: #cbd5e1 !important;
    }
    
    .rainbow-canvas {
        border-color: rgba(255,255,255,0.12) !important;
        background: rgba(15, 23, 42, 0.5) !important;
    }
    
    .rainbow-controls button {
        background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%) !important;
        color: white !important;
    }
    
    .rainbow-loading {
        background: rgba(15, 23, 42, 0.95) !important;
    }
}

/* Мобильные исправления */
@media (max-width: 768px) {
    .rainbow-captcha {
        max-width: 100%;
        margin: 0;
        padding: 20px;
        border-radius: 16px;
        /* Убираем любые ограничения по высоте */
        max-height: none !important;
        overflow: visible !important;
    }
    
    .rainbow-canvas-area {
        margin: 15px 0;
        padding: 15px;
    }
    
    .rainbow-svg {
        width: 100%;
        height: auto;
        max-height: 200px;
    }
    
    .color-palette {
        gap: 8px;
        padding: 12px;
    }
    
    .color-btn {
        width: 50px;
        height: 50px;
        min-width: 50px;
    }
    
    .color-name {
        font-size: 10px;
    }
    
    .rainbow-controls {
        flex-direction: column;
        gap: 8px;
    }
    
    .rainbow-btn {
        width: 100%;
        min-width: auto;
    }
    
    .success-content {
        min-width: 240px;
        padding: 24px 20px;
    }
    
    .checkmark-circle {
        width: 60px;
        height: 60px;
        margin: 0 auto 16px;
    }
    
    .success-title {
        font-size: 20px;
    }
    
    .success-time {
        font-size: 14px;
    }
}
