/**
 * Стилі для AI Debate Block
 * Mobile-first підхід
 */

/* ========== CSS Variables ========== */
:root {
    --color-primary: #667eea;
    --color-primary-dark: #5568d3;
    --color-agree: #28a745;
    --color-agree-light: #d4edda;
    --color-disagree: #dc3545;
    --color-disagree-light: #f8d7da;
    --color-neutral: #6c757d;
    --color-neutral-light: #e2e3e5;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

/* ========== Global Styles ========== */
* {
    box-sizing: border-box;
}

.debate-block {
    max-width: 600px;
    margin: 2rem auto;
    padding: 1rem;
}

/* ========== Header ========== */
.debate-header {
    margin-bottom: 1.5rem;
}

.debate-title {
    font-size: 1.8rem !important;
    font-weight: 700 !important;
    color: #212529 !important;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.debate-icon {
    font-size: 2rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

/* ========== Question Block ========== */
.debate-question-block {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 2rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.debate-question {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
    margin: 0 0 0.5rem 0 !important;
    line-height: 1.4 !important;
    color: white !important;
}

.debate-context {
    font-size: 1rem;
    opacity: 0.9;
    margin: 0;
}

/* ========== Vote Buttons ========== */
.debate-vote-buttons {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .debate-vote-buttons {
        grid-template-columns: repeat(3, 1fr);
    }
}

.debate-vote-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem 1rem;
    border: 3px solid transparent;
    border-radius: var(--border-radius);
    background: white;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

@media (hover: hover) and (pointer: fine) {
    .debate-vote-btn:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    }
    .debate-vote-agree:hover,
    .debate-vote-disagree:hover,
    .debate-vote-neutral:hover,
    .btn-submit:hover,
    .btn-submit.primary:hover,
    .btn-skip:hover,
    .btn-skip.ghost:hover,
    .comment-item:hover,
    .emoji-btn:hover {
        /* залишаємо поточні стилі hover (визначені нижче в файлі) */
    }
}

@media (hover: none) and (pointer: coarse) {
    .debate-vote-btn:hover,
    .debate-vote-agree:hover,
    .debate-vote-disagree:hover,
    .debate-vote-neutral:hover,
    .btn-submit:hover,
    .btn-submit.primary:hover,
    .btn-skip:hover,
    .btn-skip.ghost:hover,
    .comment-item:hover,
    .emoji-btn:hover {
        transform: none;
        box-shadow: none;
        background: inherit;
    }
}

.debate-vote-btn:active {
    transform: translateY(-2px);
}

.debate-vote-btn.active {
    border-color: currentColor;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.vote-icon {
    font-size: 2.5rem;
}

.vote-text {
    text-align: center;
}

/* Button Colors */
.debate-vote-agree {
    color: var(--color-agree);
}

.debate-vote-agree:hover,
.debate-vote-agree.active {
    background: var(--color-agree-light);
}

.debate-vote-disagree {
    color: var(--color-disagree);
}

.debate-vote-disagree:hover,
.debate-vote-disagree.active {
    background: var(--color-disagree-light);
}

.debate-vote-neutral {
    color: var(--color-neutral);
}

.debate-vote-neutral:hover,
.debate-vote-neutral.active {
    background: var(--color-neutral-light);
}

/* ========== Teaser ========== */
.debate-teaser {
    text-align: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    color: #6c757d;
    margin-bottom: 1rem;
}

.debate-teaser p {
    margin: 0;
    font-size: 0.95rem;
}

.debate-teaser strong {
    color: var(--color-primary);
    font-size: 1.1rem;
}

/* ========== Form Styles ========== */
.debate-form-container {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    animation: slideDown 0.3s ease-out;
}

.selected-position {
    font-weight: 600;
    margin-bottom: 1rem;
    color: #111827;
}

.selected-position p {
    margin: 0;
}

.position-label {
    color: var(--color-primary);
    font-size: 1.1rem;
}

.comment-input-wrapper {
    position: relative;
    margin-bottom: 1rem;
}

.comment-textarea {
    width: 100%;
    min-height: 160px;
    max-height: 360px;
    resize: vertical;
    overflow-y: auto;
    line-height: 1.6;
    font-size: 1rem;
    padding: 1rem;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.comment-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.comment-textarea.error {
    border-color: var(--color-disagree);
    animation: shake 0.3s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.char-counter {
    text-align: right;
    font-size: 0.9rem;
    color: #6c757d;
    margin-top: 0.5rem;
}

.char-counter.warning {
    color: var(--color-disagree);
    font-weight: bold;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.btn-submit,
.btn-skip {
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-submit,
.btn-submit.primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    flex: 1;
    box-shadow: 0 8px 18px rgba(102, 126, 234, 0.35);
}

.btn-submit:hover,
.btn-submit.primary:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(102, 126, 234, 0.45);
}

.btn-skip,
.btn-skip.ghost {
    background: #f3f4f6;
    color: #111827;
    border: 1px solid #e5e7eb;
}

.btn-skip:hover,
.btn-skip.ghost:hover {
    background: #e5e7eb;
}

.form-footer {
    text-align: center;
}

.auth-hint {
    font-size: 0.9rem;
    color: #6c757d;
    margin: 0;
}

/* ========== Stats & Summary ========== */
.debate-summary-container {
    margin-top: 2rem;
}

.debate-stats {
    margin-bottom: 2rem;
}

.stats-title {
    font-size: 1.3rem !important;
    font-weight: 700 !important;
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stats-icon {
    font-size: 1.5rem;
}

.stats-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-item {
    margin-bottom: 12px;
}

.stat-inline {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.stat-name {
    color: #111827;
}

.stat-percent-inline {
    color: #4b5563;
}

.stat-bar {
    background: #f1f1f5;
    border-radius: 6px;
    height: 12px;
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.3s ease;
}

.no-stats {
    padding: 12px;
    background: #f8f9fb;
    border: 1px dashed #d7dbe3;
    border-radius: 8px;
    text-align: center;
    color: #6c757d;
}

.insight-box {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #fffbeb;
    border-left: 4px solid #fbbf24;
    border-radius: 8px;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.insight-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.insight-text {
    margin: 0;
    color: #111827;
    line-height: 1.6;
}

/* ========== Comments Section ========== */
.comments-section {
    margin-top: 2rem;
}

.comments-header {
    margin-bottom: 1rem;
}

.comments-title {
    font-size: 1.3rem !important;
    font-weight: 700 !important;
    color: #212529 !important;
    margin: 0;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.comment-item {
    background: white;
    padding: 1rem;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    transition: box-shadow 0.2s;
}

.comment-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.comment-vote-badge {
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 20px;
    font-size: 0.9rem;
}

.comment-date {
    font-size: 0.85rem;
    color: #9ca3af;
}

.comment-author {
    font-size: 0.9rem;
    color: #6b7280;
    font-weight: 500;
}

.comment-text {
    color: #111827;
    line-height: 1.6;
    font-size: 1rem;
}

.no-comments {
    text-align: center;
    padding: 2rem;
    background: #f8f9fa;
    border-radius: 10px;
    color: #6c757d;
}

.no-comments p {
    margin: 0;
}

/* ========== Toast Notification ========== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: #28a745;
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s ease-out;
    z-index: 1000;
}

.toast.error {
    background: #dc3545;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========== Loading Spinner ========== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ========== Utility Classes ========== */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

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

.slide-down {
    animation: slideDown 0.3s ease-out;
}

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

/* ========== Mobile Optimizations ========== */
@media (max-width: 768px) {
    .debate-block {
        padding: 0 0.5rem;
    }

    .debate-title {
        font-size: 1.5rem;
    }

    .debate-question {
        font-size: 1.3rem;
    }

    .debate-question-block {
        padding: 1.5rem;
    }

    .vote-icon {
        font-size: 2rem;
    }

    .vote-text {
        font-size: 0.9rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn-submit {
        width: 100%;
    }
}

/* ========== v3: Tree Comments (Відповіді) ========== */
.comment-item {
    position: relative;
}

/* Відступи для рівнів вкладеності */
.comment-level-0 {
    margin-left: 0;
}

.comment-level-1 {
    margin-left: 2rem;
    border-left: 2px solid #e5e7eb;
    padding-left: 1rem;
    margin-bottom: 1rem;
}

.comment-level-2 {
    margin-left: 4rem;
    border-left: 2px solid #e5e7eb;
    padding-left: 1rem;
}

.comment-level-3 {
    margin-left: 6rem;
    border-left: 2px solid #e5e7eb;
    padding-left: 1rem;
}

.comment-level-4,
.comment-level-5,
.comment-level-6 {
    margin-left: 8rem;
    border-left: 2px solid #e5e7eb;
    padding-left: 1rem;
}

/* ========== v3: Emoji Reactions ========== */
.comment-reactions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
}

.emoji-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.emoji-btn:hover {
    background: #e5e7eb;
    transform: scale(1.05);
}

.emoji-btn.active {
    background: #dbeafe;
    border-color: #3b82f6;
}

.emoji-btn .emoji {
    font-size: 1.1rem;
}

.emoji-btn .emoji-count {
    font-size: 0.85rem;
    color: #6b7280;
    font-weight: 600;
}

.emoji-btn.emoji-add {
    background: transparent;
    border: 1px dashed #d1d5db;
}

.emoji-btn.emoji-add:hover {
    border-color: #9ca3af;
    background: #f9fafb;
}

/* Пікер емодзі (спливаюче меню) */
.emoji-picker {
    position: absolute;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    gap: 0.25rem;
    z-index: 100;
}

.emoji-picker-btn {
    font-size: 1.5rem;
    padding: 0.25rem;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.emoji-picker-btn:hover {
    background: #f3f4f6;
}

/* ========== v3: Comment Actions (Відповісти) ========== */
.comment-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.reply-btn,
.toggle-replies-btn {
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.reply-btn:hover,
.toggle-replies-btn:hover {
    background: #f3f4f6;
    color: var(--color-primary);
}

.replies-count {
    color: #9ca3af;
    font-weight: normal;
}

.toggle-icon {
    transition: transform 0.3s;
}

.toggle-replies-btn.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

/* ========== v3: Reply Form ========== */
.reply-form-container {
    margin-top: 1rem;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    animation: slideDown 0.3s ease-out;
}

.reply-textarea {
    width: 100%;
    min-height: 80px;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
}

.reply-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.reply-form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.btn-submit-reply,
.btn-cancel-reply {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-submit-reply {
    background: var(--color-primary);
    color: white;
}

.btn-submit-reply:hover {
    background: var(--color-primary-dark);
}

.btn-cancel-reply {
    background: transparent;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

.btn-cancel-reply:hover {
    background: #f3f4f6;
}

.reply-char-counter {
    text-align: right;
    font-size: 0.85rem;
    color: #9ca3af;
    margin-top: 0.5rem;
}

.reply-char-counter.warning {
    color: #dc2626;
}

/* Контейнер відповідей */
.replies-container {
    margin-top: 1rem;
}

.replies-container.collapsed {
    display: none;
}

/* ========== Print Styles ========== */
@media print {
    .debate-vote-buttons,
    .debate-form,
    .debate-form-container,
    .btn-submit,
    .btn-skip,
    .comment-reactions,
    .comment-actions,
    .reply-form-container {
        display: none;
    }
}
