:root {
    --bg-app: #111b21;
    --bg-panel: #202c33;
    --bg-chat: #0b141a;
    --msg-in: #202c33;
    --msg-out: #005c4b;
    --text-primary: #e9edef;
    --text-secondary: #8696a0;
    --text-link: #53bdeb;
    --border-color: #2a3942;
    --accent: #00a884;
    --accent-hover: #06cf9c;
    --system-msg: #182229;
    --system-msg-text: #8696a0;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: #0a1014;
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#app {
    width: 100vw;
    height: 100vh;
    display: flex;
    position: relative;
    background-color: var(--bg-app);
}

.view {
    display: none;
    width: 100%;
    height: 100%;
}

.view.active {
    display: flex;
}

/* Chat Layout */
.chat-layout {
    display: flex;
    width: 100%;
    height: 100%;
    max-width: 1600px;
    margin: 0 auto;
}

/* Sidebar */
.sidebar {
    width: 350px;
    background-color: var(--bg-app);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    height: 60px;
    background-color: var(--bg-panel);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-right: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.sidebar-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.setting-group {
    margin-bottom: 25px;
}

.setting-group label {
    display: block;
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 14px;
}

.setting-group select {
    width: 100%;
    padding: 12px;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    outline: none;
    font-size: 15px;
    font-family: inherit;
}

.setting-group select:focus, input[type="text"]:focus {
    border-color: var(--accent) !important;
}

.stat-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background-color: var(--bg-panel);
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}

.stat-label {
    color: var(--text-secondary);
}

.stat-value {
    font-weight: 600;
    color: var(--accent);
}

.btn-secondary {
    width: 100%;
    padding: 12px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-secondary:hover {
    background-color: var(--bg-panel);
}

/* Chat Main */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-chat);
    position: relative;
}

/* Add a subtle WhatsApp background pattern */
.chat-main::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('data:image/svg+xml;utf8,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h100v100H0z" fill="none"/><path d="M10 10c0-5.5 4.5-10 10-10s10 4.5 10 10c0 5.5-4.5 10-10 10S10 15.5 10 10zM80 80c0-5.5 4.5-10 10-10s10 4.5 10 10c0 5.5-4.5 10-10 10s-10-4.5-10-10z" fill="%23111b21" fill-opacity="0.4"/></svg>');
    opacity: 0.05;
    pointer-events: none;
    z-index: 0;
}

.chat-header {
    height: 60px;
    background-color: var(--bg-panel);
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 1;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #6a7175;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    overflow: hidden;
}

.chat-title {
    flex: 1;
    font-size: 16px;
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 20px;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
}

.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 5%;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

/* Scrollbar styles */
.chat-body::-webkit-scrollbar,
.sidebar-content::-webkit-scrollbar {
    width: 6px;
}
.chat-body::-webkit-scrollbar-thumb,
.sidebar-content::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* Messages */
.date-badge {
    align-self: center;
    background-color: var(--system-msg);
    color: var(--system-msg-text);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12.5px;
    margin: 15px 0;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    text-transform: uppercase;
}

.system-message {
    align-self: center;
    background-color: var(--system-msg);
    color: var(--system-msg-text);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12.5px;
    margin: 10px 0;
    text-align: center;
    max-width: 80%;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

.msg-row {
    display: flex;
    width: 100%;
    margin-bottom: 8px;
}

.msg-row.in {
    justify-content: flex-start;
}

.msg-row.out {
    justify-content: flex-end;
}

.msg-bubble {
    max-width: 65%;
    padding: 6px 7px 8px 9px;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
    display: flex;
    flex-direction: column;
}

.msg-row.in .msg-bubble {
    background-color: var(--msg-in);
    border-top-left-radius: 0;
}

.msg-row.out .msg-bubble {
    background-color: var(--msg-out);
    border-top-right-radius: 0;
}

.sender-name {
    font-size: 13px;
    font-weight: 500;
    color: #e57373;
    margin-bottom: 4px;
    padding-left: 2px;
}

.msg-row.out .sender-name {
    display: none;
}

.msg-text {
    font-size: 14.5px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
    padding-right: 60px;
    min-width: 80px;
}

.msg-text a {
    color: var(--text-link);
    text-decoration: none;
}
.msg-text a:hover {
    text-decoration: underline;
}

.msg-time {
    font-size: 11px;
    color: var(--text-secondary);
    position: absolute;
    bottom: 4px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.msg-row.out .msg-time {
    color: rgba(255,255,255,0.6);
}

/* Media styling inside bubbles */
.media-container {
    margin: 4px -2px 4px -2px;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    max-width: 320px;
}

.media-container img, 
.media-container video {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    display: block;
    cursor: pointer;
}

.media-container audio {
    width: 250px;
    height: 40px;
    outline: none;
    margin: 5px;
}

.media-omitted {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 13.5px;
    padding: 4px 0;
}

/* Chat Footer */
.chat-footer {
    height: 62px;
    background-color: var(--bg-panel);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    z-index: 1;
}

.chat-footer i {
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
}

.fake-input {
    flex: 1;
    background-color: var(--bg-chat);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text-secondary);
    font-size: 15px;
    cursor: text;
}

.mic-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#hamburger-menu, #close-sidebar {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    #hamburger-menu, #close-sidebar {
        display: block;
    }
    
    #close-sidebar {
        font-size: 20px;
        color: var(--text-secondary);
        cursor: pointer;
    }

    .chat-layout {
        flex-direction: row;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.5);
        border: none;
        flex: none;
        max-height: none;
    }

    .sidebar.open {
        left: 0;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        display: none;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .chat-main {
        flex: 1;
        width: 100%;
        height: 100vh;
    }
    
    .msg-bubble {
        max-width: 92%;
    }
    
    .chat-body {
        padding: 10px 4%;
    }

    .header-actions {
        gap: 12px;
    }

    #search-input {
        width: 100px !important;
    }

    .filter-btn {
        padding: 5px 12px;
        font-size: 11.5px;
    }

    .media-container img, 
    .media-container video {
        max-height: 200px;
    }

    .chat-footer {
        height: 55px;
        padding: 0 10px;
        gap: 10px;
    }

    .fake-input {
        padding: 10px 12px;
        font-size: 14px;
    }
}

/* Filter Bar */
.filter-bar {
    padding: 10px 20px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    gap: 10px;
    overflow-x: auto;
}

.filter-bar::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--text-primary);
    padding: 6px 15px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    transition: background 0.2s;
}

.filter-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.filter-btn.active {
    background: var(--msg-out);
    color: var(--text-primary);
}

/* Graphical Reports Styles */
.reports-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.reports-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.reports-header #btn-back-chat {
    width: auto;
    margin-right: 20px;
    margin-bottom: 0;
}

.reports-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.report-card {
    background-color: var(--bg-panel);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

.report-card.full-width {
    grid-column: 1 / -1;
}

.report-card h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 16px;
    color: var(--text-primary);
    text-align: center;
    font-weight: 500;
}

.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
}

@media (max-width: 768px) {
    .reports-grid {
        grid-template-columns: 1fr;
    }
    .report-card.full-width {
        grid-column: auto;
    }
    .report-card h3 {
        font-size: 14px;
        margin-bottom: 15px;
    }
    .reports-header h2 {
        font-size: 1.1rem;
    }
    .reports-header #btn-back-chat {
        font-size: 12px;
        padding: 8px 12px;
    }
}
