/* TU Comments - Modern Card-Based Design */

:root {
    --tu-comments-primary: #ca4f2e;
    --tu-comments-primary-hover: #b04528;
    --tu-comments-focus: #4A90A4;
    --tu-comments-bg: #ffffff;
    --tu-comments-border: #E5E7EB;
    --tu-comments-text: #1F2937;
    --tu-comments-text-muted: #6B7280;
    --tu-comments-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --tu-comments-radius: 12px;
    --tu-comments-transition: 0.3s ease;
}

/* Container */
.tu-comments {
    width: 100%;
    margin: 24px 0;
    background: var(--tu-comments-bg);
    border-radius: var(--tu-comments-radius);
    box-shadow: var(--tu-comments-shadow);
    padding: 24px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    box-sizing: border-box;
}

.tu-comments *,
.tu-comments *::before,
.tu-comments *::after {
    box-sizing: border-box;
}

/* Header */
.tu-comments__header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

@media (min-width: 541px) {
    .tu-comments__header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.tu-comments__title {
    font-size: 20px;
    font-weight: 700;
    color: var(--tu-comments-text);
    margin: 0;
    line-height: 1.3;
}

/* Header row - button */
.tu-comments__header-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

@media (min-width: 541px) {
    .tu-comments__header-row {
        justify-content: flex-end;
    }
}

.tu-comments__header-row--has-comments {
    justify-content: flex-end;
}

/* Toggle Button */
.tu-comments__toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    background: var(--tu-comments-primary);
    color: white;
    border: 2px solid var(--tu-comments-primary);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--tu-comments-transition);
    white-space: nowrap;
}

.tu-comments__toggle-btn:hover {
    background: var(--tu-comments-primary-hover);
    border-color: var(--tu-comments-primary-hover);
    transform: translateY(-1px);
}

.tu-comments__toggle-btn:active {
    transform: translateY(0);
}

.tu-comments__toggle-btn svg {
    width: 16px;
    height: 16px;
    transition: transform var(--tu-comments-transition);
}

.tu-comments__toggle-btn--expanded {
    background: white;
    color: var(--tu-comments-primary);
    border: 2px solid var(--tu-comments-primary);
}

.tu-comments__toggle-btn--expanded:hover {
    background: rgba(202, 79, 46, 0.05);
    border-color: var(--tu-comments-primary);
}

.tu-comments__toggle-btn--expanded svg {
    transform: rotate(180deg);
}

/* Form Container */
.tu-comments__form-container {
    display: none;
    padding-top: 20px;
    border-top: 1px solid var(--tu-comments-border);
    margin-top: 20px;
    animation: tuCommentsSlideDown 0.3s ease;
}

.tu-comments__form-container--visible {
    display: block;
}

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

/* Form */
.tu-comments__form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tu-comments__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tu-comments__label {
    font-size: 14px;
    font-weight: 600;
    color: var(--tu-comments-text);
}

.tu-comments__input,
.tu-comments__textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--tu-comments-border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    color: var(--tu-comments-text);
    transition: border-color var(--tu-comments-transition), box-shadow var(--tu-comments-transition);
    background: #FAFAFA;
}

.tu-comments__input:focus,
.tu-comments__textarea:focus {
    outline: none;
    border-color: var(--tu-comments-focus);
    background: white;
    box-shadow: 0 0 0 3px rgba(74, 144, 164, 0.15);
}

.tu-comments__input::placeholder,
.tu-comments__textarea::placeholder {
    color: #9CA3AF;
}

.tu-comments__textarea {
    min-height: 100px;
    resize: vertical;
}

/* Submit Button - same padding as toggle button */
.tu-comments__submit-btn {
    align-self: flex-start;
    padding: 14px 24px;
    background: var(--tu-comments-primary);
    color: white;
    border: 2px solid var(--tu-comments-primary);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--tu-comments-transition);
}

.tu-comments__submit-btn:hover {
    background: var(--tu-comments-primary-hover);
    border-color: var(--tu-comments-primary-hover);
    transform: translateY(-1px);
}

.tu-comments__submit-btn:active {
    transform: translateY(0);
}

.tu-comments__submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* reCAPTCHA notice - very small */
.tu-comments__recaptcha-notice {
    font-size: 0.6em;
    color: #9CA3AF;
    text-align: left;
    line-height: 1.4;
    margin-top: 4px;
}

.tu-comments__recaptcha-notice a {
    color: #9CA3AF;
    text-decoration: underline;
}

.tu-comments__recaptcha-notice a:hover {
    color: var(--tu-comments-primary);
}

/* Messages */
.tu-comments__message {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    animation: tuCommentsSlideDown 0.3s ease;
}

.tu-comments__message--success {
    background: #D1FAE5;
    color: #065F46;
}

.tu-comments__message--error {
    background: #FEE2E2;
    color: #991B1B;
}

/* Divider */
.tu-comments__divider {
    height: 1px;
    background: var(--tu-comments-border);
    margin: 20px 0;
}

/* Sorting Options - Dropdown */
.tu-comments__sorting {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 16px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--tu-comments-border);
}

.tu-comments__sorting-label {
    font-size: 13px;
    color: var(--tu-comments-text-muted);
    font-weight: 500;
}

.tu-comments__sort-select {
    display: block !important;
    padding: 8px 32px 8px 12px;
    background: white;
    border: 1px solid var(--tu-comments-border);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--tu-comments-text);
    cursor: pointer;
    transition: all var(--tu-comments-transition);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 140px;
}

/* Hide jQuery UI selectmenu replacement */
.tu-comments .ui-selectmenu-button,
.tu-comments .ui-selectmenu-menu,
.tu-comments .ui-selectmenu-text,
.tu-comments + .ui-selectmenu-button,
.tu-comments + .ui-selectmenu-menu,
.tu-comments__sorting .ui-selectmenu-button,
.tu-comments__sorting > span,
#tu-comments-sort-button {
    display: none !important;
}

.tu-comments__sort-select:hover {
    border-color: #9CA3AF;
}

.tu-comments__sort-select:focus {
    outline: none;
    border-color: var(--tu-comments-focus);
    box-shadow: 0 0 0 3px rgba(74, 144, 164, 0.15);
}

/* Comments List */
.tu-comments__list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Single Comment Item - more padding */
.tu-comments__item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 24px 16px;
    margin: 0 -16px;
    border-bottom: 1px solid var(--tu-comments-border);
    background: transparent;
    transition: background var(--tu-comments-transition);
}

.tu-comments__item:hover {
    background: #FAFAFA;
}

.tu-comments__item:last-child {
    border-bottom: none;
}

.tu-comments__item:first-child {
    margin-top: 16px;
}

.tu-comments__item-content {
    flex: 1;
    min-width: 0;
}

.tu-comments__item-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.tu-comments__item-author {
    font-size: 15px;
    font-weight: 700;
    color: var(--tu-comments-text);
}

.tu-comments__item-date {
    font-size: 13px;
    color: var(--tu-comments-text-muted);
}

.tu-comments__item-text {
    font-size: 1em;
    line-height: 1.7;
    color: var(--tu-comments-text);
}

.tu-comments__item-text p {
    margin: 0;
}

/* Comment Actions (reply, voting) */
.tu-comments__item-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #F3F4F6;
}

/* Reply Button */
.tu-comments__reply-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: transparent;
    border: none;
    color: var(--tu-comments-text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--tu-comments-transition);
    border-radius: 4px;
}

.tu-comments__reply-btn:hover {
    color: var(--tu-comments-primary);
    background: rgba(202, 79, 46, 0.08);
}

.tu-comments__reply-btn svg {
    width: 14px;
    height: 14px;
    transition: transform var(--tu-comments-transition);
}

.tu-comments__reply-btn--expanded svg {
    transform: rotate(180deg);
}

/* Voting */
.tu-comments__voting {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tu-comments__vote-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 8px;
    background: transparent;
    border: none;
    color: var(--tu-comments-text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--tu-comments-transition);
    border-radius: 4px;
}

.tu-comments__vote-btn:hover {
    background: #F3F4F6;
}

.tu-comments__vote-btn svg {
    width: 18px;
    height: 18px;
}

.tu-comments__vote-btn--up:hover,
.tu-comments__vote-btn--up.tu-comments__vote-btn--active {
    color: #10B981;
    background: rgba(16, 185, 129, 0.1);
}

.tu-comments__vote-btn--down:hover,
.tu-comments__vote-btn--down.tu-comments__vote-btn--active {
    color: #EF4444;
    background: rgba(239, 68, 68, 0.1);
}

.tu-comments__vote-count {
    font-size: 13px;
    font-weight: 600;
    min-width: 16px;
    text-align: center;
}

.tu-comments__vote-count--positive {
    color: #10B981;
}

.tu-comments__vote-count--negative {
    color: #EF4444;
}

/* Reply Form */
.tu-comments__reply-form-container {
    display: none;
    margin-top: 16px;
    padding: 16px;
    background: #F9FAFB;
    border-radius: 8px;
    animation: tuCommentsSlideDown 0.3s ease;
}

.tu-comments__reply-form-container--visible {
    display: block;
}

.tu-comments__reply-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tu-comments__reply-form .tu-comments__input,
.tu-comments__reply-form .tu-comments__textarea {
    background: white;
}

.tu-comments__reply-form .tu-comments__textarea {
    min-height: 80px;
}

.tu-comments__reply-form .tu-comments__submit-btn {
    padding: 10px 20px;
    font-size: 14px;
}

/* Nested Replies */
.tu-comments__replies {
    margin-top: 16px;
    margin-left: 16px;
    padding-left: 16px;
    border-left: 3px solid var(--tu-comments-primary);
    background: rgba(202, 79, 46, 0.02);
    border-radius: 0 8px 8px 0;
}

.tu-comments__replies .tu-comments__item {
    padding: 16px 12px;
    margin: 0;
    background: transparent;
}

.tu-comments__replies .tu-comments__item:hover {
    background: rgba(202, 79, 46, 0.04);
}

.tu-comments__replies .tu-comments__item:first-child {
    margin-top: 0;
    padding-top: 16px;
}

.tu-comments__replies .tu-comments__item:last-child {
    padding-bottom: 16px;
    border-bottom: none;
}

/* Hide reply button on nested comments (only 1 level) */
.tu-comments__replies .tu-comments__reply-btn {
    display: none;
}

/* Empty state */
.tu-comments__empty {
    text-align: center;
    color: var(--tu-comments-text-muted);
    font-size: 14px;
    padding: 24px 0;
}

/* Mobile Responsive */
@media (max-width: 540px) {
    .tu-comments {
        margin: 16px 0;
        padding: 16px;
        border-radius: 8px;
    }

    .tu-comments__header {
        text-align: center;
    }

    .tu-comments__title {
        font-size: 18px;
    }

    .tu-comments__header-row {
        justify-content: center;
    }

    .tu-comments__header-row--has-comments {
        justify-content: center;
    }

    .tu-comments__toggle-btn {
        padding: 12px 20px;
        font-size: 14px;
    }

    .tu-comments__input,
    .tu-comments__textarea {
        padding: 10px 12px;
        font-size: 14px;
    }

    .tu-comments__submit-btn {
        padding: 12px 20px;
        font-size: 14px;
        width: 100%;
        align-self: center;
    }

    .tu-comments__item {
        padding: 20px 12px;
        margin: 0 -12px;
    }

    .tu-comments__item:first-child {
        margin-top: 12px;
    }

    .tu-comments__item-author {
        font-size: 14px;
    }

    .tu-comments__item-date {
        font-size: 12px;
    }

    .tu-comments__item-text {
        font-size: 0.95em;
    }

    .tu-comments__item-actions {
        gap: 16px;
        padding-top: 10px;
    }

    .tu-comments__replies {
        margin-left: 8px;
        padding-left: 12px;
    }
}

/* Animation for new comments */
.tu-comments__item--new {
    animation: tuCommentsHighlight 2s ease;
}

@keyframes tuCommentsHighlight {
    0% {
        background: rgba(202, 79, 46, 0.15);
    }
    100% {
        background: transparent;
    }
}
