/* SermoQ - Element-Inspired Modern E2EE Web Chat CSS */

:root {
    /* Dark Theme (Default) */
    --bg-primary: #15191e;
    --bg-secondary: #1a2026;
    --bg-surface: #212830;
    --bg-card: #29313d;
    --bg-active: #323d4c;
    --bg-hover: rgba(255, 255, 255, 0.05);

    --accent: #0dbd8b; /* Signature Element Green */
    --accent-hover: #0aa378;
    --accent-light: rgba(13, 189, 139, 0.15);
    --accent-bubble: linear-gradient(135deg, #1b5344 0%, #0d3d31 100%);

    --text-primary: #f0f4f8;
    --text-secondary: #a9b7c6;
    --text-muted: #6c7c8c;
    
    --border-color: #2e3642;
    --border-light: rgba(255, 255, 255, 0.08);

    --danger: #ff5252;
    --warning: #ffb300;
    --success: #0dbd8b;
    --info: #29b6f6;

    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-code: 'JetBrains Mono', monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
    --shadow-lg: 0 12px 30px rgba(0,0,0,0.4);

    --sidebar-width: 280px;
    --space-bar-width: 68px;
    --info-panel-width: 260px;
}

html.light {
    --bg-primary: #f4f6f9;
    --bg-secondary: #ffffff;
    --bg-surface: #eef2f6;
    --bg-card: #e3e8f0;
    --bg-active: #d6deeb;
    --bg-hover: rgba(0, 0, 0, 0.04);
    --accent-bubble: linear-gradient(135deg, #e3f9f2 0%, #cbf5e7 100%);

    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;

    --border-color: #cbd5e0;
    --border-light: rgba(0, 0, 0, 0.08);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* App Container Layout */
#app {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* 1. Leftmost Space / Navigation Bar */
.space-bar {
    width: var(--space-bar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 0;
    gap: 16px;
    z-index: 10;
}

.brand-icon {
    width: 44px;
    height: 44px;
    background: var(--accent-light);
    border: 2px solid var(--accent);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s;
}

.brand-icon:hover {
    transform: scale(1.05);
}

.space-nav {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    width: 100%;
    align-items: center;
}

.space-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    position: relative;
}

.space-btn:hover, .space-btn.active {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
}

.space-btn.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 10px;
    bottom: 10px;
    width: 4px;
    background: var(--accent);
    border-radius: 0 4px 4px 0;
}

.user-profile-btn {
    margin-top: auto;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--accent);
    color: #0b111a;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    border: 2px solid var(--accent);
    transition: transform 0.2s;
}

.user-profile-btn:hover {
    transform: scale(1.08);
}

.user-profile-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 2. Room List Sidebar */
.room-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: background 0.2s;
}

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

.search-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    width: 100%;
}

.room-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.room-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 4px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.room-item {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

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

.room-item.active {
    background: var(--bg-surface);
    border-left: 3px solid var(--accent);
}

.room-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--accent);
    font-size: 0.95rem;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.room-avatar.dm {
    border-radius: 50%;
}

.room-info {
    flex: 1;
    min-width: 0;
}

.room-name {
    font-size: 0.92rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.room-preview {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.e2ee-badge-icon {
    font-size: 0.75rem;
    color: var(--accent);
}

/* Presence Dot Indicator */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
    position: absolute;
    bottom: -1px;
    right: -1px;
}

.status-dot.online {
    background-color: var(--accent);
    box-shadow: 0 0 6px var(--accent);
}

.status-dot.offline {
    background-color: #6c7c8c;
}

/* 3. Main Chat Viewport & Right Member Sidebar */
.chat-viewport {
    flex: 1;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Drag & Drop Overlay */
.drag-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(13, 189, 139, 0.15);
    border: 3px dashed var(--accent);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    color: var(--accent);
    font-size: 1.2rem;
    font-weight: 700;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.drag-overlay.active {
    opacity: 1;
}

.chat-main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.chat-messages-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.room-title-text {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.e2ee-status-shield {
    background: var(--accent-light);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

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

.btn-primary {
    background: var(--accent);
    color: #0b111a;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* Right Member List Panel */
.room-member-sidebar {
    width: var(--info-panel-width);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.member-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.member-list-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
}

.member-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    color: #0b111a;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
}

.member-avatar img {
    width: 100%; height: 100%; object-fit: cover;
}

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

.member-name {
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-status {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.member-status.online {
    color: var(--accent);
}

/* Message Feed & Distinct Message Bubbles */
.message-feed {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message-item {
    display: flex;
    gap: 12px;
    max-width: 78%;
}

/* Self Messages (Right Aligned, Distinct Accent Gradient) */
.message-item.me {
    margin-left: auto;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent);
    color: #0b111a;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.95rem;
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-content-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.message-item.me .message-meta {
    justify-content: flex-end;
}

.message-sender {
    font-weight: 600;
    color: var(--text-secondary);
}

/* Others' Message Bubble */
.message-bubble {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    border-top-left-radius: 2px;
    padding: 12px 16px;
    font-size: 0.95rem;
    line-height: 1.45;
    word-break: break-word;
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
}

/* Self Message Bubble (Distinct Accent Style) */
.message-item.me .message-bubble {
    background: var(--accent-bubble);
    border: 1px solid var(--accent);
    border-top-left-radius: 14px;
    border-top-right-radius: 2px;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(13, 189, 139, 0.15);
}

.message-bubble code {
    font-family: var(--font-code);
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

.message-bubble pre {
    font-family: var(--font-code);
    background: rgba(0,0,0,0.4);
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 0.85em;
}

/* Audio Player */
audio {
    width: 100%;
    min-width: 240px;
    height: 40px;
    border-radius: 8px;
    margin-top: 6px;
}

/* Chat Input Footer */
.chat-input-container {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.input-wrapper {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
}

.message-input {
    width: 100%;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    max-height: 140px;
    min-height: 24px;
}

.input-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border-light);
    padding-top: 8px;
}

.input-tools {
    display: flex;
    gap: 4px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

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

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-group input, .form-group select {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.92rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.empty-chat-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
    gap: 12px;
    padding: 20px;
}

.empty-icon {
    font-size: 3rem;
}
