/* Reader Mode Page Specific Styles */

/* Chat History Sidebar Base Styles */
.chat-history-sidebar {
    position: fixed;
    top: 72px;
    left: 0;
    width: 60px;
    height: calc(100vh - 72px);
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    transition: width 0.3s ease-in-out, transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Mobilde sidebar overlay olarak çalışır */
@media (max-width: 768px) {
    .chat-history-sidebar {
        transform: translateX(-100%);
        width: 320px;
    }
    
    .chat-history-sidebar.open {
        transform: translateX(0);
    }
}

/* Sidebar açık durumu */
.chat-history-sidebar.open {
    width: 320px;
}

/* Büyük ekranlarda sidebar varsayılan olarak açık */
@media (min-width: 1200px) {
    .chat-history-sidebar {
        width: 60px;
    }
    
    body.sidebar-closed .chat-history-sidebar {
        width: 60px;
    }
}

/* Sidebar kapalıyken header ve content gizle */
.chat-history-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    position: sticky;
    top: 0;
    z-index: 1;
    opacity: 1;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.chat-history-header h6 {
    margin: 0;
    color: var(--text-color);
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.close-sidebar-btn {
    background: none;
    border: none;
    color: var(--secondary-text);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-sidebar-btn:hover {
    background: var(--card-hover-bg);
    color: var(--text-color);
}

.chat-history-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.chat-history-list {
    padding: 0;
}

.chat-history-search {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper i {
    position: absolute;
    left: 12px;
    color: var(--secondary-text);
    z-index: 1;
}

.search-input-wrapper input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--message-bg);
    color: var(--text-color);
    font-size: 14px;
    transition: all 0.2s ease;
}

.search-input-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(115, 103, 240, 0.1);
}

.chat-history-sidebar:not(.open) .chat-history-header {
    opacity: 0;
    pointer-events: none;
}

.chat-history-sidebar:not(.open) .chat-history-content {
    opacity: 0;
    pointer-events: none;
}

@media (min-width: 1200px) {
    body.sidebar-closed .chat-history-sidebar .chat-history-header {
        opacity: 0;
        pointer-events: none;
    }
    
    body.sidebar-closed .chat-history-sidebar .chat-history-content {
        opacity: 0;
        pointer-events: none;
    }
}

/* Guest message styles */
.chat-history-guest {
    padding: 24px 20px;
    text-align: center;
}

.chat-history-guest-message {
    margin-bottom: 20px;
}

.chat-history-guest-message i {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.chat-history-guest-message p {
    color: var(--secondary-text);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

.chat-history-login-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.chat-history-login-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(115, 103, 240, 0.3);
}

/* Loading states */
.chat-history-loading {
    padding: 16px;
}

.loading-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
}

.loading-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--hover-bg);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-details {
    flex: 1;
    min-width: 0;
}

.loading-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 4px;
}

.loading-preview {
    font-size: 12px;
    color: var(--secondary-text);
}

.loading-line {
    height: 16px;
    background: var(--hover-bg);
    border-radius: 4px;
    margin-bottom: 8px;
}

.loading-line-small {
    height: 12px;
    width: 60%;
    background: var(--hover-bg);
    border-radius: 4px;
}

.shimmer {
    animation: shimmer 1.5s infinite;
    background: linear-gradient(
        90deg,
        var(--hover-bg) 0%,
        var(--border-color) 50%,
        var(--hover-bg) 100%
    );
    background-size: 200% 100%;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.chat-history-items {
    padding: 8px;
}

/* Sidebar inner toggle button */
.sidebar-inner-toggle {
    position: absolute;
    top: 16px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: var(--card-hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
}

.sidebar-inner-toggle:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.sidebar-inner-toggle:hover i {
    color: white;
}

.sidebar-inner-toggle i {
    color: var(--secondary-text);
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
}

/* Show toggle button when sidebar is collapsed */
.chat-history-sidebar:not(.open) .sidebar-inner-toggle {
    display: flex;
    top: 80px;
    right: 14px;
}

@media (min-width: 1200px) {
    body.sidebar-closed .chat-history-sidebar .sidebar-inner-toggle {
        display: flex;
        top: 90px;
        right: 14px;
    }
}

/* New Chat Button adjustments for collapsed state */
.new-chat-section {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 20px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.2);
    white-space: nowrap;
}

.new-chat-btn:hover {
    transform: translateY(-1px);
    background: #1cfb62c9;
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.51);
}

.new-chat-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.2);
}

.new-chat-btn i {
    font-size: 20px;
}

.chat-history-sidebar:not(.open) .new-chat-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
}

.chat-history-sidebar:not(.open) .new-chat-btn .btn-text {
    display: none;
}

@media (min-width: 1200px) {
    body.sidebar-closed .chat-history-sidebar .new-chat-btn {
        width: 40px;
        height: 40px;
        padding: 0;
        border-radius: 50%;
    }
    
    body.sidebar-closed .chat-history-sidebar .new-chat-btn .btn-text {
        display: none;
    }
}

/* Chat History Toggle Button */
.chat-history-toggle {
    position: fixed;
    top: 90px;
    left: 12px;
    width: 32px;
    height: 32px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chat-history-toggle:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.chat-history-toggle:hover i {
    color: white;
}

.chat-history-toggle i {
    color: var(--secondary-text);
    font-size: 16px;
    transition: all 0.3s ease;
}

/* Rotate icon when sidebar is open */
.chat-history-sidebar.open ~ .chat-history-toggle i {
    transform: rotate(180deg);
}

@media (min-width: 1200px) {
    body:not(.sidebar-closed) .chat-history-toggle i {
        transform: rotate(180deg);
    }
}

/* Hide toggle button on mobile when sidebar is open */
@media (max-width: 768px) {
    .chat-history-sidebar.open ~ .chat-history-toggle {
        display: none;
    }
}

/* Layout - Main Content Container */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    margin-left: 60px; /* Space for collapsed sidebar */
    transition: margin-left 0.3s ease-in-out;
}

/* Sidebar açık olduğunda daha fazla margin */
.chat-history-sidebar.open ~ .main-content {
    margin-left: 320px;
}

@media (min-width: 1200px) {
    .main-content {
        margin-left: 320px; /* Büyük ekranlarda varsayılan olarak açık */
    }
    
    body.sidebar-closed .main-content {
        margin-left: 60px;
    }
}

@media (max-width: 768px) {
    .main-content {
        margin-left: 0; /* Mobilde sidebar üstte değil */
    }
    
    .chat-history-sidebar.open ~ .main-content {
        margin-left: 0;
    }
}

@media (min-width: 992px) {
    .main-content {
        flex-direction: row;
        gap: 0;
    }
}

/* Reading Section */
.reading-section {
    flex: 1;
    max-width: 100%;
    padding: 2rem;
    background: var(--bg-color);
    min-height: 100vh;
    overflow-y: auto;
}

@media (min-width: 992px) {
    .reading-section {
        max-width: calc(100% - 360px); /* Account for recommendations sidebar */
    }
}

@media (min-width: 1200px) {
    .reading-section {
        max-width: calc(100% - 400px);
        padding: 2rem 3rem;
    }
}

/* Reading content inner container for better readability */
.reading-header,
.reading-content {
    max-width: 900px;
    margin: 0 auto;
}

/* Reading Header */
.reading-header {
    margin-bottom: 3rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 2rem;
}

.reading-header-content {
    max-width: 100%;
}

.reading-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.reading-meta {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.reading-author {
    display: flex;
    align-items: center;
}

.author-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-color);
    transition: color 0.2s;
}

.author-link:hover {
    color: var(--primary-color);
}

.author-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
}

.author-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.author-avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

.author-name {
    font-weight: 500;
    color: var(--text-color);
}

.reading-date,
.reading-time {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* Reading Content */
.reading-content {
    position: relative;
}

.reading-featured-image {
    width: 100%;
    max-height: 500px;
    overflow: hidden;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.reading-featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.reading-body {
    color: var(--text-color);
    line-height: 1.8;
    font-size: 1.1rem;
}

.reading-introduction {
    margin-bottom: 2rem;
}

.reading-introduction .lead {
    font-size: 1.3rem;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.6;
}

.reading-main-content {
    margin-bottom: 3rem;
}

.reading-main-content h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.reading-main-content h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.8rem;
    color: var(--text-color);
}

.reading-main-content p {
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.reading-main-content ul,
.reading-main-content ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

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

.reading-main-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    color: var(--text-secondary);
}

.reading-main-content code {
    background: var(--hover-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.reading-main-content pre {
    background: var(--hover-bg);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.reading-main-content pre code {
    background: none;
    padding: 0;
}

/* Reading Progress Bar */
.reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--border-color);
    z-index: 1000;
}

.reading-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0;
    transition: width 0.1s ease;
}

/* Table of Contents */
.reading-toc {
    position: sticky;
    top: 80px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.reading-toc h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.reading-toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.reading-toc li {
    margin-bottom: 0.5rem;
}

.reading-toc a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
    display: block;
    padding: 0.3rem 0;
}

.reading-toc a:hover {
    color: var(--primary-color);
}

.reading-toc .toc-sub-item {
    padding-left: 1rem;
}

/* Related Topics */
.reading-related-topics {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.reading-related-topics h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.related-topics-tags {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.topic-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
}

.topic-tag:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

/* Reading Actions Footer */
.reading-actions-footer {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-top: 3rem;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.reading-action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.5rem;
    background: transparent;
    border: none;
    border-radius: 25px;
    color: var(--text-color);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.reading-action-btn:hover {
    background: var(--hover-bg);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.reading-action-btn.active {
    background: var(--primary-color);
    color: white;
}

.reading-action-btn.active:hover {
    background: var(--primary-hover);
}

.reading-action-btn i {
    font-size: 1.1rem;
}

/* Dark Theme Specific */
[data-theme="dark"] .reading-section {
    background: var(--bg-color);
}

[data-theme="dark"] .reading-title {
    color: #ffffff;
}

[data-theme="dark"] .reading-main-content h2,
[data-theme="dark"] .reading-main-content h3 {
    color: #ffffff;
}

[data-theme="dark"] .reading-main-content p {
    color: #e0e0e0;
}

[data-theme="dark"] .topic-tag {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .reading-actions-footer {
    background: rgba(30, 30, 30, 0.9);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .reading-toc {
    background: var(--card-bg);
    border-color: rgba(255, 255, 255, 0.1);
}

/* Responsive Design */
@media (max-width: 768px) {
    .reading-section {
        padding: 1rem;
    }
    
    .reading-title {
        font-size: 1.8rem;
    }
    
    .reading-meta {
        gap: 1rem;
    }
    
    .reading-body {
        font-size: 1rem;
    }
    
    .reading-main-content h2 {
        font-size: 1.5rem;
    }
    
    .reading-main-content h3 {
        font-size: 1.2rem;
    }
    
    .reading-actions-footer {
        flex-wrap: wrap;
        border-radius: 20px;
    }
    
    .reading-action-btn {
        flex: 1;
        min-width: calc(50% - 0.5rem);
        justify-content: center;
    }
    
    .reading-action-btn span {
        display: none;
    }
    
    .reading-action-btn i {
        font-size: 1.3rem;
    }
}

@media (max-width: 991px) {
    .recommendations-section {
        display: none; /* Hide sidebar on mobile */
    }
    
    .reading-section {
        max-width: 100% !important;
    }
}

@media (min-width: 992px) and (max-width: 1199px) {
    .reading-section {
        padding: 1.5rem;
    }
}

@media (min-width: 1200px) {
    .reading-section {
        max-width: calc(100% - 400px);
    }
}

/* Recommendations Section Styling for Reader Mode Page */
.recommendations-section {
    width: 100%;
    padding: 20px;
    background-color: var(--card-bg);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    transition: background-color 0.3s, border-color 0.3s;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@media (min-width: 992px) {
    .recommendations-section {
        width: 360px;
        max-width: 360px;
        min-width: 360px;
        height: 100vh;
        position: sticky;
        top: 0;
        border-left: 1px solid var(--border-color);
        border-top: none;
    }
}

@media (min-width: 1200px) {
    .recommendations-section {
        width: 400px;
        max-width: 400px;
        min-width: 400px;
    }
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Selection Color */
::selection {
    background: var(--primary-color);
    color: white;
}

::-moz-selection {
    background: var(--primary-color);
    color: white;
}
