:root {
    --turkish-red: #E30A17;
    --turkish-white: #FFFFFF;
    --app-bg: #d1d7db;
    --sidebar-bg: #FFFFFF;
    --chat-bg: #EFEAE2;
    /* Classic chat background color */
    --incoming-bg: #FFFFFF;
    --outgoing-bg: #FFE4E1;
    /* Slight red tint fitting theme */
    --text-primary: #111b21;
    --text-secondary: #667781;
    --border-color: #e9edef;
    --hover-bg: #f0f2f5;
    --system-font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--system-font);
    background-color: var(--app-bg);
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* App Layout */
#app {
    display: flex;
    height: 100vh;
    max-width: 100%;
    margin: 0;
    background: var(--turkish-white);
    box-shadow: none;
}

/* Sidebar */
#sidebar {
    width: 30%;
    max-width: 450px;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    background: var(--sidebar-bg);
}

.sidebar-header {
    padding: 10px 16px;
    background: var(--sidebar-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    height: 60px;
}

.user-avatar img,
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--turkish-red);
    /* Turkish touch */
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 50%;
    margin-left: 8px;
}

.icon-btn:hover {
    background: var(--hover-bg);
}

.search-bar {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.search-input-wrapper {
    background: var(--hover-bg);
    border-radius: 8px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
}

.search-icon {
    color: var(--text-secondary);
    margin-right: 8px;
    font-size: 14px;
}

#search-input {
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    font-size: 14px;
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    padding: 12px 16px;
    cursor: pointer;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.chat-item:hover {
    background: var(--hover-bg);
}

.chat-item.active {
    background: #fdf2f2;
    /* Very light red */
}

.chat-item-info {
    margin-left: 12px;
    flex: 1;
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.chat-item-name {
    font-weight: 500;
    font-size: 16px;
    color: var(--text-primary);
}

.chat-item-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.chat-item-preview {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chat Window */
#chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    position: relative;
}

/* Background Pattern Overlay */
#chat-window::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTAgMTBoODB2ODBIMTB6IiBmaWxsPSIjRjZGMkYwIiAvPjwvc3ZnPg==');
    /* Placeholder for pattern */
    opacity: 0.1;
    pointer-events: none;
    z-index: 0;
}

.chat-header {
    padding: 10px 16px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    z-index: 10;
}

.active-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    flex: 1;
}

.chat-info {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.chat-details {
    margin-left: 12px;
}

#chat-name {
    font-size: 16px;
    font-weight: 500;
}

#chat-status {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Messages Area */
.messages-area {
    flex: 1;
    padding: 20px 50px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 5;
}

.message {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 8px;
    position: relative;
    font-size: 14.2px;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    line-height: 1.4;
}

.message.incoming {
    align-self: flex-start;
    background: var(--incoming-bg);
    border-top-left-radius: 0;
}

.message.outgoing {
    align-self: flex-end;
    background: var(--outgoing-bg);
    border-top-right-radius: 0;
}

.message-meta {
    font-size: 11px;
    color: #999;
    float: right;
    margin-left: 8px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Input Area */
.chat-input-area {
    padding: 10px 16px;
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10;
}

#message-input {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background: var(--hover-bg);
    outline: none;
    font-size: 15px;
}

.send-btn {
    transform: rotate(0deg);
}

.hidden {
    display: none !important;
}

/* Welcome Screen */
.no-chat-selected {
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: var(--chat-bg);
    border-bottom: 6px solid var(--turkish-red);
}

.welcome-content h1 {
    color: #41525d;
    font-weight: 300;
    margin-bottom: 10px;
}

.encrypted-notice {
    margin-top: 40px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* System Message / Easter Egg */
.message.system {
    align-self: center;
    background: #FFF3CD;
    color: #856404;
    font-size: 13px;
    text-align: center;
    border-radius: 8px;
    box-shadow: none;
    border: 1px solid #ffeeba;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px !important;
    height: 6px !important;
}

::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
}

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: 70px;
    left: 20px;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    z-index: 20;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.emoji-grid span {
    font-size: 24px;
    cursor: pointer;
    text-align: center;
    padding: 4px;
}

.emoji-grid span:hover {
    background: var(--hover-bg);
    border-radius: 4px;
}

/* Call Overlay */
.call-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
}

.call-content {
    text-align: center;
}

.call-avatar-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
}

#call-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid var(--turkish-red);
}

.pulse-ring {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    border: 4px solid var(--turkish-red);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.call-actions {
    margin-top: 40px;
}

.call-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.end-call {
    background: #ff3b30;
    color: white;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 900;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal {
    background: white;
    width: 90%;
    max-width: 400px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.modal-header {
    background: var(--turkish-red);
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-modal {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
}

.modal-body {
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
}

/* Modal List Items */
.contact-item {
    display: flex;
    align-items: center;
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

.contact-item:hover {
    background: var(--hover-bg);
}

.contact-info {
    margin-left: 12px;
}

.contact-name {
    font-weight: 500;
}

.img-msg {
    max-width: 200px;
    border-radius: 8px;
    margin-top: 4px;
}