:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
}

/* Font Awesome icons are used instead */

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Navigation */
.navbar-brand img {
    transition: transform 0.3s ease;
}

.navbar-brand:hover img {
    transform: scale(1.1);
}

/* Novel Cards */
.novel-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: none;
}

.novel-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1) !important;
}

.novel-cover {
    height: 250px;
    object-fit: cover;
    border-radius: 0.375rem 0.375rem 0 0;
}

/* Rating Stars */
.rating-stars {
    cursor: pointer;
}

.rating-star {
    color: #dee2e6;
    transition: color 0.2s ease;
    cursor: pointer;
    margin-right: 2px;
}

.rating-star:hover {
    color: #ffc107;
}

/* Reading Interface */
.reading-container {
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.8;
}

.paragraph {
    position: relative;
    margin-bottom: 1.5rem;
    padding: 1rem;
    border-radius: 0.75rem;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.paragraph:hover {
    background-color: rgba(13, 110, 253, 0.04);
}

.paragraph-content {
    font-size: 1.1rem;
    line-height: 1.8;
    text-align: justify;
    margin-bottom: 0;
}

.paragraph-pair {
    position: relative;
    margin-bottom: 0 !important;
}

.bilingual-primary,
.bilingual-secondary {
    position: relative;
    padding: 1rem;
    border-radius: 0.75rem;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.bilingual-primary:hover,
.bilingual-secondary:hover {
    background-color: rgba(13, 110, 253, 0.04);
}

/* Interaction Sidebar */
.paragraph-hover-icons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.paragraph-hover-icons .paragraph-action {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: none;
    border-radius: 999px;
    background: #f1f3f5;
    color: #0d6efd;
    padding: 0.25rem 0.75rem;
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.paragraph-hover-icons .paragraph-action i {
    font-size: 0.9rem;
}

.paragraph-hover-icons .paragraph-action:hover,
.paragraph-hover-icons .paragraph-action:focus {
    background: rgba(13, 110, 253, 0.12);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(13, 110, 253, 0.15);
}

.paragraph-hover-icons .icon-badge {
    background: #0d6efd;
    color: #fff;
    border-radius: 999px;
    font-size: 0.75rem;
    padding: 0.1rem 0.45rem;
}

.reading-paragraph.is-active {
    background-color: rgba(13, 110, 253, 0.08);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.18);
}

.reading-sidepanel {
    border: none;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    overflow: hidden; /* prevent outer scrolling; inner content handles scroll */
    z-index: 1010; /* below Bootstrap navbar sticky/fixed (1020) */
}

/* Ensure sidebar sticks below navbar height */
.reading-sidepanel.sticky-lg-top {
    top: var(--navbar-offset, 0) !important;
}

.reading-sidepanel .card-body {
    padding: 1.5rem 1.5rem 1.25rem;
}

.reading-sidepanel.is-focused {
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.15);
    transform: translateY(-2px);
}

.sidepanel-section {
    margin-bottom: 1.5rem;
}

.sidepanel-section:last-of-type {
    margin-bottom: 0;
}

.sidepanel-section .section-header h6 {
    letter-spacing: 0.04em;
}

.sidepanel-section .section-header p {
    color: #6c757d;
}

.sidepanel-section .badge {
    font-size: 0.75rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
}

.translation-target-select .form-select {
    min-width: 8.5rem;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

.comments-sort-group .btn {
    border-radius: 999px !important;
}

.comments-sort-group .btn.active {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}

.sidepanel-scroll {
    max-height: 220px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.sidepanel-scroll::-webkit-scrollbar {
    width: 6px;
}

.sidepanel-scroll::-webkit-scrollbar-thumb {
    background: rgba(13, 110, 253, 0.4);
    border-radius: 6px;
}

/* Redesigned sidebar layout */
.sidepanel-body {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 0.5rem;
    height: 100%;
    overflow: hidden;
}

.sidepanel-tabs .btn.active {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}

/* Collapsible helpers for TOC and sidepanel */
#toc-card .list-group-item.active {
    background-color: rgba(13,110,253,.12);
    color: #0d6efd;
    border-color: rgba(13,110,253,.25);
}

#toc-card .list-group-item {
    padding: 0.5rem 0.75rem;
}

.reading-sidepanel.is-collapsed .sidepanel-content-scroll,
.reading-sidepanel.is-collapsed .sidepanel-compose {
    display: none !important;
}

.reading-sidepanel.is-collapsed .sidepanel-body {
    height: auto !important;
    max-height: none !important;
}

.reading-sidepanel .btn#sidepanel-collapse-btn,
#toc-card #toc-toggle-btn {
    padding: 0.1rem 0.4rem;
}

.sidebar-left,
.sidebar-right {
    transition: max-width 0.2s ease, flex-basis 0.2s ease, padding 0.2s ease;
}

.sidebar-left.is-collapsed,
.sidebar-right.is-collapsed {
    flex: 0 0 0 !important;
    max-width: 0 !important;
    width: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    overflow: hidden !important;
}

.sidepanel-content-scroll {
    min-height: 0; /* allow grid to shrink */
    overflow-y: auto;
    padding-right: 0.25rem;
}

.sidepanel-panel { display: none; }
.sidepanel-panel.is-active { display: block; }

.sidepanel-compose {
    background: inherit;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0,0,0,0.075);
}

.compose-row {
    display: grid;
    align-items: start;
    gap: 0.5rem;
}

.compose-comment {
    grid-template-columns: 1fr auto auto;
}

.compose-comment textarea { min-width: 0; }

/* Make rating/select compact like a small button */
.compose-comment .form-select.form-select-sm,
.compose-translation .form-select.form-select-sm {
    height: calc(1.5em + 0.5rem + 2px); /* align with btn-sm/form-control-sm */
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    font-size: 0.875rem;
    line-height: 1.5;
    border-radius: 0.25rem;
    width: auto;
    min-width: 5.5rem; /* keep text readable but compact */
    max-width: 8rem;
    align-self: center;
}

/* (reverted compact rating button styles) */

/* Hide dropdown indicator only for the sidebar comment rating select */
/* Narrow the sidebar rating select without affecting others */
#reading-sidebar #comment-rating.form-select.form-select-sm {
    background-image: none !important;
    -webkit-appearance: none;
    appearance: none;
    padding-right: 0.35rem;
    padding-left: 0.35rem;
    width: auto;
    min-width: 3.25rem; /* fits “5 ⭐” */
    max-width: 4.75rem;
    font-size: 0.875rem;
    line-height: 1.35;
    border-radius: 0.25rem;
    display: inline-block;
    text-align: center;
}

.compose-translation {
    grid-template-columns: 1fr auto;
}

.compose-translation .compose-translation-fields {
    display: flex;
    flex-direction: column;
}

@media (max-width: 992px) {
    .sidepanel-content-scroll { max-height: 45vh; }
}

/* Dark & Sepia theme support for compose area */
.theme-dark .sidepanel-compose { border-top-color: rgba(255,255,255,0.15); }
.theme-sepia .sidepanel-compose { border-top-color: #d4c8a8; }

/* Compact auto-resize textarea */
.auto-resize-textarea {
    resize: none;
    overflow: hidden;
    transition: height 0.15s ease;
    min-height: 2.25rem; /* approximately one line for Bootstrap form-control */
}

.auto-resize-textarea.is-expanded {
    overflow-y: auto;
}

.high-rated-comments {
    margin-bottom: 1rem;
}

.high-rated-comment {
    background: #f8f9fa;
    border-left: 3px solid #28a745;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 0.35rem;
    font-size: 0.9rem;
}

.high-rated-comment .comment-meta {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

.high-rated-comment .comment-text {
    margin-bottom: 0.25rem;
}

.high-rated-comment .comment-score {
    font-size: 0.8rem;
    color: #28a745;
    font-weight: bold;
}

/* Dark Theme Support for Sidebar */
.theme-dark .reading-sidepanel .card-header,
.theme-dark .reading-sidepanel .card-body {
    background: #2d3748;
    color: #e9ecef;
}

.theme-dark .sidepanel-section .badge {
    background: #63b3ed;
    color: #1a202c;
}

.theme-dark .sidepanel-section .section-header p {
    color: #a0aec0;
}

.theme-dark .translation-target-select .form-select {
    background: #1f2937;
    color: #cbd5f5;
    border-color: #4a5568;
}

.theme-dark .high-rated-comment {
    background: #4a5568;
    border-left-color: #68d391;
}

.theme-dark .high-rated-comment .comment-meta {
    color: #a0aec0;
}

.theme-dark .high-rated-comment .comment-score {
    color: #68d391;
}

.theme-dark .paragraph:hover,
.theme-dark .reading-paragraph.is-active,
.theme-dark .bilingual-primary:hover,
.theme-dark .bilingual-secondary:hover {
    background-color: rgba(99, 179, 237, 0.1);
}

/* Sepia Theme Support for Sidebar */
.theme-sepia .reading-sidepanel .card-header,
.theme-sepia .reading-sidepanel .card-body {
    background: #f4f1ea;
    color: #3e2723;
}

.theme-sepia .sidepanel-section .badge {
    background-color: #8d6e63;
    color: #fdfaf4;
}

.theme-sepia .sidepanel-section .section-header p {
    color: #8d6e63;
}

.theme-sepia .translation-target-select .form-select {
    background: #fdfaf4;
    color: #5d4037;
    border-color: #d4c8a8;
}

.theme-sepia .high-rated-comment {
    background: #ede7d9;
    border-left-color: #81c784;
}

.theme-sepia .high-rated-comment .comment-meta {
    color: #8d6e63;
}

.theme-sepia .high-rated-comment .comment-score {
    color: #4caf50;
}

.theme-sepia .paragraph:hover,
.theme-sepia .reading-paragraph.is-active,
.theme-sepia .bilingual-primary:hover,
.theme-sepia .bilingual-secondary:hover {
    background-color: rgba(141, 110, 99, 0.08);
}

/* Responsive Design */
@media (max-width: 768px) {
    .reading-sidepanel .card-body {
        padding: 1.25rem 1rem;
    }
    
    .paragraph-hover-icons {
        justify-content: flex-start;
    }
}

/* Edge toggles to reopen collapsed sidebars */
.edge-toggle {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1030; /* above cards/nav */
    opacity: 0.85;
}
.edge-toggle:hover { opacity: 1; }
.edge-toggle-left { left: 6px; }
.edge-toggle-right { right: 6px; }

/* Comments Modal for Full View */
.comments-modal .modal-body {
    max-height: 500px;
    overflow-y: auto;
}

.comment-item {
    border-left: 3px solid #007bff;
    padding-left: 1rem;
    margin-bottom: 1rem;
}

.comment-reply {
    margin-left: 2rem;
    border-left: 2px solid #6c757d;
}

.comment-actions {
    margin-top: 0.5rem;
}

.comment-vote-btn {
    background: none;
    border: none;
    color: #6c757d;
    padding: 0.25rem 0.5rem;
    margin-right: 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.comment-vote-btn:hover {
    background-color: #f8f9fa;
    color: #007bff;
}

.comment-vote-btn.voted {
    color: #007bff;
    background-color: rgba(0, 123, 255, 0.1);
}

.comment-vote-btn.downvoted {
    color: #dc3545;
    background-color: rgba(220, 53, 69, 0.1);
}

.comment-score {
    font-weight: bold;
    margin: 0 0.25rem;
}

.comment-score.positive {
    color: #28a745;
}

.comment-score.negative {
    color: #dc3545;
}

/* User Avatar */
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.user-avatar-large {
    width: 80px;
    height: 80px;
}

/* Theme Support */
.theme-dark {
    background-color: #1a1a1a !important;
    color: #e9ecef !important;
}

.theme-dark .navbar {
    background-color: #2d3748 !important;
    border-bottom: 1px solid #4a5568;
}

.theme-dark .navbar-brand,
.theme-dark .nav-link {
    color: #e9ecef !important;
}

.theme-dark .nav-link:hover {
    color: #ffffff !important;
}

.theme-dark .card {
    background-color: #2d3748 !important;
    border-color: #4a5568 !important;
    color: #e9ecef !important;
}

.theme-dark .card-header {
    background-color: #4a5568 !important;
    border-bottom-color: #718096 !important;
}

.theme-dark .form-control {
    background-color: #4a5568 !important;
    border-color: #718096 !important;
    color: #e9ecef !important;
}

.theme-dark .form-control:focus {
    background-color: #4a5568 !important;
    border-color: #63b3ed !important;
    color: #e9ecef !important;
    box-shadow: 0 0 0 0.2rem rgba(99, 179, 237, 0.25) !important;
}

.theme-dark .btn-outline-primary {
    color: #63b3ed !important;
    border-color: #63b3ed !important;
}

.theme-dark .btn-outline-primary:hover {
    background-color: #63b3ed !important;
    color: #1a202c !important;
}

.theme-dark .dropdown-menu {
    background-color: #2d3748 !important;
    border-color: #4a5568 !important;
}

.theme-dark .dropdown-item {
    color: #e9ecef !important;
}

.theme-dark .dropdown-item:hover {
    background-color: #4a5568 !important;
    color: #ffffff !important;
}

.theme-dark .text-muted {
    color: #a0aec0 !important;
}

.theme-dark .alert {
    background-color: #2d3748 !important;
    border-color: #4a5568 !important;
    color: #e9ecef !important;
}

.theme-dark .list-group-item {
    background-color: #2d3748 !important;
    border-color: #4a5568 !important;
    color: #e9ecef !important;
}

.theme-dark .list-group-item:hover {
    background-color: #4a5568 !important;
}

.theme-dark .footer {
    background-color: #2d3748 !important;
    color: #e9ecef !important;
}

.theme-dark .footer-text {
    color: #e9ecef !important;
}

.theme-dark .footer-link {
    color: #a0aec0 !important;
}

.theme-dark .footer-link:hover {
    color: #63b3ed !important;
}

.theme-dark .footer hr {
    border-color: #4a5568 !important;
}

.theme-sepia {
    background-color: #f4f1ea !important;
    color: #5d4e37 !important;
}

.theme-sepia .navbar {
    background-color: #e8dcc4 !important;
    border-bottom: 1px solid #d4c4a8;
}

.theme-sepia .navbar-brand,
.theme-sepia .nav-link {
    color: #5d4e37 !important;
}

.theme-sepia .nav-link:hover {
    color: #3d2e17 !important;
}

.theme-sepia .card {
    background-color: #faf7f0 !important;
    border-color: #d4c4a8 !important;
    color: #5d4e37 !important;
}

.theme-sepia .card-header {
    background-color: #e8dcc4 !important;
    border-bottom-color: #d4c4a8 !important;
}

.theme-sepia .form-control {
    background-color: #faf7f0 !important;
    border-color: #d4c4a8 !important;
    color: #5d4e37 !important;
}

.theme-sepia .form-control:focus {
    background-color: #faf7f0 !important;
    border-color: #8b7355 !important;
    color: #5d4e37 !important;
    box-shadow: 0 0 0 0.2rem rgba(139, 115, 85, 0.25) !important;
}

.theme-sepia .btn-outline-primary {
    color: #8b7355 !important;
    border-color: #8b7355 !important;
}

.theme-sepia .btn-outline-primary:hover {
    background-color: #8b7355 !important;
    color: #faf7f0 !important;
}

.theme-sepia .dropdown-menu {
    background-color: #faf7f0 !important;
    border-color: #d4c4a8 !important;
}

.theme-sepia .dropdown-item {
    color: #5d4e37 !important;
}

.theme-sepia .dropdown-item:hover {
    background-color: #e8dcc4 !important;
    color: #3d2e17 !important;
}

.theme-sepia .text-muted {
    color: #8b7355 !important;
}

.theme-sepia .alert {
    background-color: #faf7f0 !important;
    border-color: #d4c4a8 !important;
    color: #5d4e37 !important;
}

.theme-sepia .list-group-item {
    background-color: #faf7f0 !important;
    border-color: #d4c4a8 !important;
    color: #5d4e37 !important;
}

.theme-sepia .list-group-item:hover {
    background-color: #e8dcc4 !important;
}

.theme-sepia .footer {
    background-color: #e8dcc4 !important;
    color: #5d4e37 !important;
}

.theme-sepia .footer-text {
    color: #5d4e37 !important;
}

.theme-sepia .footer-link {
    color: #8b7355 !important;
}

.theme-sepia .footer-link:hover {
    color: #5d4e37 !important;
}

.theme-sepia .footer hr {
    border-color: #d4c4a8 !important;
}

/* Loading Animation */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0,0,0,.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

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

/* Utility Classes */
.text-primary { color: var(--primary-color) !important; }
.bg-primary { background-color: var(--primary-color) !important; }

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Footer */
.footer {
    margin-top: auto;
    background-color: #343a40 !important;
    color: #ffffff !important;
}

.footer-text {
    color: #dee2e6 !important;
}

.footer-link {
    text-decoration: none;
    transition: color 0.3s ease;
    color: #dee2e6 !important;
}

.footer-link:hover {
    color: var(--primary-color) !important;
    text-decoration: none;
}

.footer hr {
    border-color: #495057 !important;
}

/* Light Theme Footer */
.theme-light .footer {
    background-color: #343a40 !important;
    color: #ffffff !important;
}

.theme-light .footer-text {
    color: #dee2e6 !important;
}

.theme-light .footer-link {
    color: #dee2e6 !important;
}

.theme-light .footer-link:hover {
    color: #007bff !important;
}

.theme-light .footer hr {
    border-color: #495057 !important;
}

/* (paragraph-highlighted visual style removed) */

/* Keyboard shortcut hints */
.shortcut-hint {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    z-index: 1000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.shortcut-hint.show {
    opacity: 1;
    transform: translateY(0);
}

kbd {
    display: inline-block;
    padding: 0.125rem 0.25rem;
    font-size: 0.75rem;
    color: #495057;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.2rem;
    box-shadow: inset 0 -1px 0 #dee2e6;
}

.theme-dark kbd {
    color: #e9ecef;
    background-color: #495057;
    border-color: #6c757d;
    box-shadow: inset 0 -1px 0 #6c757d;
}

/* Translation vote buttons styling */
.translation-vote-btn {
    background: none;
    border: none;
    color: #6c757d;
    padding: 0.25rem 0.5rem;
    margin-right: 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    cursor: pointer;
}

.translation-vote-btn:hover {
    background-color: #f8f9fa;
    color: #007bff;
}

.translation-vote-btn.voted {
    color: #28a745;
    background-color: rgba(40, 167, 69, 0.1);
}

.translation-vote-btn.downvoted {
    color: #dc3545;
    background-color: rgba(220, 53, 69, 0.1);
}

.theme-dark .translation-vote-btn:hover {
    background-color: #495057;
}

.theme-dark .translation-vote-btn.voted {
    background-color: rgba(40, 167, 69, 0.2);
}

.theme-dark .translation-vote-btn.downvoted {
    background-color: rgba(220, 53, 69, 0.2);
}

/* Top translation preview styling */
.top-translation {
    background: #f8f9fa;
    border-radius: 0.25rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-left: 3px solid #28a745;
}

.translation-content-preview {
    font-size: 0.9rem;
    line-height: 1.4;
}

.theme-dark .top-translation {
    background: #495057;
    border-left-color: #68d391;
}

.theme-sepia .top-translation {
    background: #ede7d9;
    border-left-color: #4caf50;
}

/* Hybrid Translation Mode */
.hybrid-translation {
    position: relative;
}

.translation-meta {
    border-top: 1px solid rgba(0,0,0,0.08);
    padding: 0.25rem 0.25rem 0.25rem;
    margin-top: 0.25rem;
    background-color: transparent;
    border-radius: 0.25rem;
    font-size: 0.85rem;
    line-height: 1.3;
}

.theme-dark .translation-meta {
    background-color: transparent;
    border-top-color: rgba(255,255,255,0.18);
    color: #e9ecef;
}

.theme-sepia .translation-meta {
    background-color: transparent;
    border-top-color: #d4c4a8;
    color: #5d4e37;
}

/* Novel title link colors for different themes */
.novel-title-link {
    color: #212529 !important;
}

.novel-title-link:hover {
    color: var(--primary-color) !important;
}

.theme-dark .novel-title-link {
    color: #e9ecef !important;
}

.theme-dark .novel-title-link:hover {
    color: #63b3ed !important;
}

.theme-sepia .novel-title-link {
    color: #5d4e37 !important;
}

.theme-sepia .novel-title-link:hover {
    color: #8b7355 !important;
}
