/* Reddit-style accordion comment system styles */

/* Base comment styles */
.comments-section {
    margin-top: 40px;
    border-top: 2px solid #f0f0f0;
    padding-top: 30px;
    background-color: transparent !important;
}

.comments-list {
    position: relative;
}

/* Individual comment styling */
.comment {
    position: relative;
    margin-bottom: 0;
    padding: 15px 0;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    background-color: transparent;
    transition: all 0.2s ease;
}

.comment:hover {
    background-color: rgba(0, 0, 0, 0.01);
}

/* Nested comment indentation - using data-depth attribute */
.comment[data-depth="1"] { margin-left: 20px; }
.comment[data-depth="2"] { margin-left: 40px; }
.comment[data-depth="3"] { margin-left: 60px; }
.comment[data-depth="4"] { margin-left: 80px; }
.comment[data-depth="5"] { margin-left: 100px; }
.comment[data-depth="6"] { margin-left: 120px; }
.comment[data-depth="7"] { margin-left: 140px; }
.comment[data-depth="8"] { margin-left: 160px; }

/* Comment header */
.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.comment-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.comment-meta strong {
    color: #333;
    font-size: 14px;
    margin-right: 10px;
}

.comment-meta span {
    color: #666;
    font-size: 12px;
}


/* Comment content */
.comment-content {
    color: #333;
    line-height: 1.5;
    margin-bottom: 8px;
    font-size: 14px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Voting section */
.comment-score {
    display: flex;
    align-items: center;
    gap: 6px;
}

.vote-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 14px;
    padding: 2px 6px;
    transition: color 0.2s ease, transform 0.1s ease;
    outline: none;
}

.vote-btn:hover:not(:disabled) {
    color: #666;
    transform: scale(1.2);
}

.vote-btn:active:not(:disabled) {
    transform: scale(0.9);
}

.vote-btn.upvote.active {
    color: #ff4444 !important;
}

.vote-btn.downvote.active {
    color: #007acc !important;
}

.vote-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.score {
    font-weight: bold;
    color: #333;
    min-width: 20px;
    text-align: center;
    font-size: 13px;
}

/* Comment actions */
.comment-actions {
    padding-top: 8px;
}

.reply-btn {
    background: none;
    border: none;
    color: #007acc;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    transition: color 0.2s;
}

.reply-btn:hover {
    color: #0056b3 !important;
    text-decoration: underline;
}

/* Reply form */
.reply-form {
    margin-top: 15px;
    padding: 15px;
    background-color: #f9f9f9 !important;
    border-radius: 4px;
}

.reply-form textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    box-sizing: border-box;
    background-color: white !important;
    color: #333 !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.reply-form textarea:focus {
    outline: none;
    border-color: #007acc;
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.1);
    background-color: white !important;
}

.reply-form button[type="submit"] {
    background-color: #007acc;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.reply-form button[type="submit"]:hover {
    background-color: #0056b3 !important;
}

.reply-form button[type="submit"]:active {
    transform: scale(0.98);
}

.reply-form button[type="submit"]:disabled {
    background-color: #6c757d !important;
    cursor: not-allowed;
}

.cancel-reply {
    background-color: #ccc;
    color: #333;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.2s;
}

.cancel-reply:hover {
    background-color: #b3b3b3 !important;
}

/* Character counter */
.reply-char-counter,
#char-counter {
    font-size: 11px;
    color: #666;
    transition: color 0.2s ease;
}


/* Thread lines for nested comments */
.comment::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #e0e0e0;
}

.comment[data-depth="0"]::before {
    display: none;
}

/* Depth-specific font sizes */
.comment[data-depth="0"] .comment-content { font-size: 14px; }
.comment[data-depth="1"] .comment-content { font-size: 14px; }
.comment[data-depth="2"] .comment-content { font-size: 13px; }
.comment[data-depth="3"] .comment-content,
.comment[data-depth="4"] .comment-content,
.comment[data-depth="5"] .comment-content { font-size: 13px; }

/* Mobile responsive styles */
@media (max-width: 768px) {
    /* Reduce indentation on mobile */
    .comment[data-depth="1"] { margin-left: 15px; }
    .comment[data-depth="2"] { margin-left: 30px; }
    .comment[data-depth="3"] { margin-left: 45px; }
    .comment[data-depth="4"] { margin-left: 60px; }
    .comment[data-depth="5"] { margin-left: 75px; }
    .comment[data-depth="6"] { margin-left: 90px; }
    .comment[data-depth="7"] { margin-left: 105px; }
    .comment[data-depth="8"] { margin-left: 120px; }
    
    .comment-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px;
    }
    
    .comment-score {
        align-self: flex-end;
    }
    
    .comment {
        font-size: 14px;
    }
    
    .comment-meta strong {
        font-size: 13px;
    }
    
    .comment-meta span {
        font-size: 11px;
    }
    
    .comment-content {
        font-size: 13px !important;
    }
    
    .vote-btn {
        font-size: 14px !important;
    }
    
    .reply-form textarea {
        font-size: 12px !important;
    }
}

/* Main comment form */
.comment-form {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #f9f9f9 !important;
    border-radius: 8px;
}

.comment-form textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
    background-color: white !important;
    color: #333 !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.comment-form textarea:focus {
    outline: none;
    border-color: #007acc;
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.1);
    background-color: white !important;
}

.comment-form button[type="submit"] {
    background-color: #007acc !important;
    color: white !important;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.comment-form button[type="submit"]:hover {
    background-color: #0056b3 !important;
}

.comment-form button[type="submit"]:active {
    transform: scale(0.98);
}

.comment-form button[type="submit"]:disabled {
    background-color: #6c757d !important;
    cursor: not-allowed;
}

/* Login prompt */
.login-prompt {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 8px;
    text-align: center;
}

.login-prompt p {
    margin: 0;
    color: #666;
}

.login-prompt a {
    color: #007acc;
    text-decoration: none;
    font-weight: bold;
}

.login-prompt a:hover {
    text-decoration: underline;
}

/* No comments message */
.no-comments {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

/* Comment highlighting (when linked) */
.comment:target,
.comment-highlighted {
    background-color: #fff3cd;
    border-color: #ffeaa7;
    animation: highlight 3s ease-in-out;
}

@keyframes highlight {
    0% {
        background-color: transparent;
        box-shadow: none;
    }
    20% {
        background-color: #fff3cd;
        box-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
    }
    80% {
        background-color: #fff3cd;
        box-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
    }
    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

/* Loading state */
.comment-loading {
    opacity: 0.6;
    pointer-events: none;
}

.comment-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007acc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error message toast (handled by JS now) */
.comment-error {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: #f44336;
    color: white;
    padding: 15px 20px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 10000;
}

/* Accessibility improvements */
.vote-btn:focus,
.reply-btn:focus,
.cancel-reply:focus,
button[type="submit"]:focus {
    outline: 2px solid #007acc;
    outline-offset: 2px;
}

/* Force light theme for all comment elements */
.comments-section,
.comments-section * {
    background-color: transparent !important;
    color: #333 !important;
}

.comment-form,
.reply-form,
.login-prompt {
    background-color: #f9f9f9 !important;
}

.comment-form textarea,
.reply-form textarea {
    background-color: white !important;
    color: #333 !important;
}

/* Thread arrow indicator for nested replies */
.comment[data-depth]:not([data-depth="0"]) .comment-meta::before {
    content: '↳';
    color: #999;
    font-size: 11px;
    margin-right: 8px;
}

/* Animations for collapse/expand */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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