/**
 * Яндекс SmartCaptcha - Кастомные стили
 * Соответствуют дизайн-системе лендинга proantikor.pro
 * Цветовая схема: Teal (#15c4b8) + Dark theme
 */

/* ============================================ */
/* CSS ПЕРЕМЕННЫЕ (соответствуют лендингу) */
/* ============================================ */

:root {
    /* Основные цвета капчи */
    --captcha-primary: #15c4b8;
    --captcha-primary-light: #1de9db;
    --captcha-primary-dark: #0f9a90;
    --captcha-primary-glow: rgba(21, 196, 184, 0.3);

    /* Фоновые цвета */
    --captcha-dark: #0A1214;
    --captcha-secondary: #0F1A1C;
    --captcha-surface: #132125;
    --captcha-surface-elevated: #1A2D31;

    /* Текст */
    --captcha-text: #FFFFFF;
    --captcha-text-muted: #8AA4A8;

    /* Состояния */
    --captcha-error: #E74C3C;
    --captcha-success: #15c4b8;
    --captcha-warning: #F7B731;

    /* Параметры */
    --captcha-border-radius: 12px;
    --captcha-spacing: 16px;
    --captcha-transition: all 0.3s ease;
    --captcha-font-family: 'Onest', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

/* ============================================ */
/* КОНТЕЙНЕР КАПЧИ */
/* ============================================ */

.smart-captcha,
.smartcaptcha-container {
    margin: 20px 0;
    padding: 0;
    display: block;
    min-height: 100px;
    min-height: 60px;
    opacity: 1;
    transition: var(--captcha-transition);
}

.smartcaptcha-container.loading {
    opacity: 0.6;
    pointer-events: none;
}

.smartcaptcha-container.hidden {
    display: none;
}

/* Для invisible капчи контейнер может быть скрыт */
.smartcaptcha-container[data-invisible="true"] {
    min-height: 0;
    margin: 0;
    padding: 0;
}

/* ============================================ */
/* СТИЛИ ДЛЯ ВИДЖЕТА ЯНДЕКС SMARTCAPTCHA */
/* ============================================ */

/* Оборачивающий контейнер виджета */
.smartcaptcha-container > div,
.smartcaptcha-container iframe {
    max-width: 100%;
    border-radius: var(--captcha-border-radius);
    overflow: hidden;
}

/* Кастомизация фона виджета (если visible) */
.smartcaptcha-widget {
    background: var(--captcha-surface) !important;
    border: 1px solid rgba(21, 196, 184, 0.2) !important;
    border-radius: var(--captcha-border-radius) !important;
    padding: var(--captcha-spacing) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
}

/* Кнопка проверки */
.smartcaptcha-widget button,
.smartcaptcha-widget .checkbox {
    background: var(--captcha-surface-elevated) !important;
    border: 2px solid var(--captcha-primary) !important;
    border-radius: 8px !important;
    color: var(--captcha-text) !important;
    font-family: var(--captcha-font-family) !important;
    font-weight: 600 !important;
    transition: var(--captcha-transition) !important;
    cursor: pointer !important;
}

.smartcaptcha-widget button:hover,
.smartcaptcha-widget .checkbox:hover {
    background: var(--captcha-primary) !important;
    border-color: var(--captcha-primary-light) !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--captcha-primary-glow) !important;
}

.smartcaptcha-widget button:active {
    transform: translateY(0);
}

/* Текст внутри виджета */
.smartcaptcha-widget span,
.smartcaptcha-widget label,
.smartcaptcha-widget p {
    color: var(--captcha-text-muted) !important;
    font-family: var(--captcha-font-family) !important;
    font-size: 14px !important;
}

/* Иконка галочки после успешной проверки */
.smartcaptcha-widget .success-icon {
    color: var(--captcha-success) !important;
}

/* ============================================ */
/* СООБЩЕНИЯ ОБ ОШИБКАХ */
/* ============================================ */

.captcha-error {
    display: none;
    margin: 12px 0;
    padding: 12px 16px;
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid var(--captcha-error);
    border-radius: var(--captcha-border-radius);
    color: var(--captcha-error);
    font-family: var(--captcha-font-family);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    animation: slideIn 0.3s ease;
}

.captcha-error.visible {
    display: flex;
    align-items: center;
    gap: 10px;
}

.captcha-error::before {
    content: '⚠️';
    font-size: 18px;
    flex-shrink: 0;
}

/* Кнопка закрытия ошибки */
.captcha-error-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--captcha-error);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.captcha-error-close:hover {
    opacity: 1;
}

/* ============================================ */
/* ИНДИКАТОР ЗАГРУЗКИ */
/* ============================================ */

.captcha-loading {
    display: none;
    margin: 12px 0;
    padding: 16px;
    text-align: center;
    color: var(--captcha-text-muted);
    font-family: var(--captcha-font-family);
    font-size: 14px;
}

.captcha-loading.visible {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.captcha-loading-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--captcha-surface-elevated);
    border-top-color: var(--captcha-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================ */
/* СТАТУС ИНДИКАТОРЫ */
/* ============================================ */

.captcha-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    padding: 8px 14px;
    border-radius: 8px;
    font-family: var(--captcha-font-family);
    font-size: 13px;
    font-weight: 600;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.captcha-status.visible {
    opacity: 1;
    transform: translateY(0);
}

.captcha-status.success {
    background: rgba(21, 196, 184, 0.15);
    color: var(--captcha-success);
    border: 1px solid var(--captcha-primary);
}

.captcha-status.error {
    background: rgba(231, 76, 60, 0.15);
    color: var(--captcha-error);
    border: 1px solid var(--captcha-error);
}

.captcha-status-icon {
    font-size: 16px;
}

/* ============================================ */
/* КНОПКА ОТПРАВКИ (disabled состояние) */
/* ============================================ */

.btn[disabled],
button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(0.3);
}

.btn[disabled]:hover {
    transform: none;
    box-shadow: none;
}

/* Дополнительный стиль для кнопок форм */
#submit-btn-contacts[disabled],
#submit-btn-popup[disabled] {
    background: var(--captcha-surface) !important;
    border-color: var(--captcha-text-muted) !important;
    color: var(--captcha-text-muted) !important;
    position: relative;
}

#submit-btn-contacts[disabled]::after,
#submit-btn-popup[disabled]::after {
    content: '🔒 Пройдите проверку безопасности';
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 12px;
    color: var(--captcha-text-muted);
    font-weight: 400;
}

/* ============================================ */
/* BADGE ДЛЯ INVISIBLE CAPTCHA */
/* ============================================ */

.smartcaptcha-badge {
    position: fixed;
    bottom: 14px;
    right: 14px;
    z-index: 9999;
    background: var(--captcha-surface-elevated);
    border: 1px solid rgba(21, 196, 184, 0.3);
    border-radius: var(--captcha-border-radius);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--captcha-font-family);
    font-size: 11px;
    color: var(--captcha-text-muted);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: var(--captcha-transition);
    opacity: 0.8;
}

.smartcaptcha-badge:hover {
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(21, 196, 184, 0.2);
}

.smartcaptcha-badge-icon {
    width: 16px;
    height: 16px;
    background: var(--captcha-primary);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.smartcaptcha-badge a {
    color: var(--captcha-primary);
    text-decoration: none;
    font-weight: 600;
}

.smartcaptcha-badge a:hover {
    color: var(--captcha-primary-light);
    text-decoration: underline;
}

/* ============================================ */
/* АНИМАЦИИ */
/* ============================================ */

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* ============================================ */
/* АДАПТИВНОСТЬ */
/* ============================================ */

@media (max-width: 768px) {
    .smartcaptcha-container {
        margin: 16px 0;
    }

    .captcha-error {
        font-size: 13px;
        padding: 10px 12px;
    }

    .smartcaptcha-badge {
        bottom: 10px;
        right: 10px;
        font-size: 10px;
        padding: 6px 10px;
    }

    #submit-btn-contacts[disabled]::after,
    #submit-btn-popup[disabled]::after {
        font-size: 11px;
        bottom: -22px;
    }
}

@media (max-width: 480px) {
    .smartcaptcha-container {
        margin: 12px 0;
    }

    .captcha-error {
        font-size: 12px;
    }

    .smartcaptcha-badge {
        font-size: 9px;
        padding: 5px 8px;
        bottom: 8px;
        right: 8px;
    }

    #submit-btn-contacts[disabled]::after,
    #submit-btn-popup[disabled]::after {
        content: '🔒';
        font-size: 14px;
        bottom: -20px;
    }
}

/* ============================================ */
/* ТЕМНАЯ ТЕМА (ДОПОЛНИТЕЛЬНЫЕ ПРАВИЛА) */
/* ============================================ */

@media (prefers-color-scheme: dark) {
    .smartcaptcha-widget {
        background: var(--captcha-surface) !important;
    }
}

/* ============================================ */
/* ACCESSIBILITY (A11Y) */
/* ============================================ */

.smartcaptcha-container:focus-within {
    outline: 2px solid var(--captcha-primary);
    outline-offset: 4px;
    border-radius: var(--captcha-border-radius);
}

/* Высокая контрастность */
@media (prefers-contrast: high) {
    .captcha-error {
        border-width: 2px;
    }

    .smartcaptcha-widget button {
        border-width: 3px !important;
    }
}

/* Уменьшенное движение */
@media (prefers-reduced-motion: reduce) {
    .smartcaptcha-container,
    .captcha-error,
    .captcha-status,
    .smartcaptcha-badge {
        transition: none;
        animation: none;
    }

    .captcha-loading-spinner {
        animation: none;
        border-top-color: var(--captcha-primary);
        border-right-color: var(--captcha-primary);
    }
}

/* ============================================ */
/* DEBUG MODE */
/* ============================================ */

body.captcha-debug .smartcaptcha-container {
    border: 2px dashed var(--captcha-warning);
    padding: 10px;
    position: relative;
}

body.captcha-debug .smartcaptcha-container::before {
    content: 'CAPTCHA DEBUG MODE';
    position: absolute;
    top: -10px;
    left: 10px;
    background: var(--captcha-warning);
    color: var(--captcha-dark);
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 4px;
}

/* ============================================ */
/* PRINT STYLES */
/* ============================================ */

@media print {
    .smartcaptcha-container,
    .captcha-error,
    .captcha-loading,
    .smartcaptcha-badge {
        display: none !important;
    }
}