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

:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --accent: #3b82f6;
    --green: #22c55e;
    --red: #ef4444;
    --amber: #f59e0b;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.screen { display: none; height: 100vh; height: 100dvh; }
.screen.active { display: flex; }

/* ===== RINGING SCREEN ===== */

#screen-ringing {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px 20px;
}

.ring-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 8px;
}

.ring-avatar {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    font-weight: 700;
    color: white;
    z-index: 2;
}

.ring-pulse {
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 2px solid var(--green);
    opacity: 0;
    animation: ring-expand 2s ease-out infinite;
}
.ring-pulse-2 { animation-delay: 1s; }

@keyframes ring-expand {
    0% { inset: 0; opacity: 0.6; }
    100% { inset: -40px; opacity: 0; }
}

.ring-name { font-size: 28px; font-weight: 600; }
.ring-phone { font-size: 16px; color: var(--muted); }
.ring-label { font-size: 14px; color: var(--green); animation: pulse-text 2s ease-in-out infinite; }

@keyframes pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.ring-docs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 400px;
    margin-top: 8px;
}

.ring-doc-chip {
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 16px;
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.ring-actions {
    display: flex;
    gap: 48px;
    margin-top: 24px;
}

.ring-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, filter 0.15s;
}
.ring-btn:hover { transform: scale(1.1); }
.ring-btn:active { transform: scale(0.95); }

.ring-decline { background: var(--red); color: white; }
.ring-answer {
    background: var(--green);
    color: white;
    animation: pulse-answer 1.5s ease-in-out infinite;
}

@keyframes pulse-answer {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50% { box-shadow: 0 0 0 16px rgba(34, 197, 94, 0); }
}

.ring-error { color: var(--red); font-size: 14px; margin-top: 12px; }

/* ===== CONNECTED SCREEN ===== */

#screen-connected {
    flex-direction: column;
}

.call-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 8px; flex: 1; }
.call-partner-name { font-size: 16px; font-weight: 600; }
.call-timer {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 18px;
    color: var(--amber);
    font-variant-numeric: tabular-nums;
}

.lang-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}
.lang-en { background: #1e3a5f; color: #60a5fa; }
.lang-ru { background: #3b1f2b; color: #f472b6; }
.lang-ka { background: #3b1f1f; color: #fca5a5; }
.lang-el { background: #1e3a5f; color: #93c5fd; }

/* Chat area */

.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.chat-area::-webkit-scrollbar { width: 6px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.message {
    padding: 12px 16px;
    border-radius: 16px;
    max-width: 80%;
    word-wrap: break-word;
}
.message-bot {
    background: var(--surface);
    align-self: flex-start;
    border: 1px solid var(--border);
}
.message-user {
    background: #1e3a5f;
    align-self: flex-end;
    border: 1px solid #2563eb;
}
.message-text { font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.message-timing { font-size: 11px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.message-interrupted { font-size: 11px; color: var(--amber); margin-top: 4px; font-style: italic; }

/* Waveform bars */
.waveform {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 20px;
    margin-top: 8px;
}
.waveform-bar {
    width: 3px;
    background: var(--accent);
    border-radius: 2px;
    transition: height 0.1s ease;
    min-height: 3px;
}

/* Replay button */
.replay-btn {
    display: inline-flex;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px 10px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 6px;
    color: var(--muted);
    transition: all 0.15s;
}
.replay-btn:hover { border-color: var(--accent); color: var(--text); }

/* Footer */
.call-footer {
    padding: 16px 20px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    text-align: center;
    flex-shrink: 0;
}
.call-status { font-size: 13px; color: var(--muted); margin-bottom: 12px; min-height: 16px; }
.call-status.listening { color: var(--green); }
.call-status.speaking { color: var(--accent); }
.call-status.recording { color: var(--red); }

.call-controls { display: flex; justify-content: center; gap: 16px; }

.btn-end-call {
    padding: 10px 32px;
    background: var(--red);
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.btn-end-call:hover { opacity: 0.85; }
.btn-end-call:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== ENDED SCREEN ===== */

#screen-ended {
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ended-card {
    background: var(--surface);
    border: 2px solid var(--accent);
    border-radius: 16px;
    padding: 32px;
    max-width: 500px;
    width: 100%;
    text-align: center;
}
.ended-card h2 { margin-bottom: 16px; }
.ended-card p { margin-bottom: 8px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.ended-card .outcome-label {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}
.outcome-completed { background: #166534; color: #4ade80; }
.outcome-promised { background: #854d0e; color: #fbbf24; }
.outcome-refused { background: #991b1b; color: #fca5a5; }
.outcome-no_answer { background: #374151; color: #9ca3af; }
.outcome-escalated { background: #7c2d12; color: #fb923c; }

.btn-close {
    margin-top: 20px;
    padding: 10px 28px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}
.btn-close:hover { opacity: 0.85; }

/* ===== MODAL ===== */

.modal {
    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(--surface);
    border-radius: 16px;
    padding: 32px;
    max-width: 480px;
    width: 90%;
}
.modal-content h2 { margin-bottom: 8px; }
.modal-content p { color: var(--muted); margin-bottom: 16px; }
.outcome-buttons { display: flex; flex-direction: column; gap: 8px; }
.outcome-btn {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
    text-align: left;
    transition: filter 0.15s;
}
.outcome-btn.completed { background: #166534; color: white; }
.outcome-btn.promised { background: #854d0e; color: white; }
.outcome-btn.refused { background: #991b1b; color: white; }
.outcome-btn.no-answer { background: #374151; color: white; }
.outcome-btn:hover { filter: brightness(1.2); }
.cancel-btn {
    margin-top: 12px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid #475569;
    color: var(--muted);
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
}
.cancel-btn:hover { border-color: var(--muted); color: var(--text); }
.hidden { display: none !important; }

/* ===== HEALTH DOT ===== */

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--green); }
.dot-error { background: var(--red); }
.dot-unknown { background: var(--muted); }

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

@media (max-width: 600px) {
    .message { max-width: 90%; }
    .ring-name { font-size: 22px; }
    .ring-actions { gap: 32px; }
}
