/* ========================================
   Paraleido - Mobile-first UI
   ======================================== */

:root {
    --bg-primary: #0a0a14;
    --bg-secondary: #10101c;
    --bg-card: #161625;
    --bg-hover: #1e1e32;
    --bg-input: #1a1a2c;
    --text-primary: #eaeaf0;
    --text-secondary: #9090a8;
    --text-muted: #5a5a72;
    --accent: #7c6cf0;
    --accent-hover: #8d7eff;
    --accent-soft: rgba(124, 108, 240, 0.12);
    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.12);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.12);
    --border: #222238;
    --msg-sent: #6c5ce7;
    --msg-received: #1a1a30;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100dvh;
    overflow: hidden;
    font-size: 15px;
    line-height: 1.5;
}

/* ========== SCREENS ========== */
.screen { display: none; height: 100dvh; }
.screen.active { display: flex; }

/* ========== AUTH ========== */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 24px;
    overflow-y: auto;
}

.logo { text-align: center; margin-bottom: 32px; }
.logo-icon { margin-bottom: 12px; }
.logo h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #a78bfa, #6c5ce7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.auth-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-text {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.restore-details {
    margin-top: 8px;
}

.restore-details summary {
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    padding: 8px 0;
}

.restore-details textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px;
    border-radius: var(--radius);
    font-family: monospace;
    font-size: 12px;
    resize: none;
    margin-top: 8px;
}

/* ========== INPUTS ========== */
.input-field {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 14px 16px;
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s;
}

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

.input-field::placeholder { color: var(--text-muted); }

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    touch-action: manipulation;
}

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

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid transparent;
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.2); }

.btn-ghost {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    padding: 10px;
    cursor: pointer;
}
.btn-ghost:hover { color: var(--text-secondary); }

.btn-large { width: 100%; padding: 16px; font-size: 16px; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-half { flex: 1; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-icon-sm {
    display: inline-flex;
    align-items: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}
.btn-icon-sm:hover { color: var(--accent); }

.btn-send {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
.btn-send:hover { background: var(--accent-hover); }

/* ========== CHAT LAYOUT ========== */
.chat-layout {
    display: flex;
    width: 100%;
    height: 100dvh;
    position: relative;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: 320px;
    min-width: 320px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100dvh;
    z-index: 200;
}

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

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #a78bfa, #6c5ce7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.user-info {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}

.user-name-display { margin-bottom: 4px; }
.sidebar-name { font-size: 16px; font-weight: 600; }

.user-id-section { display: flex; align-items: center; gap: 8px; }
.label-mini {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.id-display {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.id-display code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--accent);
}

.sidebar-actions {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
}

.pending-section {
    padding: 0 20px 8px;
}

.pending-section h3 {
    font-size: 11px;
    color: var(--warning);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.pending-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 4px;
    font-size: 13px;
}

.list-section {
    padding: 0 12px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.list-section h3 {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 8px 6px;
}

.chat-list { display: flex; flex-direction: column; gap: 2px; }

.contact-item, .group-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.12s;
}

.contact-item:hover, .group-item:hover { background: var(--bg-hover); }
.contact-item.active, .group-item.active { background: var(--accent-soft); }
.contact-item.has-unread, .group-item.has-unread { background: var(--accent-soft); }

.contact-info-col {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.contact-display-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-sub-id {
    font-family: monospace;
    font-size: 11px;
    color: var(--text-muted);
}

.group-icon { font-size: 20px; flex-shrink: 0; }

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--text-muted); }

.empty-state {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 20px 8px;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
}

/* ========== CHAT AREA ========== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    min-width: 0;
}

.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    padding: 24px;
}
.chat-empty h3 { color: var(--text-secondary); }
.chat-empty p {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
}

.chat-active {
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    min-height: 56px;
}

.btn-back { display: none; }

.chat-contact-info {
    flex: 1;
    min-width: 0;
    cursor: default;
}

.contact-name {
    display: block;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-status {
    font-size: 11px;
    color: var(--text-muted);
}

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

.encryption-badge {
    font-size: 10px;
    color: var(--success);
    background: var(--success-soft);
    padding: 4px 8px;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

/* ========== MESSAGES ========== */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overscroll-behavior: contain;
}

.empty-messages {
    color: var(--text-muted);
    text-align: center;
    margin: auto;
    font-size: 13px;
}

.message { display: flex; max-width: 85%; }
.message-sent { align-self: flex-end; }
.message-received { align-self: flex-start; }

.message-bubble {
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-sent .message-bubble {
    background: var(--msg-sent);
    border-bottom-right-radius: 4px;
}

.message-received .message-bubble {
    background: var(--msg-received);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.message-text {
    font-size: 15px;
    line-height: 1.45;
    white-space: pre-wrap;
}

.message-time {
    font-size: 10px;
    color: rgba(255,255,255,0.4);
    display: block;
    text-align: right;
    margin-top: 4px;
}

.group-msg-sender {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 2px;
}

/* ========== MESSAGE INPUT ========== */
.message-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: calc(10px + var(--safe-bottom));
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.message-input-area textarea {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 12px 14px;
    border-radius: 22px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
}

.message-input-area textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* ========== MODALS ========== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    padding: 0;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85dvh;
    overflow-y: auto;
    animation: slideUp 0.2s ease;
}

.modal-tall { max-height: 90dvh; }

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

.modal-header h3 { font-size: 17px; font-weight: 600; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
}

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

.modal-body label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.modal-desc {
    color: var(--text-secondary);
    font-size: 14px;
}

.row-input {
    display: flex;
    gap: 8px;
}
.row-input .input-field { flex: 1; }

.key-display {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: var(--bg-input);
    padding: 10px 12px;
    border-radius: var(--radius);
}

.key-display code {
    font-family: monospace;
    font-size: 11px;
    color: var(--text-muted);
    word-break: break-all;
    flex: 1;
    line-height: 1.5;
}

.info-card {
    padding: 14px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.5;
}
.info-card strong { display: block; margin-bottom: 4px; }
.info-card p { margin: 0; }
.info-card.warning {
    background: var(--warning-soft);
    color: var(--warning);
    border: 1px solid rgba(251, 191, 36, 0.15);
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

.result-msg {
    font-size: 13px;
    padding: 10px 12px;
    border-radius: var(--radius);
}
.result-msg.error { color: var(--danger); background: var(--danger-soft); }
.result-msg.success { color: var(--success); background: var(--success-soft); }
.result-msg.info { color: var(--accent); background: var(--accent-soft); }

/* ========== GROUP MODALS ========== */
.member-checkbox-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
}

.group-member-check {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
    cursor: pointer;
    border-radius: 8px;
    font-size: 14px;
}
.group-member-check:hover { background: var(--bg-hover); }
.group-member-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}
.group-member-check small {
    color: var(--text-muted);
    font-family: monospace;
    font-size: 11px;
    margin-left: auto;
}

.group-members-list { max-height: 260px; overflow-y: auto; }

.group-member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 4px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}
.group-member-item small {
    color: var(--text-muted);
    font-family: monospace;
    font-size: 11px;
}
.member-name { flex: 1; }

.admin-badge {
    font-size: 10px;
    color: var(--warning);
    background: var(--warning-soft);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* ========== AUTO-DESTRUCT ========== */
.destruct-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.destruct-opt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.12s;
}

.destruct-opt:hover { background: var(--bg-hover); }

.destruct-opt.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.destruct-opt.active .destruct-label { font-weight: 600; }

.destruct-active-badge {
    font-size: 10px;
    color: var(--danger);
    background: var(--danger-soft);
    padding: 3px 8px;
    border-radius: var(--radius-full);
    white-space: nowrap;
    font-weight: 600;
}

.msg-destruct-bar {
    height: 2px;
    background: var(--danger);
    border-radius: 1px;
    margin-top: 4px;
    transition: width 0.5s linear;
    opacity: 0.6;
}

.msg-countdown {
    font-size: 9px;
    color: var(--danger);
    opacity: 0.7;
    text-align: right;
    margin-top: 2px;
}

/* ========== FILES ========== */
.file-message { max-width: 100%; }

.file-preview-img {
    max-width: 260px;
    max-height: 260px;
    border-radius: var(--radius);
    cursor: pointer;
    display: block;
    margin-bottom: 6px;
}

.file-preview-video {
    max-width: 280px;
    border-radius: var(--radius);
    display: block;
    margin-bottom: 6px;
}

.file-preview-audio {
    width: 100%;
    max-width: 240px;
    margin-bottom: 6px;
}

.file-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.file-name { font-size: 12px; color: var(--text-secondary); word-break: break-all; }
.file-size { font-size: 11px; color: var(--text-muted); }

.file-download-btn {
    font-size: 11px;
    color: var(--accent);
    text-decoration: none;
    padding: 3px 10px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-full);
    transition: all 0.15s;
}
.file-download-btn:hover { background: var(--accent); color: white; }

.file-generic { display: flex; align-items: center; gap: 10px; }
.file-icon { font-size: 28px; }
.file-details { display: flex; flex-direction: column; flex: 1; }

/* ========== CALL OVERLAY ========== */
.call-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 15, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.call-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 40px 24px;
    width: 100%;
    max-width: 500px;
}

.call-info { text-align: center; }
.call-type {
    font-size: 12px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
}
.call-info h2 { font-size: 24px; margin: 10px 0 6px; }
.call-status { font-size: 14px; color: var(--text-secondary); }

.call-video-section {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.remote-video { width: 100%; height: 100%; object-fit: cover; }
.local-video {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 100px;
    height: 75px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 2px solid var(--border);
}

.call-buttons { display: flex; gap: 16px; align-items: center; }

.call-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.call-accept { background: var(--success); color: white; }
.call-reject { background: var(--danger); color: white; }
.call-hangup {
    background: var(--danger);
    color: white;
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 50%;
}
.call-toggle {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
}
.call-toggle.active { background: var(--warning); color: var(--bg-primary); border-color: var(--warning); }

/* --- Llamada finalizada --- */
.call-ended {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

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

.call-ended-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--danger-soft);
    display: flex;
    align-items: center;
    justify-content: center;
}

.call-ended-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
}

.call-ended-reason {
    font-size: 15px;
    color: var(--text-secondary);
    max-width: 280px;
    line-height: 1.5;
}

.call-ended-close {
    margin-top: 8px;
}

.group-call-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 6px;
    width: 100%;
    margin-top: 8px;
}

.group-vid-wrapper {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 4/3;
}
.group-vid-wrapper video { width: 100%; height: 100%; object-fit: cover; }
.group-vid-label {
    position: absolute;
    bottom: 4px;
    left: 4px;
    font-size: 10px;
    background: rgba(0,0,0,0.6);
    padding: 2px 6px;
    border-radius: 4px;
    color: white;
}

/* ========== LOCK SCREEN ========== */
.lock-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
}

.lock-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 32px;
    max-width: 360px;
    width: 100%;
    text-align: center;
}

.lock-container h2 {
    font-size: 22px;
    margin-top: 8px;
}

.lock-desc {
    color: var(--text-secondary);
    font-size: 14px;
}

.lock-container .input-field {
    text-align: center;
    font-size: 18px;
    letter-spacing: 2px;
}

/* ========== SAFETY NUMBERS ========== */
.safety-number {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 16px;
    letter-spacing: 3px;
    line-height: 2;
    text-align: center;
    background: var(--bg-input);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    color: var(--accent);
    white-space: pre-line;
    user-select: all;
}

/* ========== TYPING INDICATOR ========== */
.typing-indicator {
    padding: 4px 0;
}

.typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    background: var(--msg-received);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.typing-name {
    color: var(--accent);
    font-weight: 500;
}

.typing-dots span {
    animation: blink 1.4s infinite;
    font-weight: bold;
    font-size: 16px;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0%, 60%, 100% { opacity: 0.2; }
    30% { opacity: 1; }
}

/* ========== SETTINGS EXTRAS ========== */
.settings-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 4px;
}

.setting-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    margin: -4px 0 4px;
}

select.input-field {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239090a8' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: calc(20px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    font-size: 14px;
    transition: transform 0.25s ease;
    z-index: 3000;
    text-align: center;
    max-width: calc(100vw - 40px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ========== RESPONSIVE ========== */

/* Mobile (default) */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 85vw;
        max-width: 340px;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .btn-back { display: flex; }

    .chat-header { padding: 8px; }

    .modal { align-items: flex-end; }
    .modal-content {
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-width: 100%;
    }

    .message { max-width: 90%; }
    .file-preview-img { max-width: 200px; }
    .file-preview-video { max-width: 220px; }

    /* Mostrar sidebar por defecto cuando no hay chat activo */
    .chat-layout:not(.has-active-chat) .sidebar {
        transform: translateX(0);
    }
    .chat-layout:not(.has-active-chat) .sidebar-overlay {
        display: block;
        background: transparent;
    }
}

/* Tablet y Desktop */
@media (min-width: 769px) {
    .sidebar {
        position: relative;
        transform: none;
        transition: width 0.25s ease, min-width 0.25s ease;
    }

    .sidebar-overlay { display: none !important; }
    .btn-back { display: flex; }

    .chat-layout.sidebar-collapsed .sidebar {
        width: 0;
        min-width: 0;
        overflow: hidden;
        border-right: none;
    }

    .modal { align-items: center; }
    .modal-content {
        border-radius: var(--radius-lg);
        max-width: 440px;
    }
}

/* Large desktop */
@media (min-width: 1200px) {
    .sidebar { width: 360px; min-width: 360px; }
}
