:root {
    /* Light mode (default) - WhatsApp colors */
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f2f5;
    --bg-message-incoming: #ffffff;
    --bg-message-outgoing: #d9fdd3;
    --bg-header: #f0f2f5;
    --bg-chat-list: #ffffff;
    --bg-composer: #f0f2f5;
    --text-primary: #111b21;
    --text-secondary: #667781;
    --border-color: #e4e6eb;
    --border-dark: #d1d9de;
    --shadow: rgba(0, 0, 0, 0.1);
    --hover-bg: #f5f6f6;
    --active-bg: #e9edef;
    --button-primary: #00a884;
    --button-secondary: #008069;
}

body.dark-mode {
    /* Dark mode - WhatsApp colors */
    --bg-primary: #0b141a;
    --bg-secondary: #111b21;
    --bg-tertiary: #202c33;
    --bg-message-incoming: #202c33;
    --bg-message-outgoing: #005c4b;
    --bg-header: #202c33;
    --bg-chat-list: #111b21;
    --bg-composer: #202c33;
    --text-primary: #e9edef;
    --text-secondary: #8696a0;
    --border-color: #2a3942;
    --border-dark: #1f2c34;
    --shadow: rgba(0, 0, 0, 0.3);
    --hover-bg: #202c33;
    --active-bg: #2a3942;
    --button-primary: #00a884;
    --button-secondary: #008069;
}

html, body {
    height: 100%;
    overflow: hidden;
}

/* Allow scrolling on admin page */
html.admin-page {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: auto !important;
}

body.admin-page {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: auto !important;
    min-height: 100vh;
    position: relative;
}

body.admin-page #app {
    height: auto !important;
    min-height: 100vh;
    overflow: visible !important;
    position: relative;
}

body.admin-page .admin-main {
    overflow: visible !important;
}

body {
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.login-container {
    display: flex;
    height: 100vh;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--bg-secondary);
    padding: 32px;
    border-radius: 14px;
    box-shadow: 0 10px 30px var(--shadow);
    width: 320px;
}

.login-card h1 {
    margin-top: 0;
}

.login-card input {
    width: 100%;
    margin: 8px 0 16px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.login-card button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: var(--button-primary);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.login-card button:hover {
    background: var(--button-secondary);
}

.error {
    color: #dc2626;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--bg-header);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.brand {
    font-weight: 600;
    letter-spacing: 0.2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.app-header .actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-header input {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    width: 260px;
}

.app-header input::placeholder {
    color: var(--text-secondary);
}

.app-header button {
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.app-header button:hover {
    background: var(--hover-bg);
}

.header-link {
    color: var(--text-primary);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
    font-size: 14px;
}

.header-link:hover {
    background: var(--hover-bg);
    text-decoration: none;
}

.header-link.icon-link {
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.header-link.icon-link svg {
    width: 20px;
    height: 20px;
}

.theme-toggle {
    background: transparent !important;
    border: 1px solid var(--border-color) !important;
    padding: 6px 10px !important;
    font-size: 18px;
}

.app-main {
    display: grid;
    grid-template-columns: 360px 1fr;
    height: 100vh;
    overflow: hidden;
}

.chat-list {
    background: var(--bg-chat-list);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-list-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-header);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-list-row {
    display: flex;
    align-items: center;
}

.chat-list-row-1 {
    justify-content: space-between;
}

.chat-list-row-1 .brand-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.chat-list-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-list-tabs {
    display: flex;
    gap: 0;
    width: 100%;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 2px;
}

.chat-tab {
    flex: 1;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    opacity: 0.7;
}

.chat-tab:hover {
    color: var(--text-primary);
    opacity: 0.9;
}

.chat-tab.active {
    background: var(--button-primary);
    color: #ffffff;
    font-weight: 600;
    opacity: 1;
    box-shadow: 0 2px 4px rgba(0, 168, 132, 0.3);
}

body.dark-mode .chat-tab.active {
    background: var(--button-primary);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 168, 132, 0.4);
}

.chat-list-row-3 {
    width: 100%;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.chat-list-header input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    padding-right: 40px; /* Make room for cancel button */
    color: var(--text-primary);
    font-size: 14px;
}

.chat-list-header input::placeholder {
    color: var(--text-secondary);
}

.chat-list-header input:focus {
    outline: none;
    border-color: var(--button-primary);
}

.search-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    padding: 0;
    transition: all 0.15s ease;
    z-index: 10;
}

.search-clear-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.search-clear-btn:active {
    transform: translateY(-50%) scale(0.9);
}

.search-clear-btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
}

.chat-list-buttons .header-link,
.chat-list-buttons .theme-toggle,
.chat-list-buttons #logoutBtn,
.chat-list-buttons #newChatBtn {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
}

.chat-list-buttons .header-link:hover,
.chat-list-buttons .theme-toggle:hover,
.chat-list-buttons #logoutBtn:hover {
    background: var(--hover-bg);
    transform: scale(1.05);
}

.chat-list-buttons .header-link:active,
.chat-list-buttons .theme-toggle:active,
.chat-list-buttons #logoutBtn:active {
    transform: scale(0.95);
}

.chat-list-buttons .header-link svg,
.chat-list-buttons #logoutBtn svg {
    width: 20px;
    height: 20px;
}

.chat-list-buttons .theme-toggle {
    background: var(--bg-tertiary) !important;
    border: none !important;
}

.chat-context-menu {
    position: fixed;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 200px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-context-menu .context-menu-item {
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.15s ease;
    width: 100%;
    border-radius: 0;
}

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

.chat-context-menu .context-menu-item:active {
    background: var(--bg-tertiary);
}

.chat-item {
    padding: 0;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.15s ease;
    color: var(--text-primary);
    position: relative;
}

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

.chat-item.active {
    background: var(--active-bg);
    border-left: 3px solid var(--button-primary);
}

#chatItems {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.chat-list-loader {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
}

.loader-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--button-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 8px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loader-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Empty state for chat list */
.chat-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.chat-list-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.chat-list-empty-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.chat-list-empty-hint {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Slim scrollbar for chat list */
#chatItems::-webkit-scrollbar {
    width: 6px;
}

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

#chatItems::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

#chatItems::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

body.dark-mode #chatItems::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

body.dark-mode #chatItems::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Firefox scrollbar */
#chatItems {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

body.dark-mode #chatItems {
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.chat-item-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    position: relative;
    z-index: 0;
}

.chat-item-avatar {
    width: 49px;
    height: 49px;
    border-radius: 50%;
    background: var(--button-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

.chat-item-details {
    flex: 1;
    min-width: 0;
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chat-item-name {
    font-weight: 500;
    font-size: 17px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-item-time {
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
    margin-left: 8px;
}

.chat-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.chat-item-preview {
    font-size: 14px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.unread-badge {
    background: var(--button-primary);
    color: #fff;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.chat-view {
    display: flex;
    flex-direction: row;
    height: 100%;
    background: var(--bg-primary);
    overflow: hidden;
    position: relative;
}

.chat-view-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.scroll-to-bottom-btn {
    position: absolute;
    right: 18px;
    bottom: 92px; /* above composer */
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.92);
    color: #54656f;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2000;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease, background-color 0.15s ease;
}

.scroll-to-bottom-btn.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.scroll-to-bottom-btn:hover {
    background: rgba(255, 255, 255, 1);
}

.scroll-to-bottom-btn:active {
    transform: translateY(0) scale(0.98);
}

body.dark-mode .scroll-to-bottom-btn {
    background: rgba(42, 57, 66, 0.92);
    color: #e9edef;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.22);
}

body.dark-mode .scroll-to-bottom-btn:hover {
    background: rgba(42, 57, 66, 1);
}

.no-chat-selected {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
    background-color: #efeae2;
    background-image: 
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d1d9de' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    background-size: 60px 60px;
    background-position: 0 0;
}

body.dark-mode .no-chat-selected {
    background-color: #0b141a;
    background-image: 
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    background-size: 60px 60px;
    background-position: 0 0;
}

.no-chat-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.no-chat-text {
    font-size: 16px;
    color: var(--text-secondary);
}

.chat-header {
    padding: 10px 14px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.chat-title {
    color: var(--text-primary);
    font-weight: 500;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
}

.chat-actions button {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-actions button svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.chat-actions button:hover:not(:disabled) {
    background: var(--hover-bg);
}

.chat-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Contact Info Section */
.contact-info-section {
    width: 0;
    max-width: 90vw;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease-out;
    overflow: hidden;
    flex-shrink: 0;
}

.contact-info-section.open {
    width: 380px;
}

.contact-info-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
    gap: 12px;
    overflow: visible;
    position: relative;
}

.contact-info-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
    min-width: 24px;
    width: 24px;
    height: 24px;
    position: relative;
    z-index: 1;
}

.contact-info-close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.contact-info-close svg {
    width: 18px;
    height: 18px;
}

.contact-info-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.contact-info-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contact-info-title svg {
    width: 18px;
    height: 18px;
    color: var(--button-primary);
}

.contact-info-content {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
}

.contact-info-details h4,
.contact-info-packages h4 {
    margin: 0 0 12px 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.contact-info-packages-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 8px;
    min-width: 0;
}

.contact-info-packages-header h4 {
    margin: 0;
    flex-shrink: 0;
}

.contact-info-packages-link {
    display: flex;
    align-items: center;
    color: var(--button-primary);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.contact-info-packages-link:hover {
    background: var(--hover-bg);
}

.contact-info-packages-link svg {
    width: 14px;
    height: 14px;
}

.contact-info-card {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 20px;
}

.contact-info-row {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.contact-info-row:last-child {
    border-bottom: none;
}

.contact-info-label {
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 80px;
    font-size: 13px;
}

.contact-info-phone {
    color: var(--button-primary);
    text-decoration: none;
    font-size: 13px;
    transition: opacity 0.2s ease;
}

.contact-info-phone:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.contact-info-row span:not(.contact-info-label) {
    color: var(--text-primary);
    font-size: 13px;
}

.contact-info-packages-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.contact-info-package-item {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.contact-info-package-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13px;
}

.contact-info-package-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.contact-info-package-status.expired {
    color: #ef4444;
}

.contact-info-package-status.active {
    color: var(--button-primary);
}

.message-list {
    flex: 1;
    min-height: 0;
    padding: 20px 16px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    background-color: #efeae2;
    background-image: 
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d1d9de' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    background-size: 60px 60px;
    background-position: 0 0;
    transition: all 0.2s ease;
}

/* Drag and drop visual feedback for message list - WhatsApp style */
.message-list.drag-over {
    background-color: #e6ffe6 !important;
    border: 2px dashed #00a884 !important;
    border-radius: 0;
    box-shadow: none;
    position: relative;
}

.message-list.drag-over::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e6ffe6;
    border: 2px dashed #00a884;
    z-index: 9999;
    pointer-events: none;
}

.message-list.drag-over::before {
    content: 'Dosyayı buraya sürükleyin';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    color: #00a884;
    font-weight: 500;
    font-size: 18px;
    z-index: 10000;
    white-space: nowrap;
}

body.dark-mode .message-list.drag-over {
    background-color: rgba(0, 168, 132, 0.15) !important;
}

body.dark-mode .message-list.drag-over::after {
    background-color: rgba(0, 168, 132, 0.15);
    border-color: #00a884;
}

body.dark-mode .message-list.drag-over::before {
    color: #00a884;
}

body.dark-mode .message-list {
    background-color: #0b141a;
    background-image: 
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    background-size: 60px 60px;
    background-position: 0 0;
}

.message {
    margin-bottom: 12px;
    max-width: 70%;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-start;
}

.message.incoming {
    justify-content: flex-start;
}

.message.outgoing {
    margin-left: auto;
    justify-content: flex-end;
}

.message-content {
    position: relative;
    max-width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding-bottom: 12px;
}

.message-body {
    padding: 8px 12px;
    border-radius: 7.5px;
    line-height: 1.4;
    color: var(--text-primary);
    box-shadow: 0 1px 0.5px var(--shadow);
    word-wrap: break-word;
    flex: 0 1 auto;
}

.message.incoming .message-body {
    background: var(--bg-message-incoming);
    border-top-left-radius: 0;
}

.message.outgoing .message-body {
    background: var(--bg-message-outgoing);
    border-top-right-radius: 0;
}

.message-reaction-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #ffffff;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: opacity 0.15s ease, visibility 0.15s ease;
    padding: 0;
    /* Ensure button is always clickable and doesn't get clipped */
    pointer-events: auto;
    /* Use visibility instead of display to prevent layout shift */
    visibility: hidden;
    opacity: 0;
}

.message-reaction-btn::before {
    content: '';
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%234a5568'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-3.5-9c.83 0 1.5-.67 1.5-1.5S9.33 8 8.5 8 7 8.67 7 9.5 7.67 11 8.5 11zm7 0c.83 0 1.5-.67 1.5-1.5S16.33 8 15.5 8 14 8.67 14 9.5s.67 1.5 1.5 1.5zm-3.5 6.5c2.33 0 4.31-1.46 5.11-3.5H6.89c.8 2.04 2.78 3.5 5.11 3.5z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    display: block;
}

.message.incoming .message-reaction-btn {
    right: -36px;
}

.message-cancel-btn {
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 14px;
    background: #dc3545;
    color: #ffffff;
    border: none;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    z-index: 20;
    box-shadow: 0 2px 6px rgba(220, 53, 69, 0.3);
    transition: all 0.15s ease;
    white-space: nowrap;
}

.message-cancel-btn:hover {
    background: #c82333;
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 3px 8px rgba(220, 53, 69, 0.4);
}

.message-cancel-btn:active {
    background: #bd2130;
    transform: translateX(-50%) scale(0.95);
}

.message.pending-message {
    opacity: 0.85;
}

.message.pending-message .message-body {
    border: 1px dashed rgba(0, 0, 0, 0.2);
}

body.dark-mode .message.pending-message .message-body {
    border: 1px dashed rgba(255, 255, 255, 0.2);
}

.message.search-highlight {
    animation: searchHighlight 2s ease-out;
}

@keyframes searchHighlight {
    0% {
        background-color: rgba(255, 255, 0, 0.3);
        transform: scale(1.02);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

body.dark-mode .message.search-highlight {
    animation: searchHighlightDark 2s ease-out;
}

@keyframes searchHighlightDark {
    0% {
        background-color: rgba(255, 255, 0, 0.2);
        transform: scale(1.02);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

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

@keyframes messageHighlight {
    0% {
        background-color: rgba(0, 168, 132, 0.2);
        transform: scale(1.01);
    }
    50% {
        background-color: rgba(0, 168, 132, 0.15);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

body.dark-mode .message-highlight {
    animation: messageHighlightDark 2s ease-out;
}

@keyframes messageHighlightDark {
    0% {
        background-color: rgba(0, 168, 132, 0.3);
        transform: scale(1.01);
    }
    50% {
        background-color: rgba(0, 168, 132, 0.2);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

.message.outgoing .message-reaction-btn {
    left: -36px;
}

/* Show button when hovering over message OR the button itself */
.message:hover .message-reaction-btn,
.message-reaction-btn:hover {
    display: flex;
    visibility: visible;
    opacity: 1;
}

/* Keep button visible when it's active (picker is open) */
.message-reaction-btn.active {
    display: flex;
    visibility: visible;
    opacity: 1;
}

.message-reaction-btn:hover {
    background: #f5f5f5;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.08);
    transform: translateY(-50%) scale(1.05);
}

body.dark-mode .message-reaction-btn {
    background: #2a3942;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.1);
}

body.dark-mode .message-reaction-btn::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23e9edef'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-3.5-9c.83 0 1.5-.67 1.5-1.5S9.33 8 8.5 8 7 8.67 7 9.5 7.67 11 8.5 11zm7 0c.83 0 1.5-.67 1.5-1.5S16.33 8 15.5 8 14 8.67 14 9.5s.67 1.5 1.5 1.5zm-3.5 6.5c2.33 0 4.31-1.46 5.11-3.5H6.89c.8 2.04 2.78 3.5 5.11 3.5z'/%3E%3C/svg%3E");
}

body.dark-mode .message-reaction-btn:hover {
    background: #202c33;
}

.admin-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 8px;
  margin-left: -4px;
  vertical-align: middle;
  line-height: 1.4;
  flex-shrink: 0;
  align-self: flex-end;
}

/* Light mode - outgoing messages (green background) */
.message.outgoing .admin-badge {
  background: rgba(0, 0, 0, 0.15);
  color: #1f4e3d;
  font-weight: 700;
}

/* Dark mode - outgoing messages (dark green background) */
body.dark-mode .message.outgoing .admin-badge {
  background: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.95);
  font-weight: 700;
}

/* Message metadata container (admin badge + status + timestamp) */
.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  min-height: 15px;
}

/* Message timestamp */
.message-timestamp {
  font-size: 11px;
  color: rgba(0, 0, 0, 0.45);
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}

body.dark-mode .message-timestamp {
  color: rgba(255, 255, 255, 0.5);
}

/* Incoming messages - timestamp alignment */
.message.incoming .message-meta {
  justify-content: flex-start;
}

/* Day separator */
.day-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 16px 0;
  position: relative;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0 12px;
  background: transparent;
  z-index: 1;
}

.day-separator::before,
.day-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.day-separator::before {
  margin-right: 12px;
}

.day-separator::after {
  margin-left: 12px;
}

/* Message status indicators */
.message-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.message-status svg {
  display: block;
}

/* Pending/sending - grey clock */
.message-status.status-pending {
  color: rgba(0, 0, 0, 0.45);
}

body.dark-mode .message-status.status-pending {
  color: rgba(255, 255, 255, 0.5);
}

/* Sent - single grey tick */
.message-status.status-sent {
  color: rgba(0, 0, 0, 0.45);
}

body.dark-mode .message-status.status-sent {
  color: rgba(255, 255, 255, 0.5);
}

/* Delivered - double grey ticks */
.message-status.status-delivered {
  color: rgba(0, 0, 0, 0.45);
}

body.dark-mode .message-status.status-delivered {
  color: rgba(255, 255, 255, 0.5);
}

/* Read - double blue ticks */
.message-status.status-read {
  color: #53bdeb;
}

body.dark-mode .message-status.status-read {
  color: #53bdeb;
}

/* Failed - red icon */
.message-status.status-failed {
  color: #f15c6d;
}

body.dark-mode .message-status.status-failed {
  color: #f15c6d;
}

.message-reactions {
    position: absolute;
    bottom: -8px;
    left: 8px;
    width: 20px;
    height: 20px;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    z-index: 2;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

body.dark-mode .message-reactions {
    background: #2a3942;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.message-attachment {
    margin-top: 4px;
}

.message-attachment.message-attachment-image {
    position: relative;
    display: inline-block;
    max-width: 200px;
}

.message-attachment.message-attachment-image .attachment-open-new-tab {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 5;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    border-radius: 999px;
    text-decoration: none;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.message-attachment.message-attachment-image:hover .attachment-open-new-tab,
.message-attachment.message-attachment-image .attachment-open-new-tab:focus {
    opacity: 1;
    pointer-events: auto;
}

.message-attachment.message-attachment-image .attachment-open-new-tab:hover {
    background: rgba(0, 0, 0, 0.7);
    text-decoration: none;
}

body.dark-mode .message-attachment.message-attachment-image .attachment-open-new-tab {
    background: rgba(0, 0, 0, 0.6);
}

.message-attachment:first-child {
    margin-top: 0;
}

.attachment-loading {
    padding: 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
    font-style: italic;
}

body.dark-mode .attachment-loading {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

.message-attachment a {
    color: #e9edef;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    word-break: break-all;
}

.message-attachment a:hover {
    text-decoration: underline;
    background: rgba(0, 0, 0, 0.15);
}

/* Light mode file attachment */
.message.incoming .message-attachment a {
    color: #111b21;
    background: rgba(0, 0, 0, 0.05);
}

.message.incoming .message-attachment a:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Dark mode file attachment */
body.dark-mode .message-attachment a {
    color: #e9edef;
    background: rgba(255, 255, 255, 0.1);
}

body.dark-mode .message-attachment a:hover {
    background: rgba(255, 255, 255, 0.15);
}

body.dark-mode .message.incoming .message-attachment a {
    color: #e9edef;
    background: rgba(255, 255, 255, 0.1);
}

.message-text {
    margin: 0;
    word-wrap: break-word;
    line-height: 1.4;
}

.message-text br {
    line-height: 1.4;
    margin: 0;
    padding: 0;
}

/* Quoted message in chat bubble */
.message-quoted {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    user-select: none;
}

/* Light mode - outgoing messages: darker background for better contrast */
.message.outgoing .message-quoted {
    background: rgba(0, 0, 0, 0.08);
}

/* Dark mode - outgoing messages: lighter background */
body.dark-mode .message.outgoing .message-quoted {
    background: rgba(255, 255, 255, 0.15);
}

.message.incoming .message-quoted {
    background: rgba(0, 0, 0, 0.05);
}

body.dark-mode .message.incoming .message-quoted {
    background: rgba(255, 255, 255, 0.08);
}

.message-quoted:hover {
    background: rgba(0, 0, 0, 0.1);
}

.message.outgoing .message-quoted:hover {
    background: rgba(0, 0, 0, 0.12);
}

body.dark-mode .message.outgoing .message-quoted:hover {
    background: rgba(255, 255, 255, 0.25);
}

body.dark-mode .message.incoming .message-quoted:hover {
    background: rgba(255, 255, 255, 0.12);
}

.message-quoted-line {
    width: 3px;
    background: #00a884;
    border-radius: 2px;
    flex-shrink: 0;
    align-self: stretch;
}

.message.outgoing .message-quoted-line {
    background: #25d366;
}

body.dark-mode .message.outgoing .message-quoted-line {
    background: rgba(255, 255, 255, 0.5);
}

.message-quoted-content {
    flex: 1;
    min-width: 0;
}

.message-quoted-author {
    font-size: 12px;
    font-weight: 600;
    color: #00a884;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Light mode - outgoing: use darker green for better contrast */
.message.outgoing .message-quoted-author {
    color: #25d366;
}

/* Dark mode - outgoing: use white */
body.dark-mode .message.outgoing .message-quoted-author {
    color: rgba(255, 255, 255, 0.9);
}

.message-quoted-text {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    line-height: 1.3;
}

/* Light mode - incoming: use darker text for better contrast */
.message.incoming .message-quoted-text {
    color: #54656f;
}

/* Light mode - outgoing: use darker text for better contrast on light green */
.message.outgoing .message-quoted-text {
    color: #1f7a5c;
}

/* Dark mode - incoming: use lighter text */
body.dark-mode .message.incoming .message-quoted-text {
    color: rgba(255, 255, 255, 0.7);
}

/* Dark mode - outgoing: use white */
body.dark-mode .message.outgoing .message-quoted-text {
    color: rgba(255, 255, 255, 0.8);
}

.reaction-picker {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 4px;
    display: flex;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    animation: reactionPickerFadeIn 0.15s ease-out;
}

@keyframes reactionPickerFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.reaction-picker-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
}

.reaction-picker-btn:hover {
    transform: scale(1.3);
    background: var(--hover-bg);
}

/* Emoji Picker */
.emoji-picker {
    position: fixed;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    min-width: 280px;
    animation: emojiPickerFadeIn 0.2s ease-out;
}

body.dark-mode .emoji-picker {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

@keyframes emojiPickerFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.emoji-picker-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    padding: 0;
    line-height: 1;
}

.emoji-picker-btn:hover {
    background: var(--hover-bg);
    transform: scale(1.1);
}

.emoji-picker-btn:active {
    transform: scale(0.95);
}

/* Quick Replies Popup */
.quick-replies-popup {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    margin-bottom: 8px;
    animation: slideUp 0.2s ease-out;
    max-width: 100%;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.quick-replies-list {
    display: flex;
    flex-direction: column;
}

.quick-reply-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.15s ease;
}

.quick-reply-item:last-child {
    border-bottom: none;
}

.quick-reply-item:hover,
.quick-reply-item.highlighted {
    background: var(--hover-bg);
}

.quick-reply-keyword {
    font-weight: 600;
    color: var(--button-primary);
    font-size: 14px;
    margin-bottom: 4px;
}

.quick-reply-message {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    white-space: pre-wrap;
}

/* Formatting Popup - WhatsApp Style */
.formatting-popup {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: #f5f5f5 !important;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15), 0 0 2px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    margin-bottom: 8px;
    display: flex;
    gap: 6px;
    padding: 6px;
    animation: slideUp 0.2s ease-out;
}

body.dark-mode .formatting-popup {
    background: #2a2a2a;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4), 0 0 2px rgba(0, 0, 0, 0.3);
}

.format-btn {
    background: #3a3a3a !important;
    border: none !important;
    border-radius: 4px !important;
    padding: 0 !important;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: #b0b0b0 !important;
    transition: background-color 0.15s ease;
    width: 32px;
    height: 32px;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    line-height: 1;
}

body.dark-mode .format-btn {
    background: #3a3a3a !important;
    color: #b0b0b0 !important;
}

.format-btn:hover {
    background: #4a4a4a !important;
}

body.dark-mode .format-btn:hover {
    background: #4a4a4a !important;
}

.format-btn:active {
    background: #2a2a2a !important;
}

body.dark-mode .format-btn:active {
    background: #2a2a2a !important;
}

/* Style individual format buttons */
.format-btn[data-format="bold"] {
    font-weight: 700;
}

.format-btn[data-format="italic"] {
    font-style: italic;
}

.format-btn[data-format="strikethrough"] {
    text-decoration: line-through;
}

/* Message formatting styles */
.message-text strong {
    font-weight: 600;
}

.message-text em {
    font-style: italic;
}

.message-text del {
    text-decoration: line-through;
}

.message-text code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message-text a.message-link {
    color: #53bdeb;
    text-decoration: none;
    word-break: break-all;
}

.message-text a.message-link:hover {
    text-decoration: underline;
}

/* Dark mode link color */
body.dark-mode .message-text a.message-link {
    color: #53bdeb;
}

.composer {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 14px;
    /* Base padding - safe area padding only applied on mobile via media query */
    padding-bottom: 16px;
    background: var(--bg-composer);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

/* Drag and drop visual feedback - WhatsApp style */
.composer.drag-over {
    background: #e6ffe6;
    border-top: 2px dashed #00a884;
    box-shadow: none;
    position: relative;
}

.composer.drag-over::before {
    content: 'Dosyayı buraya sürükleyin';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    color: #00a884;
    font-weight: 500;
    font-size: 16px;
    z-index: 10;
    white-space: nowrap;
}

body.dark-mode .composer.drag-over {
    background: rgba(0, 168, 132, 0.15);
}

body.dark-mode .composer.drag-over::before {
    color: #00a884;
}

.composer textarea {
    flex: 1;
    resize: none;
    padding: 10px 12px;
    border-radius: 21px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    min-height: 20px;
    max-height: 20px;
    line-height: 20px;
    overflow-y: hidden;
}

.composer textarea::placeholder {
    color: var(--text-secondary);
}

.composer textarea:focus {
    outline: none;
    border-color: var(--button-primary);
}

.composer button {
    padding: 8px 12px;
    border-radius: 50%;
    border: none;
    background: var(--button-primary);
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.composer button:hover {
    background: var(--button-secondary);
}

.composer-tools {
    position: relative;
}

.composer-tools input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.composer-tools label {
    cursor: pointer;
    display: inline-block;
    color: var(--text-secondary);
    font-size: 20px;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.composer-tools label:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.composer-tools button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 20px;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s ease;
    outline: none;
}

.composer-tools button:focus {
    outline: none;
    box-shadow: none;
}

.composer-tools button:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.composer-tools {
    display: flex;
    gap: 6px;
    align-items: center;
}

.attachment-preview {
    padding: 8px 12px;
    display: none; /* Hidden by default, shown when files are attached */
    flex-wrap: wrap;
    gap: 8px;
    background: var(--bg-composer);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.attachment-chip {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    padding-right: 28px;
    border-radius: 10px;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color 0.2s ease;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.attachment-chip:hover {
    background: var(--hover-bg);
}

.attachment-chip-remove {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.attachment-chip-remove:hover {
    background: rgba(220, 53, 69, 0.2);
    color: #dc3545;
    transform: translateY(-50%) scale(1.1);
}

.attachment-chip-remove:active {
    transform: translateY(-50%) scale(0.95);
}

body.dark-mode .attachment-chip-remove {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

body.dark-mode .attachment-chip-remove:hover {
    background: rgba(220, 53, 69, 0.3);
    color: #dc3545;
}

.admin-main {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    min-height: calc(100vh - 60px); /* Account for header height */
}

.admin-panel {
    padding: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    box-shadow: 0 2px 8px var(--shadow);
}

.admin-panel h2 {
    color: var(--text-primary);
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 24px;
}

.admin-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 12px;
}

.admin-form input,
.admin-form select {
    padding: 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.admin-form input::placeholder {
    color: var(--text-secondary);
}

.admin-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.admin-row.admin-header {
    font-weight: 600;
    background: var(--bg-tertiary);
    border-radius: 6px 6px 0 0;
    margin-bottom: 4px;
}

.admin-row:not(.admin-header):hover {
    background: var(--hover-bg);
}

.admin-row:last-of-type:not(.admin-header) {
    border-bottom: none;
}

.admin-row button {
    background: #ef4444;
    color: #fff;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
}

.admin-row button[data-edit] {
    background: var(--button-primary);
}

.admin-row button[data-edit]:hover {
    background: var(--button-secondary);
}

.order-btn {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    padding: 4px 8px !important;
    font-size: 12px;
    cursor: pointer;
    min-width: 30px;
}

.order-btn:hover:not(:disabled) {
    background: var(--hover-bg) !important;
}

.order-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Image Modal */
.edit-name-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-name-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.edit-name-modal-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 2001;
}

.edit-name-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.edit-name-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.edit-name-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.edit-name-modal-close:hover {
    background: var(--hover-bg);
}

.edit-name-modal-body {
    padding: 20px;
}

.edit-name-modal-body label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.edit-name-modal-body input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    box-sizing: border-box;
}

.edit-name-modal-body input:focus {
    outline: none;
    border-color: var(--button-primary);
}

.edit-name-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

/* New Chat Modal */
.new-chat-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.2s ease-out;
}

.new-chat-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.new-chat-modal-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideUp 0.3s ease-out;
    overflow: hidden;
    z-index: 2001;
}

.new-chat-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.new-chat-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.new-chat-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.new-chat-modal-close:hover {
    background: var(--hover-bg);
}

.new-chat-modal-body {
    padding: 20px;
}

.new-chat-modal-body label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.new-chat-modal-body input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    box-sizing: border-box;
}

.new-chat-modal-body input:focus {
    outline: none;
    border-color: var(--button-primary);
}

.new-chat-modal-body .error {
    margin-top: 8px;
    color: #ef4444;
    font-size: 13px;
}

.new-chat-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.btn-cancel {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.btn-cancel:hover {
    background: var(--hover-bg);
}

.btn-send {
    padding: 8px 16px;
    background: var(--button-primary);
    border: none;
    border-radius: 8px;
    color: #ffffff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.btn-send:hover {
    background: var(--button-secondary);
}

/* Image Lightbox (for viewing full-size images) */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.2s ease-out;
}

.image-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.image-lightbox-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-lightbox-content img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    cursor: default;
}

.image-lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 28px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10002;
}

.image-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.image-lightbox-download {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10002;
    text-decoration: none;
}

.image-lightbox-download:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Make images in messages clickable */
.message-attachment img {
    cursor: pointer;
    transition: opacity 0.2s;
}

.message-attachment img:hover {
    opacity: 0.9;
}

.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.2s ease-out;
    overflow-x: hidden;
    overflow-y: auto;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.image-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.image-modal-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideUp 0.3s ease-out;
    overflow: hidden;
    box-sizing: border-box;
    margin: 20px;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.image-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    box-sizing: border-box;
    flex-shrink: 0;
    min-width: 0;
}

.image-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.image-modal-close {
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.image-modal-close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.image-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(90vh - 140px);
    box-sizing: border-box;
}

#modalImagePreview {
    width: 100%;
    max-width: 100%;
    max-height: 400px;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    background: var(--bg-primary);
    box-sizing: border-box;
    display: block;
}

#imageCaption {
    width: 100%;
    max-width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    resize: none;
    min-height: 60px;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#imageCaption:focus {
    outline: none;
    border-color: var(--button-primary);
}

#imageCaption::placeholder {
    color: var(--text-secondary);
}

.image-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    box-sizing: border-box;
    flex-shrink: 0;
    min-width: 0;
}

.btn-cancel,
.btn-send {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.btn-cancel {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-cancel:hover {
    background: var(--hover-bg);
}

.btn-send {
    background: var(--button-primary);
    color: #fff;
}

.btn-send:hover {
    background: var(--button-secondary);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Template Modal */
.template-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.2s ease-out;
}

.template-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.template-modal-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideUp 0.3s ease-out;
    overflow: hidden;
}

.template-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.template-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.template-modal-close {
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.template-modal-close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.template-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.template-sync-section {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    align-items: center;
}

.btn-sync {
    background: var(--button-primary);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.btn-sync:hover {
    background: var(--button-secondary);
}

.template-sync-section select {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
}

.template-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.template-item {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-secondary);
}

.template-item:hover {
    background: var(--hover-bg);
    border-color: var(--button-primary);
}

.template-item.selected {
    background: var(--active-bg);
    border-color: var(--button-primary);
}

.template-item-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.template-item-body {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.template-item-category {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.template-item-language {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.template-placeholders {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.template-placeholders h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.template-preview {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    min-height: 60px;
}

.placeholder-input-group {
    margin-bottom: 12px;
}

.placeholder-input-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.placeholder-input-group input,
.placeholder-input-group textarea {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}

.placeholder-input-group input:focus,
.placeholder-input-group textarea:focus {
    outline: none;
    border-color: var(--button-primary);
}

.placeholder-input-group textarea {
    resize: vertical;
    min-height: 60px;
}

.template-modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
}

/* Message Context Menu */
.message-context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    min-width: 140px;
    padding: 4px;
    animation: contextMenuFadeIn 0.15s ease-out;
}

@keyframes contextMenuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.context-menu-item {
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
    transition: background-color 0.15s ease;
}

.context-menu-item:hover {
    background: var(--hover-bg);
}

.context-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

.context-menu-reactions {
    display: flex;
    gap: 4px;
    padding: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.context-menu-reaction-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    padding: 0;
}

.context-menu-reaction-btn:hover {
    background: var(--hover-bg);
    transform: scale(1.2);
}

.context-menu-reaction-btn:active {
    transform: scale(1.1);
}

/* Quoted Message */
.quoted-message {
    padding: 8px 12px;
    background: var(--bg-composer);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.quoted-message-content {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    position: relative;
}

.quoted-message-line {
    width: 3px;
    background: #00a884;
    border-radius: 2px;
    flex-shrink: 0;
    align-self: stretch;
}

.quoted-message-text {
    flex: 1;
    min-width: 0;
}

.quoted-message-author {
    font-size: 13px;
    font-weight: 500;
    color: #00a884;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quoted-message-body {
    font-size: 14px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.quoted-message-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.quoted-message-close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    .app-main {
        grid-template-columns: 1fr;
        position: relative;
    }
    
    .chat-list {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10;
        transition: transform 0.3s ease;
    }
    
    .chat-list.hidden {
        transform: translateX(-100%);
    }
    
    .chat-view {
        width: 100%;
        position: relative;
    }
    
    .chat-view.has-chat .chat-list {
        transform: translateX(-100%);
    }
    
    .chat-header {
        padding: 12px 14px;
        position: sticky;
        top: 0;
        z-index: 10;
        gap: 0;
        flex-direction: column;
        align-items: stretch;
    }
    
    /* First row: back button and title in a flex row */
    .chat-header > .back-button {
        position: absolute;
        left: 14px;
        top: 12px;
        bottom: 12px; /* Span to bottom of header to cover both rows */
        margin: 0;
        z-index: 1;
        height: auto; /* Override fixed height */
        width: 48px; /* Wider for better touch target */
        min-height: 80px; /* Ensure it covers both rows */
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px; /* Rounded rectangle instead of circle */
    }
    
    .chat-header > .chat-title {
        font-size: 16px;
        width: 100%;
        padding-left: 58px; /* More space for wider back button */
        order: 1;
        margin-bottom: 8px;
        min-height: 40px; /* Ensure consistent height */
        display: flex;
        align-items: center;
    }
    
    /* Second row: action buttons */
    .chat-header > .chat-actions {
        order: 2;
        width: 100%;
        justify-content: flex-start;
        max-width: 100%;
        padding-left: 58px; /* Align with title, accounting for back button */
        margin-top: 0;
        min-height: 44px; /* Ensure consistent height for touch target */
        align-items: center;
    }
    
    .contact-info-section.open {
        width: 100%;
        max-width: 100%;
    }
    
    .contact-info-header,
    .contact-info-content {
        width: 100%;
        min-width: 0;
    }
    
    .contact-info-content {
        padding: 12px;
    }
    
    .contact-info-card {
        padding: 10px;
    }
    
    .contact-info-row {
        flex-direction: column;
        gap: 4px;
        padding: 6px 0;
    }
    
    .contact-info-label {
        min-width: auto;
        font-size: 12px;
    }
    
    .back-button {
        display: flex !important;
        flex-shrink: 0;
    }
    
    .chat-actions {
        gap: 4px;
        flex-shrink: 0;
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }
    
    .chat-actions::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }
    
    .chat-actions button {
        padding: 6px 10px;
        font-size: 11px;
        flex-shrink: 0;
    }
    
    .message-list {
        padding: 16px 12px;
    }
    
    .message {
        max-width: 85%;
        margin-bottom: 8px;
    }
    
    .message-content {
        max-width: 100%;
    }
    
    .composer {
        padding: 8px 12px;
        /* Safe area for mobile gesture navigation - ensure minimum padding */
        /* Base padding + max of safe-area-inset-bottom or 48px (for Android nav bars) */
        padding-bottom: calc(8px + max(env(safe-area-inset-bottom, 48px), 48px));
    }
    
    .composer-tools button,
    .composer-tools label {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }
    
    .composer textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 10px 12px;
    }
    
    .chat-list-header {
        padding: 10px;
    }
    
    .chat-list-buttons button,
    .chat-list-buttons .header-link {
        width: 40px;
        height: 40px;
        min-width: 40px;
        padding: 0;
    }
    
    .chat-tab {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .chat-item {
        padding: 12px;
    }
    
    .chat-item-avatar {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }
    
    .chat-item-name {
        font-size: 16px;
    }
    
    .chat-item-preview {
        font-size: 14px;
    }
    
    .message-reaction-btn {
        width: 32px;
        height: 32px;
    }
    
    .reaction-picker {
        padding: 6px;
        gap: 6px;
    }
    
    .reaction-picker-btn {
        width: 44px;
        height: 44px;
        font-size: 24px;
    }
    
    .emoji-picker {
        padding: 12px;
        gap: 8px;
        max-width: calc(100vw - 32px);
    }
    
    .emoji-picker-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .chat-context-menu,
    .message-context-menu {
        min-width: 180px;
        font-size: 15px;
        padding: 4px;
    }
    
    .context-menu-item {
        padding: 12px 16px;
    }
    
    .new-chat-modal-content,
    .image-modal-content {
        width: 90%;
        max-width: 400px;
        padding: 24px;
    }
    
    .chat-list-row {
        gap: 8px;
    }
    
    #searchInput {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 10px 12px;
    }
    
    /* Full width messages on very small screens */
    @media (max-width: 480px) {
        .message {
            max-width: 90%;
        }
        
        .composer {
            padding: 6px 10px;
            /* Ensure minimum padding for very small screens */
            /* Base padding + max of safe-area-inset-bottom or 48px (for Android nav bars) */
            padding-bottom: calc(6px + max(env(safe-area-inset-bottom, 48px), 48px));
        }
        
        .chat-header {
            padding: 10px 12px;
        }
        
        .chat-actions button {
            padding: 5px 8px;
            font-size: 10px;
        }
        
        .chat-actions button#archiveBtn {
            padding: 5px 10px;
        }
    }
    
    /* Landscape orientation adjustments */
    @media (max-width: 768px) and (orientation: landscape) {
        .chat-list-header {
            padding: 8px 10px;
        }
        
        .chat-item {
            padding: 10px;
        }
        
        .message-list {
            padding: 12px 10px;
        }
    }
}

/* Back button for mobile */
.back-button {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    padding: 0;
    margin-right: 12px;
    cursor: pointer;
    user-select: none;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.back-button:hover,
.back-button:active {
    background: var(--hover-bg);
}

/* Prevent text selection on mobile for better UX */
@media (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }
    
    button, a {
        -webkit-user-select: none;
        user-select: none;
    }
    
    input, textarea {
        -webkit-user-select: text;
        user-select: text;
    }
    
    /* Improve touch targets */
    button, .chat-item, .context-menu-item {
        min-height: 44px;
    }
    
    /* Optimize scrolling on mobile */
    .chat-items, .message-list {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Better spacing for mobile */
    .chat-list-header {
        padding: 10px 12px;
    }
    
    .message-list {
        padding-bottom: 80px; /* Extra space for composer */
    }
    
    /* Ensure back button is visible on mobile when chat is selected */
    .chat-view.has-chat .back-button {
        display: flex !important;
    }
    
    /* Full width messages on very small screens */
    @media (max-width: 480px) {
        .message {
            max-width: 90%;
        }
        
        .composer {
            padding: 6px 10px;
            /* Ensure minimum padding for very small screens */
            /* Base padding + max of safe-area-inset-bottom or 48px (for Android nav bars) */
            padding-bottom: calc(6px + max(env(safe-area-inset-bottom, 48px), 48px));
        }
        
        .chat-header {
            padding: 10px 12px;
        }
        
        .chat-actions button {
            padding: 5px 8px;
            font-size: 10px;
        }
        
        .chat-actions button#archiveBtn {
            padding: 5px 10px;
        }
    }
    
    /* Landscape orientation adjustments */
    @media (max-width: 768px) and (orientation: landscape) {
        .chat-list-header {
            padding: 8px 10px;
        }
        
        .chat-item {
            padding: 10px;
        }
        
        .message-list {
            padding: 12px 10px;
        }
    }
}

/* ===== PWA Prompts ===== */
.pwa-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    display: flex;
    justify-content: center;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.pwa-prompt-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    box-shadow: 0 -4px 20px var(--shadow), 0 0 0 1px var(--border-color);
    padding: 16px 20px;
    max-width: 400px;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    position: relative;
}

.pwa-prompt-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.pwa-prompt-close:hover {
    opacity: 1;
}

.pwa-prompt-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-prompt-icon img {
    border-radius: 12px;
}

.pwa-prompt-text {
    flex: 1;
    min-width: 180px;
}

.pwa-prompt-text strong {
    display: block;
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.pwa-prompt-text p {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.pwa-prompt-buttons {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-top: 4px;
}

.pwa-btn-later,
.pwa-btn-install {
    flex: 1;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    border: none;
}

.pwa-btn-later {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.pwa-btn-later:hover {
    background: var(--hover-bg);
}

.pwa-btn-install {
    background: var(--button-primary);
    color: white;
}

.pwa-btn-install:hover {
    background: var(--button-secondary);
}

.pwa-btn-later:active,
.pwa-btn-install:active {
    transform: scale(0.98);
}

/* Mobile adjustments for PWA prompts */
@media (max-width: 480px) {
    .pwa-prompt {
        padding: 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }
    
    .pwa-prompt-content {
        padding: 14px 16px;
        border-radius: 14px;
    }
    
    .pwa-prompt-icon {
        width: 40px;
        height: 40px;
    }
    
    .pwa-prompt-icon img,
    .pwa-prompt-icon svg {
        width: 40px;
        height: 40px;
    }
    
    .pwa-prompt-text strong {
        font-size: 14px;
    }
    
    .pwa-prompt-text p {
        font-size: 12px;
    }
    
    .pwa-btn-later,
    .pwa-btn-install {
        padding: 10px 12px;
        font-size: 13px;
    }
}
