/**
 * Frontend Interactive Sandbox Engine UI Styling
 *
 * @package JS_Sandbox
 */

/* 1. КОНТЕЙНЕР ПЕСОЧНИЦЫ */
.js-sandbox-wrapper {
    margin: 0 0 30px 0;
    font-family: var(--font-sans);
}

.js-sandbox-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 20px;
    overflow: hidden;
}

@media (min-width: 768px) {
    .js-sandbox-card {
        padding: 30px;
    }
}

.js-sandbox-card-header {
    margin-bottom: 25px;
}

.js-sandbox-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: var(--text-primary);
}

.js-sandbox-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin: 0;
}

/* 2. РАБОЧАЯ СЕТКА ИНСТРУМЕНТА */
.js-sandbox-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

@media (min-width: 768px) {
    .js-sandbox-grid {
        grid-template-columns: 1fr 1fr; /* Две колонки: ввод слева, вывод справа */
    }
}

/* 3. ОФОРМЛЕНИЕ ПОЛЕЙ ВВОДА (INPUTS) */
.js-sandbox-form-group {
    margin-bottom: 20px;
    position: relative;
}

.js-sandbox-label-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.js-sandbox-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Обозначение обязательного поля */
.js-sandbox-label.required::after {
    content: " *";
    color: var(--danger);
}

/* Стилизация текстовых полей и инпутов */
.js-sandbox-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.js-sandbox-input {
    width: 100%;
    height: 46px; /* Touch target size (>44px) */
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.js-sandbox-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--border-focus);
}

/* Валидация ошибок ввода (Красная рамка) */
.js-sandbox-input.input-error {
    border-color: var(--danger);
    background-color: var(--danger-light);
}

.js-field-validation-msg {
    display: block;
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 5px;
}

/* Префиксы и суффиксы единиц измерения внутри инпутов */
.js-input-unit {
    position: absolute;
    right: 14px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    pointer-events: none;
}

/* Слайдер / Ползунок (Synced Slider) */
.js-sandbox-slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
}

.js-sandbox-range {
    flex-grow: 1;
    height: 6px;
    -webkit-appearance: none;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
}

.js-sandbox-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast);
}

.js-sandbox-range::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

/* Чекбоксы и переключатели (Switches) */
.js-sandbox-switch-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    user-select: none;
}

.js-sandbox-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--border-color);
    border-radius: 12px;
    transition: background var(--transition-fast);
}

.js-sandbox-switch::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    left: 3px;
    top: 3px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast);
}

input[type="checkbox"]:checked + .js-sandbox-switch {
    background: var(--success);
}

input[type="checkbox"]:checked + .js-sandbox-switch::before {
    transform: translateX(20px);
}

/* 4. ОФОРМЛЕНИЕ ВЫВОДА РЕЗУЛЬТАТОВ (OUTPUTS) */
.js-sandbox-results-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 25px;
}

.js-sandbox-results-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* Контрастная подсветка результатов */
.js-output-block {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--accent-primary);
    box-shadow: var(--shadow-sm);
    transition: background var(--transition-fast);
}

.js-output-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.js-output-value-container {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.js-output-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--accent-primary);
}

.js-output-unit {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Анимация мигания результатов при обновлении (Interaction Feedback) */
@keyframes flashHighlight {
    0% { background-color: var(--accent-light); }
    100% { background-color: var(--bg-secondary); }
}

.flash-updated {
    animation: flashHighlight 0.5s ease-out;
}

/* 5. КНОПКИ УПРАВЛЕНИЯ И ИНТЕРФЕЙСА */
.js-sandbox-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 25px;
}

.js-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px; /* Touch target (>44px) */
    padding: 10px 20px;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast);
    outline: none;
}

.btn-primary {
    background: var(--accent-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
}

.js-sandbox-action-links {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
}

.js-link-btn {
    background: none;
    border: none;
    color: var(--accent-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 0;
    transition: color var(--transition-fast);
}

.js-link-btn:hover {
    color: var(--accent-hover);
}

/* 6. ИНТЕРАКТИВНЫЕ ПОДСКАЗКИ (TOOLTIPS) */
.js-tooltip-trigger {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    margin-left: 6px;
    display: inline-flex;
    align-items: center;
}

.js-tooltip-trigger .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.js-tooltip-trigger:hover {
    color: var(--accent-primary);
}

/* Всплывающие тултипы */
.js-tooltip-box {
    position: absolute;
    background: var(--text-primary);
    color: #fff;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    width: 200px;
    box-shadow: var(--shadow-lg);
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-fast);
    line-height: 1.4;
}

.js-tooltip-box.visible {
    opacity: 1;
}

/* 7. СТИЛИЗАЦИЯ СКЕЛЕТОНОВ (CLS PROTECTION) */
@keyframes skeletonPulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.js-sandbox-skeleton-field {
    height: 74px;
    background: var(--bg-tertiary);
    margin-bottom: 20px;
    border-radius: var(--radius-md);
    animation: skeletonPulse 1.5s infinite ease-in-out;
}

.js-sandbox-skeleton-output {
    height: 150px;
    background: var(--border-color);
    border-radius: var(--radius-md);
    animation: skeletonPulse 1.5s infinite ease-in-out;
}

/* 8. ИНТЕРФЕЙС ИСПРАВЛЕНИЯ ОШИБОК И TOAST */
.js-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: #fff;
    padding: 12px 24px;
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    transition: opacity var(--transition-normal);
    opacity: 1;
}

.js-toast.hidden {
    opacity: 0;
    pointer-events: none;
}

.js-bug-report-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 15px;
}

.js-bug-form-group {
    margin-bottom: 15px;
}

.js-bug-label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 6px;
}

.js-bug-input, .js-bug-textarea {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.9rem;
}

.js-bug-input:focus, .js-bug-textarea:focus {
    border-color: var(--danger);
    outline: none;
}

.js-bug-alert {
    padding: 10px 15px;
    border-radius: var(--radius-sm);
    margin-top: 15px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid var(--success);
}

.alert-danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.hidden {
    display: none !important;
}