:root {
    --bg-main: #09090b;
    --bg-card: #18181b;
    --bg-card-hover: #27272a;
    --border-color: #27272a;
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-dim: #71717a;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-success: #10b981;
    --accent-success-bg: rgba(16, 185, 129, 0.1);
    --error-color: #ef4444;
    --font-ui: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

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

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseRed {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}

.pulse-red {
    animation: pulseRed 1.5s infinite ease-in-out;
    display: inline-block;
}

/* Login Screen Layout */
#login {
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #09090b 0%, #18181b 100%);
    height: 100vh;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 2.5rem 2rem;
    border-radius: 16px;
    width: 90%;
    max-width: 380px;
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-card h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #ffffff, #a1a1aa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-card .subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 1.5rem;
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    background: #09090b;
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

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

.auth-tab.active {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.auth-tab:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.input-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.input-group select, .input-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: #09090b;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: var(--font-ui);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group select:focus, .input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.btn-primary {
    width: 100%;
    padding: 0.8rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-ui);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    margin-top: 1rem;
}

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

.btn-primary:active {
    transform: scale(0.98);
}

.error-message {
    margin-top: 1.25rem;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--error-color);
    border-radius: 8px;
    font-size: 0.85rem;
    text-align: center;
}

/* App Layout Grid */
.app-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 100vh;
    width: 100vw;
}

/* Dashboard Sidebar Styling */
.sidebar {
    background: #0e0e11;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-logo {
    font-size: 1.4rem;
}

.brand h3 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    text-transform: uppercase;
}

.status-badge.status-online {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-success);
}

.status-badge.status-offline {
    background: rgba(113, 113, 122, 0.15);
    color: var(--text-secondary);
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Sidebar Sections */
.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
}

.section-hint {
    font-size: 0.75rem;
    color: var(--text-dim);
    line-height: 1.3;
}

/* Profile Card */
.profile-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    text-transform: uppercase;
}

.profile-details h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

.profile-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Registered Contacts List styling */
.users-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
}

.no-users {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: center;
    padding: 15px 0;
}

.user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.user-item:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--text-dim);
}

.user-item.active {
    background-color: rgba(37, 99, 235, 0.15);
    border-color: var(--accent);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar-mini {
    width: 28px;
    height: 28px;
    background: var(--border-color);
    color: var(--text-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.user-item.active .avatar-mini {
    background: var(--accent);
    color: white;
}

.username-label {
    font-size: 0.9rem;
    font-weight: 500;
}

.user-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-dim);
}

.user-status-dot.online {
    background-color: var(--accent-success);
}

/* Fingerprints Display */
.fingerprint-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fingerprint-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fingerprint-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.fingerprint-value {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent-success);
    word-break: break-all;
    background: #09090b;
    padding: 4px 6px;
    border-radius: 4px;
    border: 1px solid #1f1f23;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Sidebar Footer & Logout */
.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.btn-logout-sidebar {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-weight: 600;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}

.btn-logout-sidebar:hover {
    background-color: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
    color: var(--error-color);
}

/* Chat Main Workspace */
.chat-area {
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    overflow: hidden;
}

.chat-header {
    padding: 18px 24px;
    background: #0d0d0f;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}

.peer-info h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.peer-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge-pqc-on {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    background: var(--accent-success-bg);
    color: var(--accent-success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Chat Message Logs */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: radial-gradient(circle at top left, #0e0e11 0%, #09090b 100%);
}

.chat-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-dim);
    gap: 12px;
}

.placeholder-icon {
    font-size: 3rem;
    opacity: 0.4;
}

.chat-placeholder p {
    font-size: 0.95rem;
    max-width: 280px;
    text-align: center;
    line-height: 1.4;
}

/* Message bubble container */
.message {
    max-width: 65%;
    padding: 10px 14px;
    border-radius: 16px;
    word-wrap: break-word;
    font-size: 0.95rem;
    line-height: 1.45;
    animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    position: relative;
}

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

.message.theirs {
    align-self: flex-start;
    background: var(--bg-card);
    border-bottom-left-radius: 4px;
    color: #e4e4e7;
    border: 1px solid var(--border-color);
}

.message-content {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
}

.lock-icon {
    font-size: 0.8rem;
    color: var(--accent-success);
    margin-top: 3px;
}

.content {
    flex: 1;
}

/* Media styling inside chat bubbles */
.media-image-container {
    margin-top: 4px;
    border-radius: 8px;
    overflow: hidden;
    max-width: 250px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
}

.media-image {
    width: 100%;
    height: auto;
    display: block;
}

/* Audio Player styling */
.media-audio-player {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 12px;
    border-radius: 20px;
    margin-top: 4px;
    min-width: 200px;
}

.media-audio-player button {
    background: var(--accent);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.message.theirs .media-audio-player button {
    background: var(--accent-success);
}

.audio-progress {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.audio-progress-bar {
    width: 0%;
    height: 100%;
    background: white;
}

.audio-duration {
    font-size: 0.7rem;
    opacity: 0.8;
}

/* File attachments document styling */
.media-file-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.25);
    padding: 10px 14px;
    border-radius: 8px;
    margin-top: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.file-icon {
    font-size: 1.5rem;
}

.file-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    color: var(--text-primary);
}

.file-size {
    font-size: 0.7rem;
    opacity: 0.7;
}

.btn-file-download {
    background: var(--accent);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.message.theirs .btn-file-download {
    background: var(--bg-card-hover);
    border: 1px solid var(--border-color);
}

/* View-Once Blur Placeholder */
.view-once-placeholder {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px dashed rgba(239, 68, 68, 0.3);
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 4px;
    transition: background-color 0.2s;
}

.view-once-placeholder:hover {
    background: rgba(239, 68, 68, 0.15);
}

.view-once-text {
    font-size: 0.85rem;
    color: var(--error-color);
    font-weight: 600;
}

/* Recall/Trash control button */
.btn-recall {
    position: absolute;
    right: -28px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    padding: 4px;
}

.message.mine:hover .btn-recall {
    opacity: 1;
}

.btn-recall:hover {
    color: var(--error-color);
}

.message.theirs .btn-recall {
    display: none; /* Can only delete your own messages */
}

/* Markdown Support Elements inside Chat Bubble */
.content strong {
    font-weight: 700;
}

.content em {
    font-style: italic;
}

.content code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 5px;
    border-radius: 4px;
    color: #ff79c6;
}

.message.mine .content code {
    background: rgba(255, 255, 255, 0.15);
    color: #f1f5f9;
}

.message-meta {
    font-size: 0.7rem;
    opacity: 0.55;
    margin-top: 6px;
    text-align: right;
}

/* Status Bars for Media Upload/Record */
.recording-status-bar {
    background: rgba(239, 68, 68, 0.15);
    border-top: 1px solid rgba(239, 68, 68, 0.25);
    padding: 8px 24px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.upload-status-bar {
    background: rgba(37, 99, 235, 0.15);
    border-top: 1px solid rgba(37, 99, 235, 0.25);
    padding: 8px 24px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

#typing-indicator {
    padding: 5px 24px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Footer / Input Panel */
.chat-footer {
    padding: 20px 24px;
    background: #0d0d0f;
    border-top: 1px solid var(--border-color);
}

#message-form {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

#message-form.disabled-form {
    opacity: 0.5;
}

.btn-footer-action {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    transition: background-color 0.2s;
}

.btn-footer-action:hover {
    background-color: var(--bg-card);
}

/* View Once button state styling */
.btn-view-once-on {
    color: var(--error-color);
    background-color: rgba(239, 68, 68, 0.1) !important;
}

.btn-view-once-off {
    color: var(--text-dim);
}

#message-input {
    flex: 1;
    padding: 12px 18px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: white;
    font-size: 0.95rem;
    font-family: var(--font-ui);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#message-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

#message-form button[type="submit"] {
    background: var(--accent);
    color: white;
    border: none;
    font-weight: 600;
    font-size: 0.9rem;
    font-family: var(--font-ui);
    cursor: pointer;
    padding: 10px 20px;
    border-radius: 20px;
    transition: background-color 0.2s, transform 0.1s;
}

#message-form button[type="submit"]:hover {
    background-color: var(--accent-hover);
}

#message-form button[type="submit"]:active {
    transform: scale(0.96);
}

#message-form button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Recording Mic Active Styling */
#record-btn.recording {
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--error-color);
    animation: pulseRed 1.5s infinite ease-in-out;
}

/* Modal Overlay styling for View-Once photo viewer */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 12px 18px;
    background: #0d0d0f;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.modal-countdown-timer {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error-color);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.modal-body {
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    max-height: 80vh;
    background: #09090b;
}

.modal-body img {
    max-width: 100%;
    max-height: 60vh;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}