:root {
    --primary-bg: #1a1a1a;
    --secondary-bg: #2b2b2b;
    --tertiary-bg: #3c3c3c;
    --primary-text: #ffffff;
    --secondary-text: #aaaaaa;
    --accent-color: #3c3f42;
    --border-color: #4a4a4a;
}

body.theme-light {
    --primary-bg: #ffffff;
    --secondary-bg: #f5f5f5;
    --tertiary-bg: #e0e0e0;
    --primary-text: #121212;
    --secondary-text: #555555;
    --accent-color: #f8fcfc;
    --border-color: #dddddd;
}

/* Additional Themes */
body.theme-teal { --accent-color: #03A6A1; }
body.theme-blue { --accent-color: #3674B5; }

body.theme-cream {
    --primary-bg: #FFF2E0;
    --secondary-bg: #ffffff;
    --tertiary-bg: #F0E5D3;
    --primary-text: #4C3F35;
    --secondary-text: #79685C;
    --border-color: #E6D8C6;
    --accent-color: #D27D2D;
}

body.theme-lavender {
    --primary-bg: #f4f6fd;
    --secondary-bg: #ffffff;
    --tertiary-bg: #e8ebf5;
    --primary-text: #343a40;
    --secondary-text: #566473;
    --border-color: #C0C9EE;
    --accent-color: #5865f2;
}

body.theme-pink {
    --primary-bg: #FEF6FB;
    --secondary-bg: #FFFFFF;
    --tertiary-bg: #FEEBF6;
    --primary-text: #5D374E;
    --secondary-text: #8C657B;
    --border-color: #F5D9E9;
    --accent-color: #E54B9A;
}

body.theme-pastel-green {
    --accent-color: #9BC09C;
    --primary-bg: #f5f8f5;
    --secondary-bg: #ffffff;
    --primary-text: #3e4a3e;
    --secondary-text: #607160;
    --border-color: #e4e8e4;
}

body.theme-mint {
    --accent-color: #ADEED9;
    --primary-bg: #f0fcf9;
    --secondary-bg: #ffffff;
    --primary-text: #345049;
    --secondary-text: #5d7e75;
    --border-color: #e0f2ec;
}

body.theme-sage {
    --accent-color: #A7C1A8;
    --primary-bg: #f6f8f6;
    --secondary-bg: #ffffff;
    --primary-text: #414a41;
    --secondary-text: #677868;
    --border-color: #e6e9e6;
}

body.theme-orchid { --accent-color: #C562AF; }
body.theme-coral { --accent-color: #FF8282; }

body.theme-turquoise {
    --accent-color: #6DE1D2;
    --primary-bg: #f0fcfb;
    --secondary-bg: #ffffff;
    --primary-text: #2a4a45;
    --secondary-text: #5a7a75;
    --border-color: #d0e8e4;
    --tertiary-bg: #f0fcfb;
}

body.theme-sky-blue {
    --accent-color: #AFDDFF;
    --primary-bg: #f0f8ff;
    --secondary-bg: #ffffff;
    --primary-text: #2c4251;
    --secondary-text: #5c7281;
    --border-color: #d4e3f0;
    --tertiary-bg: #f0f8ff;
}

body, html {
    height: 100%;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--primary-bg);
    color: var(--primary-text);
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* --- Sidebar (Contact List) --- */
.sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    background-color: var(--secondary-bg);
    transition: width 0.3s ease, min-width 0.3s ease;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
}

.sidebar-header {
    padding: 10px;
    display: flex !important;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--secondary-bg);
    min-height: 50px;
    align-items: center;
}

.sidebar-header input {
    width: 100%;
    padding: 8px 12px;
    border-radius: 18px;
    border: none;
    background-color: var(--tertiary-bg);
    color: var(--primary-text);
    box-sizing: border-box;
}

.contact-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
    overflow-y: auto;
}

.contact {
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.contact:hover {
    background-color: var(--tertiary-bg);
}

.contact.active {
    background-color: var(--accent-color);
}

.contact img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 15px;
}

.contact-info {
    flex-grow: 1;
}

.contact-name {
    font-weight: 600;
}

.last-message {
    font-size: 0.9em;
    color: var(--secondary-text);
}

.message-status {
    text-align: right;
    font-size: 0.8em;
    color: var(--secondary-text);
}

.timestamp {
    margin-bottom: 4px;
}

.unread-count {
    background-color: var(--accent-color);
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 0.75em;
    font-weight: bold;
    display: inline-block;
}

.contact.active .last-message, .contact.active .message-status {
    color: #e0e0e0;
}

/* --- Chat Container --- */
.chat-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--primary-bg);
}

.chat-header {
    display: flex !important;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--secondary-bg);
    justify-content: space-between;
    min-height: 60px;
}

.chat-header img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 15px;
}

.chat-name {
    font-weight: 600;
}

.chat-status {
    font-size: 0.85em;
    color: var(--secondary-text);
}

.chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.message {
    max-width: 60%;
    padding: 10px 15px;
    border-radius: 18px;
    margin-bottom: 15px;
    position: relative;
}

.message .timestamp {
    font-size: 0.75em;
    color: var(--secondary-text);
    margin-top: 5px;
    text-align: right;
}

.message.received {
    background-color: var(--secondary-bg);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.sent {
    background-color: var(--accent-color);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-input {
    display: flex;
    padding: 15px;
    border-top: 1px solid var(--border-color);
    background-color: var(--secondary-bg);
}

.chat-input input {
    flex-grow: 1;
    padding: 10px 15px;
    border-radius: 20px;
    border: none;
    background-color: var(--tertiary-bg);
    color: var(--primary-text);
    margin-right: 10px;
}

.chat-input button {
    padding: 10px 20px;
    border: none;
    background-color: var(--accent-color);
    color: white;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
}

/* --- Profile Sidebar --- */
.profile-sidebar {
    width: 320px;
    border-left: 1px solid var(--border-color);
    background-color: var(--secondary-bg);
    padding: 20px;
    overflow-y: auto;
    transition: width 0.3s ease, min-width 0.3s ease, padding 0.3s ease;
    flex-shrink: 0;
}

.profile-sidebar.collapsed {
    width: 0;
    min-width: 0;
    padding: 0;
    border-left: none;
}

.profile-header {
    text-align: center;
    margin-bottom: 20px;
}

.profile-header img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin-bottom: 10px;
}

.profile-name {
    font-size: 1.2em;
    font-weight: 600;
}

.profile-username {
    color: var(--secondary-text);
}

.profile-details h4 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--accent-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

.profile-details p, .file-list {
    font-size: 0.9em;
    color: var(--secondary-text);
    list-style: none;
    padding: 0;
}

.file-list a {
    color: var(--primary-text);
    text-decoration: none;
    display: block;
    padding: 8px 0;
    border-bottom: 1px solid var(--tertiary-bg);
}

.file-list a:hover {
    color: var(--accent-color);
}

/* Theme Selector UI */
.theme-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.theme-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--border-color);
    transition: all 0.2s ease;
}

.theme-dot:hover {
    transform: scale(1.1);
}

.theme-dot.active {
    border-color: var(--accent-color);
    transform: scale(1.15);
    box-shadow: 0 0 8px -2px var(--accent-color);
}

/* --- Responsive Design --- */

/* Tablet */
@media (max-width: 1024px) {
    .profile-sidebar {
        display: none; /* Hide profile on tablets */
    }
    .sidebar {
        width: 280px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .app-container {
        position: relative;
        overflow-x: hidden;
    }

    .sidebar {
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        z-index: 10;
        transform: translateX(0);
        transition: transform 0.3s ease-in-out;
    }

    .chat-container {
        width: 100%;
    }

    /* State for when a chat is selected on mobile */
    .app-container.chat-active .sidebar {
        transform: translateX(-100%);
    }

    .chat-header {
        position: relative;
        padding: 10px 15px;
        display: flex !important;
        align-items: center;
        background-color: var(--secondary-bg);
        border-bottom: 1px solid var(--border-color);
        min-height: 60px;
    }

    .sidebar-header {
        display: flex !important;
        padding: 10px;
        border-bottom: 1px solid var(--border-color);
        background-color: var(--secondary-bg);
    }

    #toggle-left-sidebar {
        display: block;
        margin-right: 10px;
    }
}

#toggle-left-sidebar {
    display: block;
}

@media (min-width: 769px) {
    .sidebar-header,
    .chat-header {
        display: flex !important;
    }
}

/* Force visibility for mobile browsers that might hide these elements */
.sidebar-header,
.chat-header {
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    overflow: visible !important;
}

/* Additional mobile browser compatibility */
@media screen and (max-width: 768px) {
    .sidebar-header {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        will-change: transform;
    }
    
    .chat-header {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        will-change: transform;
    }
}

.icon-button {
    background: none;
    border: none;
    color: var(--secondary-text);
    font-size: 1.3em;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s ease;
}

.icon-button:hover {
    color: var(--accent-color);
}

a.contact-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 15px;
    box-sizing: border-box;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--tertiary-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2em;
    color: var(--secondary-text);
    flex-shrink: 0;
}

.avatar.large {
    width: 80px;
    height: 80px;
    font-size: 3em;
}

.contact .avatar, .chat-header .avatar, .user-info .avatar {
    margin-right: 15px;
}

.profile-header .avatar {
    margin: 0 auto 10px auto;
} 