
:root {
    --bg-color: #1a1b26;
    --sidebar-bg: rgba(22, 22, 30, 0.95);
    --header-bg: #16161e;
    --chat-bg: #0f1115;
    
    --border-color: rgba(255, 255, 255, 0.08);
    
    --text-primary: #e9eaeb;
    --text-secondary: #8696a0;
    --text-highlight: #ffffff;
    
    --accent-color: #00a884;
    
    --bubble-them: #202c33;
    --bubble-me: #005c4b; 
    --bubble-text-me: #e9edef;
    
    --search-bg: #202c33;
    --hover-bg: rgba(255, 255, 255, 0.05);
    --active-chat-bg: #2a3942;
    
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
}

body { 
    margin: 0; 
    padding: 0; 
    font-family: var(--font-main); 
    height: 100vh; 
    overflow: hidden; 
    background-color: var(--bg-color); 
    color: var(--text-primary); 
    font-size: 14px;
}

.app-container { 
    display: flex; 
    width: 100%; 
    height: 100%; 
    position: relative;
}

.sidebar { 
    width: 320px; 
    min-width: 320px; 
    background-color: var(--sidebar-bg); 
    border-right: 1px solid var(--border-color); 
    display: flex; 
    flex-direction: column; 
    z-index: 10;
}

.sidebar-header { 
    height: 60px; 
    background: var(--header-bg); 
    display: flex; 
    align-items: center; 
    padding: 0 16px; 
    border-bottom: 1px solid var(--border-color); 
    font-weight: 700; 
    color: var(--text-highlight); 
    font-size: 16px;
    gap: 12px;
}

.search-container { 
    padding: 10px; 
    border-bottom: 1px solid var(--border-color);
}

.search-input { 
    width: 100%; 
    padding: 8px 12px 8px 36px; 
    background: var(--search-bg); 
    border: 1px solid transparent; 
    border-radius: 8px; 
    color: var(--text-highlight); 
    outline: none; 
    font-family: var(--font-main);
    font-size: 13px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238696a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 10px center;
}

.search-input:focus { 
    background: #2a3942; 
}

.chat-list { 
    overflow-y: auto; 
    flex: 1; 
}

.chat-item { 
    padding: 12px 16px; 
    display: flex; 
    align-items: center; 
    cursor: pointer; 
    border-bottom: 1px solid var(--border-color); 
    transition: background-color 0.2s, border-left 0.2s; 
    border-left: 3px solid transparent; 
}

.chat-item:hover { 
    background-color: var(--hover-bg); 
}

.chat-item.active { 
    background-color: var(--active-chat-bg); 
    border-left-color: var(--accent-color);
}

.chat-info { 
    flex: 1; 
    overflow: hidden; 
}

.chat-info h4 { 
    margin: 0 0 4px 0; 
    font-size: 15px; 
    color: var(--text-highlight); 
    font-weight: 500; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

.chat-info p { 
    margin: 0; 
    font-size: 13px; 
    color: var(--text-secondary); 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

.chat-area { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    background-color: var(--chat-bg); 
    position: relative; 
    min-width: 0; 
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23ffffff' fill-opacity='0.03' fill-rule='evenodd'/%3E%3C/svg%3E");
}

.chat-header { 
    height: 60px; 
    background: var(--header-bg); 
    display: flex; 
    align-items: center; 
    padding: 0 16px; 
    border-bottom: 1px solid var(--border-color); 
    justify-content: space-between; 
    z-index: 20; 
}

.chat-header-left { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    overflow: hidden; 
    flex: 1; 
}

.chat-title { 
    font-weight: 600; 
    font-size: 16px; 
    color: var(--text-highlight);
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

.back-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-highlight);
    padding: 8px;
    margin-left: -8px;
    cursor: pointer;
}

.chat-search-box { 
    padding: 6px 12px; 
    background: var(--search-bg); 
    border: 1px solid transparent; 
    color: var(--text-highlight); 
    border-radius: 8px; 
    outline: none; 
    font-size: 13px;
    width: 240px;
    transition: all 0.2s;
}

.chat-search-box:focus { 
    background: #2a3942; 
    border-color: var(--accent-color); 
}

.messages { 
    flex: 1; 
    overflow-y: auto; 
    padding: 20px 5%; 
    display: flex; 
    flex-direction: column; 
    gap: 2px; 
}

.date-divider { 
    align-self: center; 
    background: #182229; 
    color: var(--text-secondary); 
    padding: 6px 12px; 
    border-radius: 8px; 
    font-size: 11px; 
    margin: 16px 0; 
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.msg { 
    max-width: 65%; 
    padding: 6px 10px; 
    border-radius: 8px; 
    position: relative; 
    font-size: 14.2px; 
    line-height: 1.4; 
    word-wrap: break-word; 
    box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
    margin-bottom: 2px;
}

.msg-them { 
    align-self: flex-start; 
    background: var(--bubble-them); 
    color: var(--text-highlight);
    border-top-left-radius: 0; 
}

.msg-me { 
    align-self: flex-end; 
    background: var(--bubble-me); 
    color: var(--bubble-text-me);
    border-top-right-radius: 0; 
}

.sender-name { 
    font-size: 12px; 
    font-weight: 600; 
    margin-bottom: 2px; 
    display: block; 
    color: #d1d7db; 
}

.msg-meta { 
    display: block; 
    text-align: right; 
    font-size: 10px; 
    opacity: 0.6; 
    margin-top: 2px; 
    margin-bottom: -2px;
}

.highlight { 
    background-color: rgba(0, 168, 132, 0.4); 
    color: #fff; 
    padding: 0 2px; 
    border-radius: 2px; 
}

.flash-highlight {
    animation: flash 2s ease-out;
}

@keyframes flash {
    0% { background-color: rgba(255, 255, 0, 0.3); transform: scale(1.02); }
    50% { background-color: rgba(255, 255, 0, 0.3); transform: scale(1.02); }
    100% { background-color: var(--bubble-them); transform: scale(1); }
}

.msg-me.flash-highlight {
    animation-name: flash-me;
}

@keyframes flash-me {
    0% { background-color: rgba(255, 255, 0, 0.3); transform: scale(1.02); }
    50% { background-color: rgba(255, 255, 0, 0.3); transform: scale(1.02); }
    100% { background-color: var(--bubble-me); transform: scale(1); }
}

.search-result-item {
    cursor: pointer;
    transition: background 0.2s;
    border-left: 3px solid transparent;
}

.search-result-item:hover {
    background: var(--hover-bg);
    border-left-color: var(--accent-color);
}

.scroll-down-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: none; 
    align-items: center;
    justify-content: center;
    color: var(--accent-color);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 50;
    transition: transform 0.2s;
}

.scroll-down-btn:hover {
    transform: scale(1.1);
    background: var(--active-chat-bg);
}

.media-container { 
    margin: 4px 0; 
    border-radius: 6px; 
    overflow: hidden; 
    background: rgba(0,0,0,0.2); 
}

.media-container img, .media-container video { 
    max-width: 100%; 
    max-height: 350px; 
    display: block; 
}

.missing-file {
    padding: 15px;
    text-align: center;
    background: rgba(255,255,255,0.05);
    color: #8696a0;
    font-size: 11px;
    border-radius: 6px;
}

.media-drawer { 
    width: 340px; 
    min-width: 340px; 
    background: var(--sidebar-bg); 
    border-left: 1px solid var(--border-color); 
    display: flex; 
    flex-direction: column; 
    z-index: 25;
    height: 100%;
}

.drawer-header { 
    padding: 0 20px; 
    height: 60px;
    font-weight: 700; 
    border-bottom: 1px solid var(--border-color); 
    color: var(--text-highlight); 
    font-size: 16px;
    display: flex; 
    align-items: center; 
    justify-content: space-between;
    background: var(--header-bg);
}

.drawer-close-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
}

.drawer-tabs { 
    display: flex; 
    padding: 0; 
    border-bottom: 1px solid var(--border-color); 
    background: var(--header-bg);
}

.tab { 
    font-size: 13px; 
    padding: 12px 8px; 
    cursor: pointer; 
    background: transparent; 
    color: var(--text-secondary); 
    flex: 1; 
    text-align: center; 
    font-weight: 500;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.tab:hover { 
    background: var(--hover-bg); 
    color: var(--text-primary); 
}

.tab.active { 
    color: var(--accent-color); 
    border-bottom-color: var(--accent-color);
}

.drawer-content { 
    flex: 1; 
    overflow-y: auto; 
    padding: 4px; 
}

.media-grid { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 2px; 
    align-content: start;
}

.grid-item { 
    position: relative;
    width: 100%;
    padding-top: 100%; 
    background: var(--search-bg); 
    cursor: pointer; 
    z-index: 1;
}

.grid-item:hover {
    z-index: 10;
}

.grid-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; 
}

.grid-content img, .grid-content video { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    transition: transform 0.2s;
}

.grid-content:hover img, .grid-content:hover video {
    transform: scale(1.05);
}

.mini-play-btn {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 30px; height: 30px;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: background 0.2s;
    pointer-events: auto;
    z-index: 10;
}

.mini-play-btn:hover { 
    background: rgba(0,0,0,0.7); 
    transform: translate(-50%, -50%) scale(1.1); 
}

.item-menu-btn {
    position: absolute;
    top: 4px; right: 4px;
    width: 20px; height: 20px;
    background: rgba(0,0,0,0.6);
    border-radius: 50%;
    display: none; 
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    z-index: 20;
    border: none;
}

.grid-item:hover .item-menu-btn { 
    display: flex; 
}

.item-menu-btn:hover { 
    background: rgba(0,0,0,0.9); 
}

.ctx-menu {
    position: fixed; 
    background: #2a2c33;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    z-index: 9999; 
    width: 140px;
    padding: 4px 0;
    border: 1px solid var(--border-color);
}

.ctx-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    font-size: 13px;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
}

.ctx-menu-item:hover { 
    background: #3b3e4a; 
}

.doc-list { 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    padding: 12px; 
}

.doc-card {
    display: flex; 
    align-items: center; 
    padding: 12px; 
    background: var(--search-bg); 
    border-radius: 8px; 
    color: var(--text-primary); 
    text-decoration: none; 
    font-size: 13px;
    gap: 12px;
    border: 1px solid transparent;
}

.doc-card:hover { 
    background: #2a3942; 
    border-color: var(--border-color);
}

.doc-icon {
    width: 36px; 
    height: 36px; 
    background: #ff5252; 
    color: #fff; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border-radius: 6px; 
    font-size: 10px; 
    font-weight: bold; 
    text-transform: uppercase;
    flex-shrink: 0;
}

.icon-svg { 
    stroke: currentColor; 
    fill: none; 
    stroke-width: 2; 
    stroke-linecap: round; 
    stroke-linejoin: round; 
}

.icon-sm { 
    width: 20px; 
    height: 20px; 
}

.icon-md { 
    width: 24px; 
    height: 24px; 
}

.loading-indicator {
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
}

::-webkit-scrollbar { 
    width: 6px; 
}

::-webkit-scrollbar-track { 
    background: transparent; 
}

::-webkit-scrollbar-thumb { 
    background: #374045; border-radius: 3px; 
}

@media (max-width: 768px) {
    .sidebar { 
        width: 100%; 
    }
    
    .chat-area {
        position: fixed;
        top: 0; left: 0; width: 100%; height: 100%;
        z-index: 20;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    
    .chat-area.active { 
        transform: translateX(0); 
    }
    
    .back-btn { 
        display: block; 
    }
    
    .media-drawer {
        position: fixed;
        top: 0; right: 0; width: 100%; height: 100%;
        z-index: 30;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        display: flex !important; 
        width: 85%; 
        box-shadow: -10px 0 50px rgba(0,0,0,0.5);
    }
    
    .media-drawer.active { 
        transform: translateX(0);
    }

    .chat-header {
        padding: 0 10px;
    }
    .chat-search-box { 
        display: block !important; 
        width: 140px; 
        font-size: 12px;
        padding: 6px 10px;
    }
    .chat-search-box:focus {
        width: 160px;
    }

    .msg { 
        max-width: 85%; 
    }

    .drawer-toggle { 
        display: block !important; 
    }

    .drawer-close-btn { 
        display: block; 
    }
    
    .media-grid { 
        grid-template-columns: repeat(3, 1fr); 
    } 

    .item-menu-btn { 
        display: flex; 
        opacity: 0.8; 
    } 
    
    .scroll-down-btn { 
        bottom: 80px; 
        right: 20px; 
    }
}
