/* ═══════════════════════════════════════════════
   One-Device Mode — Completely isolated styles
   ═══════════════════════════════════════════════ */

/* ─── Mode Tabs (Landing screen) ─── */
.mode-tabs {
    display: flex;
    background: var(--bg-card);
    border-radius: 14px;
    padding: 4px;
    margin-bottom: 20px;
    border: 1.5px solid var(--border);
    gap: 4px;
}

.mode-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 12px;
    border: none;
    border-radius: 11px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    touch-action: manipulation;
}

.mode-tab .tab-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.mode-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 2px 12px rgba(79, 70, 229, 0.35);
}

.mode-tab:not(.active):hover {
    background: rgba(255,255,255,0.05);
    color: var(--text);
}

/* ─── One-Device Conversation Screen ─── */
#od-screen-conv {
    display: none;
    flex-direction: column;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    padding: 0;
    max-width: 100%;
    width: 100%;
    animation: fadeIn 0.3s ease;
}

#od-screen-conv.active {
    display: flex;
}

/* ─── Split View Container ─── */
.od-split-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* ─── Chat Half (User 1 / User 2) ─── */
.od-chat-half {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    transition: flex 0.35s ease, opacity 0.3s ease, max-height 0.35s ease;
    position: relative;
}

/* Top half (User 2) — rotated 180° so opposite user can read */
.od-chat-top {
    transform: rotate(180deg);
    border-bottom: 1px solid var(--border);
}

.od-chat-half.hidden {
    flex: 0;
    min-height: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.od-chat-half.fullscreen {
    flex: 1;
}

/* Chat Half Header */
.od-chat-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.od-chat-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.od-chat-header .od-user-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
}

.od-chat-header .od-lang-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 3px 10px;
    border-radius: 12px;
}

.od-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.od-user-avatar.user1 {
    background: linear-gradient(135deg, #6366F1, #4F46E5);
}

.od-user-avatar.user2 {
    background: linear-gradient(135deg, #10B981, #059669);
}

/* Active indicator on chat header */
.od-chat-header.active-speaker {
    background: rgba(79, 70, 229, 0.08);
    border-bottom-color: var(--primary-light);
}

.od-chat-header.active-speaker .od-active-dot {
    display: block;
}

.od-active-dot {
    display: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--secondary);
    animation: pulse 1.5s infinite;
    flex-shrink: 0;
}

/* Toggle visibility button (only on bottom/User 1) */
.od-toggle-view-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.od-toggle-view-btn:hover {
    background: var(--bg-input);
}

/* Chat Messages Area */
.od-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* ─── Message Bubble (One-Device) ─── */
.od-msg {
    padding: 10px 14px;
    border-radius: 14px;
    animation: slideUp 0.2s ease;
    word-wrap: break-word;
    max-width: 85%;
    width: fit-content;
}

.od-msg .od-msg-translated {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.5;
    color: var(--text);
}

.od-msg .od-msg-original {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
}

/* Own speech — right side */
.od-msg.own {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 14px 14px 4px 14px;
    align-self: flex-end;
}

/* Received translation — left side */
.od-msg.received {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 14px 14px 14px 4px;
    align-self: flex-start;
}

/* ─── Center Toggle Button (between chatboxes) ─── */
.od-toggle-area {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    transition: opacity 0.3s ease, max-height 0.3s ease;
    position: relative;
    z-index: 10;
}

.od-toggle-area.hidden {
    max-height: 0;
    padding: 0;
    border: none;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.od-toggle-btn {
    width: 100%;
    max-width: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 20px;
    border: 2px solid var(--primary-light);
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(79, 70, 229, 0.04));
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    touch-action: manipulation;
    position: relative;
    overflow: hidden;
}

.od-toggle-btn:active {
    transform: scale(0.97);
}

.od-toggle-btn.user1-active {
    border-color: #6366F1;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(99, 102, 241, 0.05));
}

.od-toggle-btn.user2-active {
    border-color: #10B981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05));
}

.od-toggle-arrow {
    font-size: 1.6rem;
    line-height: 1;
}

.od-toggle-flag {
    font-size: 1.3rem;
    line-height: 1;
}

.od-toggle-lang {
    font-size: 0.85rem;
    font-weight: 600;
}

/* Listening indicator on toggle */
.od-toggle-btn.listening {
    animation: odTogglePulse 1.8s infinite;
}

@keyframes odTogglePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.3); }
    50% { box-shadow: 0 0 0 10px rgba(79, 70, 229, 0); }
}

.od-toggle-btn.user2-active.listening {
    animation: odTogglePulseGreen 1.8s infinite;
}

@keyframes odTogglePulseGreen {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.3); }
    50% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
}

/* ─── Controls Bar (One-Device) ─── */
.od-controls {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg);
    border-top: 1px solid var(--border);
}

.od-ctrl-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.2rem;
    touch-action: manipulation;
}

.od-ctrl-btn:active {
    transform: scale(0.92);
}

.od-ctrl-btn.tts {
    background: var(--bg-card);
    color: var(--primary-light);
    border: 1.5px solid var(--border);
}

.od-ctrl-btn.tts.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.od-ctrl-btn.end {
    background: var(--danger);
    color: white;
}

.od-ctrl-btn.mic {
    background: var(--secondary);
    color: white;
    width: 56px;
    height: 56px;
    font-size: 1.4rem;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
}

.od-ctrl-btn.mic.listening {
    animation: micPulse 1.5s infinite;
}

.od-ctrl-btn.mic.muted {
    background: var(--danger);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}

/* ─── Status line ─── */
.od-status {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg);
}

.od-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--secondary);
    animation: pulse 2s infinite;
}

.od-status-dot.paused {
    background: var(--warning);
    animation: none;
}

/* ─── Empty state in chat ─── */
.od-empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 20px;
    opacity: 0.6;
}

/* ─── Interim preview in one-device ─── */
.od-interim {
    padding: 8px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    opacity: 0.6;
    font-style: italic;
    animation: fadeIn 0.15s ease;
    word-wrap: break-word;
    max-width: 85%;
    width: fit-content;
}

.od-interim.own {
    background: rgba(99, 102, 241, 0.08);
    color: var(--text);
    align-self: flex-end;
}

.od-interim.received {
    background: rgba(16, 185, 129, 0.08);
    color: var(--text);
    align-self: flex-start;
}

/* ─── Landing mode content containers ─── */
.landing-mode-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    animation: fadeIn 0.25s ease;
}

/* ─── Chatbox border flash on switch (2 blinks) ─── */
@keyframes odFlash {
    0%   { box-shadow: inset 0 0 0 2px var(--primary-light); }
    25%  { box-shadow: inset 0 0 0 0px transparent; }
    50%  { box-shadow: inset 0 0 0 2px var(--primary-light); }
    75%  { box-shadow: inset 0 0 0 0px transparent; }
    100% { box-shadow: none; }
}

.od-chat-half.od-flash {
    animation: odFlash 0.6s ease;
}

/* ─── Toggle row (button + checkbox side by side) ─── */
.od-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 420px;
}

.od-toggle-row .od-toggle-btn {
    flex: 1;
    min-width: 0;
}

/* ─── Auto-switch checkbox ─── */
.od-auto-switch-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    position: relative;
    z-index: 20;
}

.od-auto-switch-wrap input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
    padding: 0 !important;
    margin: 0;
    background: none !important;
    border: none !important;
    accent-color: var(--primary);
    cursor: pointer;
    pointer-events: auto;
    -webkit-appearance: checkbox !important;
    appearance: checkbox !important;
}

.od-auto-switch-wrap label {
    font-size: 0.65rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    pointer-events: auto;
}

/* ─── Responsive ─── */
@media (min-width: 481px) {
    .od-toggle-btn {
        max-width: 420px;
    }
}
