/* ═══════════════════════════════════════════
   DECENTRALCHAT — SHARED STYLES
   Reset, fonts, variables, modal, call overlay
   ═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@300;400;500;600;700&display=swap');

/* === GLOBAL RESET === */
* { margin: 0; padding: 0; box-sizing: border-box; }

::selection {
    background: var(--selection-bg, rgba(0, 229, 255, 0.3));
    color: var(--selection-fg, #fff);
}

:focus-visible {
    outline: 2px dotted var(--accent, #00e5ff);
    outline-offset: 2px;
}

html, body {
    font-family: 'IBM Plex Mono', 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    background: var(--bg-primary, #0a0a0f);
    color: var(--text-primary, #d4d4d8);
    height: 100vh;
    overflow: hidden;
    letter-spacing: 0.3px;
    font-size: 13px;
}

.hidden { display: none !important; }
.muted { color: var(--text-secondary); }

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* === MODE SELECTOR === */
#mode-selector {
    position: fixed;
    inset: 0;
    background: #0a0a0f;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    gap: 48px;
}

.mode-selector-title {
    text-align: center;
}

.mode-selector-title h1 {
    font-size: 32px;
    font-weight: 700;
    color: #00e5ff;
    letter-spacing: 6px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.mode-selector-title p {
    font-size: 12px;
    color: #71717a;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.mode-cards {
    display: flex;
    gap: 32px;
}

.mode-card {
    width: 320px;
    padding: 32px;
    background: #12121a;
    border: 2px solid #2a2a3a;
    border-radius: 2px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    text-align: center;
}

.mode-card:hover {
    border-color: #00e5ff;
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.15);
}

.mode-card h2 {
    font-size: 18px;
    color: #00e5ff;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 16px;
}

.mode-card-preview {
    height: 140px;
    background: #0a0a0f;
    border: 1px solid #2a2a3a;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #71717a;
    font-size: 11px;
    overflow: hidden;
}

.mode-card p {
    font-size: 11px;
    color: #71717a;
    line-height: 1.6;
}

/* Classic preview ASCII */
.preview-classic {
    font-size: 9px;
    line-height: 1.3;
    text-align: left;
    padding: 8px;
    white-space: pre;
    color: #4a4a5a;
}

/* Ambient preview canvas */
.preview-ambient {
    width: 100%;
    height: 100%;
}

/* === SHARED FORM ELEMENTS === */
label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

input[type="text"], input[type="password"], textarea {
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 2px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    font-family: inherit;
    letter-spacing: 0.3px;
}

input:focus, textarea:focus { border-color: var(--accent); }

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

/* === SHARED BUTTONS === */
.btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
    border: 2px solid var(--accent);
    padding: 10px 20px;
    border-radius: 2px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-tab {
    flex: 1;
    background: var(--bg-tertiary);
    color: var(--muted);
    border: 2px solid var(--border);
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.btn-tab.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}
.btn-tab:hover:not(.active) { opacity: 0.8; }

.input-field {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border);
    padding: 10px 12px;
    border-radius: 2px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}
.input-field:focus {
    border-color: var(--accent);
}
.input-field::placeholder {
    color: var(--muted);
}

.btn-small {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border);
    padding: 6px 14px;
    border-radius: 2px;
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.btn-small:hover { background: var(--bg-hover); border-color: var(--accent); }

.btn-danger {
    background: var(--error);
    color: white;
    border: 2px solid var(--error);
    padding: 10px 20px;
    border-radius: 2px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.error-msg { color: var(--error); font-size: 12px; margin-top: 8px; min-height: 20px; }

/* === MODAL OVERLAY === */
#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#modal-content {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 2px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 4px 4px 0 var(--shadow-color);
}

#modal-content h3 {
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 14px;
}

/* === CALL OVERLAY === */
#call-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 90;
}

.call-incoming, .call-active.call-audio {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.call-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 2px;
    background: var(--bg-tertiary, #1a1a26);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 32px;
    color: var(--accent, #00e5ff);
    border: 2px solid var(--accent, #00e5ff);
}

.call-peer-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary, #d4d4d8);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.call-status {
    font-size: 12px;
    color: var(--text-secondary, #71717a);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.call-actions {
    display: flex;
    gap: 16px;
    margin-top: 16px;
}

.call-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 2px;
    border: 2px solid transparent;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    color: white;
    background: var(--bg-tertiary, #1a1a26);
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.call-btn:hover { opacity: 0.85; }
.call-btn-accept { background: var(--success, #10b981); border-color: var(--success, #10b981); }
.call-btn-reject { background: var(--error, #ef4444); border-color: var(--error, #ef4444); }
.call-btn-active { background: var(--accent, #00e5ff); color: var(--bg-primary, #0a0a0f); border-color: var(--accent, #00e5ff); }

.call-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
}

.call-control-bar {
    display: flex;
    gap: 12px;
    align-items: center;
}

.call-timer {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: 2px;
}

.call-active.call-video {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.call-video #remote-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.call-video #local-video {
    position: absolute;
    bottom: 100px;
    right: 24px;
    width: 180px;
    height: 135px;
    border-radius: 2px;
    object-fit: cover;
    border: 2px solid var(--border);
    background: #000;
    z-index: 2;
}

.call-video .call-controls {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    background: rgba(0, 0, 0, 0.7);
    padding: 12px 24px;
    border-radius: 2px;
    border: 1px solid var(--border);
}

.call-audio-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* === ANIMATIONS === */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* === RESPONSIVE === */
@media (max-width: 600px) {
    .mode-cards { flex-direction: column; }
    .mode-card { width: 280px; }
}
