/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #1a1a1a;
    background-color: #f8fafc;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: #fff;
    border-bottom: 1px solid #e1e5e9;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a1a;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #1d4ed8;
    color: white;
}

.btn-primary:hover {
    background: #1e40af;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-outline {
    background: transparent;
    color: #1d4ed8;
    border: 1px solid #1d4ed8;
}

.btn-outline:hover {
    background: #1d4ed8;
    color: white;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.btn-full {
    width: 100%;
}

/* Layout */
.layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
    padding: 2rem 0;
}

/* Sidebar */
.sidebar {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 100px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    color: #6b7280;
    transition: all 0.2s;
}

.nav-item:hover,
.nav-item.active {
    background: #f1f5f9;
    color: #1d4ed8;
}

/* Feed */
.feed {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
}

.feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e1e5e9;
}

.feed-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Chapter Cards */
.chapter-card {
    padding: 1.5rem;
    border-bottom: 1px solid #e1e5e9;
    cursor: pointer;
    transition: background-color 0.2s;
}

.chapter-card:hover {
    background: #f8fafc;
}

.chapter-card:last-child {
    border-bottom: none;
}

.chapter-meta {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: #6b7280;
}

.chapter-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #1a1a1a;
}

.chapter-preview {
    color: #6b7280;
    line-height: 1.6;
    margin-bottom: 1rem;
    white-space: pre-line;
    font-size: 0.95rem;
    max-height: 4.5em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.chapter-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: #6b7280;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e1e5e9;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
    padding: 0.25rem;
}

.close-btn:hover {
    color: #1a1a1a;
}

.modal-body {
    padding: 1.5rem;
}

/* Chapter Content */
.chapter-content {
    margin-bottom: 2rem;
    line-height: 1.8;
}

.chapter-content h1,
.chapter-content h2,
.chapter-content h3 {
    margin: 1.5rem 0 1rem 0;
    color: #1a1a1a;
}

.chapter-content p {
    margin-bottom: 1rem;
}

.chapter-content ul,
.chapter-content ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.chapter-content li {
    margin-bottom: 0.5rem;
}

/* Comments */
.comments-section h3 {
    margin-bottom: 1rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.comment {
    padding: 1rem;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.comment-author {
    font-weight: 600;
    color: #1a1a1a;
}

.comment-date {
    font-size: 0.875rem;
    color: #6b7280;
}

.comment-content {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.comment-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.comment-like {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 0.875rem;
}

.comment-like:hover,
.comment-like.liked {
    color: #dc2626;
}

.edit-btn,
.delete-btn {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.edit-btn:hover {
    color: #2563eb;
    background-color: #eff6ff;
}

.delete-btn:hover {
    color: #dc2626;
    background-color: #fef2f2;
}

.reply-btn {
    background: none;
    border: 1px solid #d1d5db;
    color: #374151;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

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

.comment-replies {
    margin-left: 2rem;
    margin-top: 1rem;
}

.comment-form {
    margin-top: 1rem;
}

.comment-form textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    resize: vertical;
    font-family: inherit;
    margin-bottom: 1rem;
}

.comment-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Highlight Tooltip */
.highlight-tooltip {
    position: absolute;
    background: #1a1a1a;
    color: white;
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.875rem;
    z-index: 1001;
    pointer-events: none;
}

.highlight-tooltip.show {
    pointer-events: auto;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #1d4ed8;
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

.auth-switch {
    text-align: center;
    margin-top: 1rem;
    color: #6b7280;
}

.auth-switch a {
    color: #1d4ed8;
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
    color: #6b7280;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e1e5e9;
    border-top: 3px solid #1d4ed8;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Responsive */
@media (max-width: 768px) {
    .layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .sidebar {
        position: static;
        order: 2;
    }
    
    .feed {
        order: 1;
    }
    
    .modal.show {
        padding: 1rem;
    }
    
    .comment-replies {
        margin-left: 1rem;
    }
}

/* Text Selection */
::selection {
    background: #dbeafe;
    color: #1e40af;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
