/* assets/style.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

.hidden {
    display: none !important;
}

:root {
    /* Light Theme (Default) */
    --primary: #0058be;
    --primary-container: #2170e4;
    --on-primary: #ffffff;
    --bg-color: #F5F7FA;
    --surface: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.75);
    --surface-container-low: #f1f3ff;
    --surface-container-high: #e1e8fd;
    --text-color: #141b2b;
    --text-variant: #424754;
    --outline: #727785;
    --outline-variant: rgba(194, 198, 216, 0.4);
    --tg-blue: #2481cc;
    --tg-bubble-out: #effdde;
    --tg-date: #8ea0b3;
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 18px;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);
}

html.dark {
    --primary: #adc6ff;
    --primary-container: #004395;
    --on-primary: #001a42;
    --bg-color: #0e1621;
    --surface: #17212b;
    --surface-glass: rgba(23, 33, 43, 0.8);
    --surface-container-low: #24303f;
    --surface-container-high: #2b394a;
    --text-color: #edf0ff;
    --text-variant: #b0b8c6;
    --outline: #8e95a5;
    --outline-variant: rgba(255, 255, 255, 0.1);
    --tg-blue: #2f6ea5;
    --tg-bubble-out: #2b5278;
    --tg-date: #7f91a4;
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.4);
}

html.peach {
    --primary: #e67e53;
    --primary-container: #ffdcc6;
    --on-primary: #311400;
    --bg-color: #FFF8F3;
    --surface: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.8);
    --surface-container-low: #fdf1e8;
    --surface-container-high: #fad8c5;
    --text-color: #4a3525;
    --text-variant: #7c685c;
    --outline: #b09c90;
    --outline-variant: rgba(245, 158, 123, 0.2);
    --tg-blue: #f59e7b;
    --tg-bubble-out: #fff0ea;
    --tg-date: #b89d8e;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Scrollbars */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}
html.dark .custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

/* Header */
header {
    height: 56px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--outline-variant);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 50;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Glassmorphism Header */
header.glass {
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.search-input-wrapper {
    position: relative;
    width: 240px;
}

.search-input-wrapper input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border-radius: 20px;
    border: 1px solid var(--outline-variant);
    background-color: var(--surface-container-low);
    color: var(--text-color);
    font-size: 13px;
    outline: none;
    transition: all 0.2s ease;
}

.search-input-wrapper input:focus {
    border-color: var(--primary);
    background-color: var(--surface);
    box-shadow: 0 0 0 2px rgba(33, 112, 228, 0.2);
}

.header-title-section {
    flex-grow: 1;
    margin-left: 20px;
}

/* Layout */
.app-container {
    display: flex;
    flex: 1;
    height: calc(100vh - 56px);
    overflow: hidden;
}

/* Sidebar */
aside.sidebar {
    width: 280px;
    background-color: var(--surface);
    border-right: 1px solid var(--outline-variant);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
    flex-shrink: 0;
}

aside.sidebar.collapsed {
    width: 72px;
}

.sidebar-items {
    flex: 1;
    overflow-y: auto;
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.02);
    transition: background-color 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.sidebar-item:hover {
    background-color: var(--surface-container-low);
}

.sidebar-item.active {
    background-color: var(--tg-blue);
    color: #ffffff;
}

.sidebar-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--surface-container-low);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.sidebar-item.active .sidebar-icon {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.sidebar-info {
    flex: 1;
    min-w: 0;
}

.sidebar-info .title-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-weight: 600;
    font-size: 14px;
}

.sidebar-info .subtitle {
    font-size: 12px;
    color: var(--text-variant);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-item.active .sidebar-info .subtitle {
    color: rgba(255, 255, 255, 0.8);
}

/* Collapsed Sidebar overrides */
aside.sidebar.collapsed .sidebar-info {
    display: none;
}
aside.sidebar.collapsed .sidebar-icon {
    margin-right: 0;
}
aside.sidebar.collapsed .sidebar-item {
    justify-content: center;
}

/* Timeline Stream */
main.timeline-stream {
    flex: 1;
    background-color: var(--bg-color);
    overflow-y: auto;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.timeline-content-wrapper {
    width: 100%;
    max-width: 680px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.date-divider {
    display: flex;
    justify-content: center;
    margin: 12px 0;
}

.date-badge {
    background-color: rgba(0, 0, 0, 0.08);
    color: var(--text-color);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}
html.dark .date-badge {
    background-color: rgba(255, 255, 255, 0.08);
}

/* Chat bubble card styles */
.knowledge-card {
    background-color: var(--surface);
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-xl);
    padding: 16px;
    position: relative;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    align-self: flex-start;
    width: 90%;
    max-width: 600px;
    resize: both;
    overflow: auto;
    min-width: 280px;
    min-height: 100px;
}

.knowledge-card:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(33, 112, 228, 0.4);
}

.knowledge-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary), var(--shadow-md);
}

.knowledge-card.pinned {
    background-color: var(--tg-bubble-out);
    border-color: rgba(36, 129, 204, 0.2);
}

.knowledge-card .tag-badge {
    background-color: rgba(33, 112, 228, 0.08);
    color: var(--primary);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
}

.knowledge-card.pinned .tag-badge {
    background-color: rgba(36, 129, 204, 0.15);
}

.knowledge-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.knowledge-card p {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-variant);
    margin-bottom: 8px;
}

.knowledge-card .code-preview-block {
    background-color: var(--surface-container-low);
    border-radius: var(--radius-md);
    padding: 12px;
    font-family: monospace;
    font-size: 12px;
    overflow-x: auto;
    margin-bottom: 8px;
}

.card-meta-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--tg-date);
}

/* Modal Popup Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.3s ease;
}

html.dark .modal-overlay {
    background-color: rgba(0, 0, 0, 0.6);
}

.modal-overlay.hidden {
    display: none !important;
}

/* Modal Content Box */
.modal-box {
    background-color: var(--surface);
    width: 90%;
    max-width: 620px;
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--outline-variant);
    position: relative;
    max-height: 85vh;
    overflow: auto;
    display: flex;
    flex-direction: column;
    resize: both;
    min-width: 350px;
    min-height: 300px;
}

/* Modal Box Maximized state */
.modal-box.maximized {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    top: 0 !important;
    left: 0 !important;
    margin: 0 !important;
    position: absolute !important;
    resize: none !important;
    z-index: 1001 !important;
}

/* Window Control Buttons */
.modal-control-btn {
    background: transparent;
    border: none;
    color: var(--text-variant);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
}

.modal-control-btn:hover {
    background-color: var(--surface-container-low);
    color: var(--text-color);
}

.modal-control-btn .material-symbols-outlined {
    font-size: 20px;
}

.modal-admin-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--outline-variant);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Copy & Selection Protection */
.no-select {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

/* Screenshot Deterrent (Blur on Focus Loss) */
.window-blur-active {
    filter: blur(25px) !important;
    pointer-events: none !important;
}

/* Print Protection */
@media print {
    body, html, .app-container, .modal-overlay, .modal-box, header, aside, main {
        display: none !important;
    }
}

.detail-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.detail-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: rgba(33, 112, 228, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.detail-tags-row {
    font-size: 13px;
    font-weight: 500;
    color: var(--tg-blue);
    text-align: center;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.detail-tags-row span {
    cursor: pointer;
}

.detail-tags-row span:hover {
    text-decoration: underline;
}

.info-item {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.info-item .material-symbols-outlined {
    color: var(--text-variant);
    font-size: 20px;
    margin-top: 2px;
}

.info-text-title {
    font-size: 11px;
    color: var(--text-variant);
    margin-top: 2px;
}

.info-text-val {
    font-size: 14px;
    word-break: break-word;
}

.btn-primary {
    background-color: var(--tg-blue);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md);
    padding: 8px 16px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: opacity 0.2s;
    font-size: 14px;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-icon {
    padding: 8px;
    border: 1px solid var(--outline-variant);
    background-color: var(--surface);
    color: var(--text-variant);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background-color: var(--surface-container-low);
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--tg-blue);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

.fab:hover {
    transform: scale(1.1);
}

.fab:active {
    transform: scale(0.95);
}

/* Toast */
.toast-notification {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--text-color);
    color: var(--bg-color);
    padding: 12px 24px;
    border-radius: 30px;
    box-shadow: var(--shadow-lg);
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Rich Text Content formatting in preview */
.rich-text-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-color);
}
.rich-text-content p {
    margin-bottom: 12px;
}
.rich-text-content a {
    color: var(--primary);
    text-decoration: underline;
}
.rich-text-content ul, .rich-text-content ol {
    margin-left: 20px;
    margin-bottom: 12px;
}
.rich-text-content li {
    margin-bottom: 4px;
}
.rich-text-content pre {
    background-color: var(--surface-container-low);
    padding: 12px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-family: monospace;
    font-size: 13px;
    margin-bottom: 12px;
}
.rich-text-content code {
    background-color: var(--surface-container-low);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 13px;
}
.rich-text-content blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 16px;
    font-style: italic;
    color: var(--text-variant);
    margin-bottom: 12px;
}
.rich-text-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
}
.rich-text-content th, .rich-text-content td {
    border: 1px solid var(--outline-variant);
    padding: 8px 12px;
    text-align: left;
}
.rich-text-content th {
    background-color: var(--surface-container-low);
}

@media (max-width: 768px) {
    aside.sidebar {
        position: fixed;
        left: 0;
        top: 56px;
        bottom: 0;
        z-index: 80;
        transform: translateX(-100%);
        width: 280px !important;
    }
    aside.sidebar.open {
        transform: translateX(0);
    }
    .search-input-wrapper {
        display: none;
    }
}

