/* ═══════════════════════════════════════════════════
   BurdoChat v1.0 — Styles
   Dark theme, mobile-first, PWA-ready
   ═══════════════════════════════════════════════════ */

:root {
    --bg-deep: #07080c;
    --bg-base: #0a0b10;
    --bg-surface: #0f1117;
    --bg-raised: #151820;
    --bg-hover: #1a1d28;
    --bg-active: rgba(56,189,248,0.08);

    --border: rgba(148,163,184,0.07);
    --border-hover: rgba(148,163,184,0.12);

    --text-primary: #e8ecf2;
    --text-secondary: #8b95a8;
    --text-muted: #505a6e;

    --accent: #38bdf8;
    --accent-glow: rgba(56,189,248,0.15);
    --accent-dim: #1e6b9e;
    --sent-bg: #162a4a;
    --sent-bg-hover: #1a3358;

    --green: #22c55e;
    --amber: #f59e0b;
    --red: #ef4444;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-pill: 100px;

    --font-body: 'DM Sans', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --header-h: 56px;
    --sidebar-w: 320px;
}

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

html, body {
    height: 100%; overflow: hidden;
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* ─── Screens ──────────────────────────────────── */
.screen { display: none; height: 100%; }
.screen.active { display: flex; }

/* ═══ LOGIN ═══ */
#login-screen {
    justify-content: center; align-items: center;
    background: 
        radial-gradient(ellipse at 30% 20%, rgba(56,189,248,0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(129,140,248,0.04) 0%, transparent 50%),
        var(--bg-deep);
}

.login-container {
    width: 100%; max-width: 380px;
    padding: 24px;
    text-align: center;
}

.login-icon {
    font-size: 48px;
    margin-bottom: 8px;
    animation: floatIn 0.6s ease-out;
}

.login-container h1 {
    font-family: var(--font-mono);
    font-size: 28px; font-weight: 600;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--accent), #818cf8);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: floatIn 0.6s ease-out 0.1s both;
}

.login-subtitle {
    color: var(--text-muted); font-size: 13px;
    margin-top: 4px;
    animation: floatIn 0.6s ease-out 0.15s both;
}

.login-form {
    margin-top: 32px;
    animation: floatIn 0.6s ease-out 0.2s both;
}

.login-footer {
    margin-top: 40px; font-size: 11px;
    color: var(--text-muted); letter-spacing: 0.04em;
    animation: floatIn 0.6s ease-out 0.3s both;
}
.lock-icon { font-size: 12px; margin-right: 4px; }

/* ─── Form Elements ──────────────────────────── */
.input-group { margin-bottom: 14px; text-align: left; }
.input-group label {
    display: block; font-size: 11px; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 6px;
    text-transform: uppercase; letter-spacing: 0.08em;
}

.input-group input {
    width: 100%; padding: 12px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body); font-size: 14px;
    outline: none; transition: border-color 0.2s;
}
.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.input-group input::placeholder { color: var(--text-muted); }

.btn-primary {
    width: 100%; padding: 12px;
    background: linear-gradient(135deg, var(--accent), #6d9fff);
    border: none; border-radius: var(--radius);
    color: #fff; font-family: var(--font-body);
    font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
    margin-top: 6px;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }

.error-msg { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 20px; }
.status-msg { font-size: 13px; margin-top: 10px; min-height: 20px; color: var(--green); }

/* ═══ APP LAYOUT ═══ */
#app-screen { flex-direction: row; }

/* ─── Sidebar ────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w); min-width: var(--sidebar-w);
    background: var(--bg-base);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 10;
}

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

.user-profile { display: flex; align-items: center; gap: 10px; }
.avatar-emoji {
    width: 36px; height: 36px;
    background: var(--bg-raised);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.user-name { font-weight: 600; font-size: 14px; }
.status-badge {
    font-size: 10px; padding: 1px 8px;
    border-radius: var(--radius-pill); font-weight: 500;
}
.status-badge.online { background: rgba(34,197,94,0.12); color: var(--green); }
.user-info { display: flex; flex-direction: column; gap: 2px; }

.icon-btn {
    background: none; border: none;
    font-size: 18px; cursor: pointer;
    padding: 6px; border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); }

.icon-btn-sm {
    background: none; border: none;
    font-size: 14px; cursor: pointer;
    padding: 4px; color: var(--text-muted);
}

/* Search */
.search-bar {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px;
}
.search-bar input {
    flex: 1; background: var(--bg-raised);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 8px 10px; color: var(--text-primary);
    font-size: 13px; font-family: var(--font-body); outline: none;
}
.search-bar input:focus { border-color: var(--accent); }

/* Conversation List */
.conv-list { flex: 1; overflow-y: auto; padding: 6px 0; }

.conv-item {
    padding: 12px 16px;
    display: flex; align-items: center; gap: 10px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}
.conv-item:hover { background: var(--bg-hover); }
.conv-item.active {
    background: var(--bg-active);
    border-left-color: var(--accent);
}

.conv-avatar { position: relative; }
.conv-avatar .avatar-emoji { width: 40px; height: 40px; font-size: 20px; }
.status-dot {
    position: absolute; bottom: -1px; right: -1px;
    width: 11px; height: 11px; border-radius: 50%;
    border: 2px solid var(--bg-base);
}
.status-dot.online { background: var(--green); }
.status-dot.away { background: var(--amber); }
.status-dot.offline { background: var(--text-muted); }

.conv-info { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; align-items: center; }
.conv-name { font-size: 13.5px; font-weight: 600; }
.conv-time { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }
.conv-preview {
    font-size: 12px; color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-unread {
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--accent); color: var(--bg-deep);
    font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: space-around;
}

/* ─── Chat Area ──────────────────────────────── */
.chat-area {
    flex: 1; display: flex; flex-direction: column;
    background:
        radial-gradient(ellipse at 80% 10%, rgba(56,189,248,0.025) 0%, transparent 50%),
        var(--bg-deep);
    position: relative;
    min-width: 0;
}

.empty-state {
    flex: 1; display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state h2 { font-size: 18px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.empty-state p { font-size: 13px; }

.chat-header {
    height: var(--header-h); padding: 0 16px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(10,11,16,0.8);
    backdrop-filter: blur(12px);
    flex-shrink: 0;
}
.chat-header-info { display: flex; align-items: center; gap: 10px; }
.chat-title { font-weight: 600; font-size: 14px; }
.chat-status { font-size: 11px; }
.chat-status.online { color: var(--green); }
.chat-status.away { color: var(--amber); }
.chat-status.offline { color: var(--text-muted); }
.chat-header-actions { display: flex; gap: 4px; }

/* Messages Container */
.messages-container {
    flex: 1; overflow-y: auto;
    display: flex; flex-direction: column;
}
.messages {
    flex: 1; padding: 16px 20px;
    display: flex; flex-direction: column; gap: 4px;
}

/* Date Divider */
.date-divider {
    text-align: center; margin: 14px 0;
}
.date-divider span {
    font-size: 10px; color: var(--text-muted);
    background: var(--bg-surface);
    padding: 3px 14px; border-radius: var(--radius-pill);
    letter-spacing: 0.04em; font-weight: 500;
}

/* Message Bubbles */
.msg-row { display: flex; margin-bottom: 2px; }
.msg-row.sent { justify-content: flex-end; }
.msg-row.received { justify-content: flex-start; }

.msg-bubble {
    max-width: 72%; padding: 10px 14px;
    font-size: 14px; line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}
.msg-row.sent .msg-bubble {
    background: var(--sent-bg);
    border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
}
.msg-row.received .msg-bubble {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
}

.msg-row.system { justify-content: center; }
.msg-row.system .msg-bubble {
    background: none; border: none;
    font-size: 12px; color: var(--text-muted);
    text-align: center; padding: 6px 12px;
}

.msg-meta {
    display: flex; align-items: center; gap: 4px;
    margin-top: 4px; font-size: 10px; color: var(--text-muted);
}
.msg-row.sent .msg-meta { justify-content: flex-end; }
.read-receipt { font-size: 11px; }
.read-receipt.read { color: var(--accent); }

/* File messages */
.msg-file {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    background: rgba(0,0,0,0.15);
    border-radius: var(--radius-sm);
    margin-bottom: 4px; cursor: pointer;
    text-decoration: none; color: inherit;
}
.msg-file:hover { background: rgba(0,0,0,0.25); }
.file-icon { font-size: 22px; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 10px; color: var(--text-muted); }

.msg-image {
    max-width: 280px; border-radius: var(--radius);
    margin-bottom: 4px; cursor: pointer;
}

/* Typing indicator */
.typing-indicator {
    padding: 4px 20px 8px;
    font-size: 12px; color: var(--text-secondary);
    font-style: italic;
}
.typing-dots span {
    animation: blink 1.4s infinite;
    font-style: normal; font-weight: 700;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Message Input */
.message-input-area {
    padding: 10px 16px 14px;
    border-top: 1px solid var(--border);
    background: rgba(10,11,16,0.6);
    backdrop-filter: blur(8px);
    flex-shrink: 0;
}

.input-row {
    display: flex; align-items: flex-end; gap: 8px;
}

#msg-input {
    flex: 1; resize: none;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font-body); font-size: 14px;
    outline: none; max-height: 120px;
    transition: border-color 0.2s;
    line-height: 1.4;
}
#msg-input:focus { border-color: var(--accent); }
#msg-input::placeholder { color: var(--text-muted); }

.send-btn {
    width: 40px; height: 40px;
    border-radius: var(--radius);
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    background: var(--bg-raised);
}
.send-btn.ready {
    background: linear-gradient(135deg, var(--accent), #6d9fff);
}
.send-arrow {
    font-size: 18px; font-weight: 700;
    color: var(--text-muted);
    transition: color 0.2s;
}
.send-btn.ready .send-arrow { color: #fff; }

/* ═══ MODAL ═══ */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: center; align-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
.modal-content {
    position: relative; width: 90%; max-width: 400px;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); overflow: hidden;
    max-height: 90vh; overflow-y: auto;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-close {
    background: none; border: none; font-size: 18px;
    color: var(--text-muted); cursor: pointer; padding: 4px;
}
.modal-body { padding: 20px; }
.modal-body h3 { font-size: 14px; margin-bottom: 12px; color: var(--text-secondary); }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.settings-info { text-align: center; font-size: 12px; color: var(--text-muted); }
.settings-info .muted { margin-top: 4px; font-size: 11px; }

/* Upload Progress */
.upload-progress {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
    background: var(--bg-raised); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 10px 16px;
    display: flex; align-items: center; gap: 10px;
    min-width: 200px; z-index: 50;
}
.upload-bar { flex: 1; height: 4px; background: var(--bg-surface); border-radius: 2px; overflow: hidden; }
.upload-fill { height: 100%; background: var(--accent); border-radius: 2px; width: 0%; transition: width 0.3s; }
.upload-text { font-size: 11px; color: var(--text-secondary); white-space: nowrap; }

/* Pinned badge */
.pin-badge {
    font-size: 10px; color: var(--amber);
    margin-bottom: 4px; font-weight: 500;
}

/* ─── Utilities ──────────────────────────────── */
.hidden { display: none !important; }
.hidden-input { position: absolute; opacity: 0; width: 0; height: 0; }
.loading-placeholder {
    padding: 40px 20px; text-align: center;
    color: var(--text-muted); font-size: 13px;
}

/* ─── Animations ─────────────────────────────── */
@keyframes floatIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes blink {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 1; }
}
@keyframes slideIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-row { animation: slideIn 0.15s ease-out; }

/* ─── Scrollbar ──────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ═══ RESPONSIVE ═══ */
.mobile-only { display: none; }

@media (max-width: 768px) {
    .sidebar {
        position: fixed; inset: 0; z-index: 20;
        width: 100%; min-width: 100%;
        transform: translateX(0);
    }
    .sidebar.hidden-mobile { transform: translateX(-100%); }

    .chat-area { width: 100%; }
    .mobile-only { display: inline-flex; }

    .msg-bubble { max-width: 85%; }
    .msg-image { max-width: 220px; }
}
