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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: #333;
}

/* ===== LAYOUT COMPONENTS ===== */
.container {
    width: 100%;
    height: 100vh;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.main-content {
    display: flex;
    flex: 1;
    gap: 15px;
    min-height: 0;
}

.left-panel {
    flex: 2;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Page-specific layout: Control and Speaker want 25% mic controls (left) / 75% group chat (right) */
.page-control .left-panel,
.page-speaker .left-panel {
    flex: 1;
}

.page-control .right-panel,
.page-speaker .right-panel {
    flex: 3;
}

/* ===== HEADER COMPONENTS ===== */
.header {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 15px;
    text-align: center;
}

.header h1 {
    color: #333;
    font-size: 2rem;
    margin-bottom: 5px;
}

.header p {
    color: #666;
    font-size: 1rem;
}

/* ===== NAVIGATION COMPONENTS ===== */
.nav {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.nav a {
    background: #007bff;
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 20px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.nav a:hover {
    background: #0056b3;
    transform: translateY(-2px);
}

.nav a.active {
    background: #28a745;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

/* ===== CARD COMPONENTS ===== */
.form-card {
    background: #ffffff;
    padding: 20px;
    border-radius: 12px;
    color: #333;
    border: 1px solid #e9ecef;
    text-align: left;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    gap: 10px;
}

/* legacy alias if used elsewhere */
.control-card { text-align: left; }

.form-card h3 { text-align: center; }

.translation-history {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* allow inner chat to scroll without expanding container */
}

.translation-history h3 {
    color: #333;
    font-size: 1.1rem;
    margin-bottom: 12px;
    text-align: center;
}

/* ===== BUTTON COMPONENTS ===== */
.mic-button {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(45deg, #007bff, #0056b3);
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 15px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    margin-right: auto;
}

.mic-button:hover {
    transform: scale(1.1);
    box-shadow: 0 10px 25px rgba(0, 123, 255, 0.3);
}

.mic-button.listening {
    background: linear-gradient(45deg, #ff4757, #ff3838);
    animation: pulse 1.5s infinite;
    box-shadow: 0 0 20px rgba(255, 71, 87, 0.6);
}

.btn {
    background: linear-gradient(45deg, #007bff, #0056b3);
    color: white;
    text-decoration: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 123, 255, 0.3);
}

.btn.control {
    background: linear-gradient(45deg, #28a745, #20c997);
}

.btn.display {
    background: linear-gradient(45deg, #ffc107, #fd7e14);
}

.btn-secondary {
    padding: 6px 10px;
    border: 1px solid #e9ecef;
    background: #ffffff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #333;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #f8f9fa;
    border-color: #007bff;
}

/* ===== STATUS COMPONENTS ===== */
.status {
    margin: 15px 0;
    padding: 12px;
    border-radius: 8px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    font-size: 0.9rem;
}

.status.recording {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.status.translating {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.status.sent {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.connection-status {
    background: #e3f2fd;
    border: 1px solid #2196f3;
    border-radius: 8px;
    padding: 10px;
    margin-top: 15px;
    text-align: center;
}

.connection-status.connected {
    background: #d4edda;
    border-color: #28a745;
}

.connection-status.disconnected {
    background: #f8d7da;
    border-color: #dc3545;
}

/* ===== FORM COMPONENTS ===== */
.language-selector {
    margin: 15px 0;
}

.language-selector select {
    padding: 8px 12px;
    border-radius: 20px;
    border: 1px solid #e9ecef;
    background: #ffffff;
    color: #333;
    font-size: 0.9rem;
    cursor: pointer;
}

.language-selector select option {
    background: #ffffff;
    color: #333;
}

.language-selector input[type="text"] {
    padding: 6px 10px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    width: 200px;
    font-size: 0.9rem;
}

.language-selector input[type="color"] {
    width: 40px;
    height: 28px;
    padding: 0;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
}

/* ===== TRANSCRIPT COMPONENTS ===== */
.transcript {
    margin: 15px 0;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    min-height: 120px;
    text-align: left;
}

.transcript h3 {
    margin-bottom: 8px;
    color: #333;
    font-size: 1rem;
}

.transcript p {
    color: #666;
    line-height: 1.4;
    font-size: 1.1rem;
}

.confidence-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.confidence-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    border: 1px solid #e9ecef;
    background: #ffffff;
    color: #333;
}

.confidence-dot {
    font-size: 0.9rem;
    line-height: 1;
}

/* ===== MESSAGE COMPONENTS ===== */
.error {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 8px;
    margin-top: 12px;
    border: 1px solid #f5c6cb;
    font-size: 0.9rem;
}

.success {
    background: #d4edda;
    color: #155724;
    padding: 12px;
    border-radius: 8px;
    margin-top: 12px;
    border: 1px solid #c3e6cb;
    font-size: 0.9rem;
}

/* ===== HISTORY COMPONENTS ===== */
.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    border-left: 3px solid #007bff;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.history-item:nth-child(1) {
    background: #1565c0;
    border-left-color: #0d47a1;
    color: white;
}

.history-item:nth-child(1) .history-original,
.history-item:nth-child(1) .history-translation,
.history-item:nth-child(1) .history-timestamp {
    color: white;
}

.history-item:nth-child(2) {
    background: #1976d2;
    border-left-color: #1565c0;
    color: white;
}

.history-item:nth-child(2) .history-original,
.history-item:nth-child(2) .history-translation,
.history-item:nth-child(2) .history-timestamp {
    color: white;
}

.history-item:nth-child(3) {
    background: #42a5f5;
    border-left-color: #1976d2;
    color: white;
}

.history-item:nth-child(3) .history-original,
.history-item:nth-child(3) .history-translation,
.history-item:nth-child(3) .history-timestamp {
    color: white;
}

.history-item:nth-child(4) {
    background: #90caf9;
    border-left-color: #42a5f5;
    color: #333;
}

.history-item:nth-child(5) {
    background: #bbdefb;
    border-left-color: #90caf9;
    color: #333;
}

.history-item:nth-child(6) {
    background: #e3f2fd;
    border-left-color: #bbdefb;
    color: #333;
}

.history-item:nth-child(n+7) {
    background: #f8f9fa;
    border-left-color: #6c757d;
}

.history-item:hover {
    background: #e9ecef;
    transform: translateX(3px);
}

.history-original {
    font-size: 1rem;
    color: #666;
    margin-bottom: 4px;
    font-style: italic;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.history-translation {
    font-size: 1.2rem;
    color: #333;
    font-weight: 500;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.2;
}

.history-timestamp {
    font-size: 0.7rem;
    color: #999;
    margin-top: 4px;
}

/* ===== CHAT COMPONENTS ===== */
.chat-feed {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.chat-item {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.04);
}

/* Tinted chat background from speaker color (fallback: white). 
   Use 5% of the speaker color mixed with white to approximate 95% transparency. */
.chat-item {
    background: color-mix(in srgb, var(--speaker-color, #ffffff) 5%, #ffffff);
}

.chat-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.chat-avatar {
    font-size: 1.1rem;
}

.chat-name {
    font-weight: 600;
}

.chat-time {
    margin-left: auto;
    color: #777;
    font-size: 0.8rem;
}

.chat-conf-inline {
    margin-left: 8px;
    color: #333;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.chat-text {
    font-size: 1rem;
    color: #111;
}

.chat-original {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
    margin-top: 4px;
}

.chat-interim {
    opacity: 0.7;
}

.chat-confidence {
    margin-top: 6px;
    font-size: 0.85rem;
    color: #333;
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    display: inline-block;
    animation: typingBlink 1.2s infinite both;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* ===== ANIMATIONS ===== */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes typingBlink {
    0% { opacity: 0.25; }
    20% { opacity: 1; }
    100% { opacity: 0.25; }
}

/* ===== LANDING PAGE SPECIFIC STYLES ===== */
.landing-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    align-items: center;
    justify-content: center;
}

.landing-page .container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    max-width: 500px;
    width: 90%;
    height: auto;
}

.landing-page .header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.landing-page .header p {
    font-size: 1.1rem;
}

.buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.status-info {
    margin-top: 30px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
}

.status-info h3 {
    color: #333;
    margin-bottom: 10px;
}

.status-info p {
    color: #666;
    font-size: 0.9rem;
}

.socket-info {
    margin-top: 20px;
    padding: 15px;
    background: #e3f2fd;
    border-radius: 10px;
    border: 1px solid #2196f3;
}

.socket-info h3 {
    color: #1976d2;
    margin-bottom: 10px;
}

.socket-info p {
    color: #0d47a1;
    font-size: 0.9rem;
}

/* ===== SESSION CODE STYLES ===== */
.session-code-display {
    font-size: 2rem;
    font-weight: 700;
    color: #0d47a1;
    background: #e3f2fd;
    border: 2px solid #bbdefb;
    border-radius: 12px;
    padding: 6px 12px;
    display: inline-block;
    white-space: nowrap;
}

.session-code-display .code-group {
    margin-right: 12px;
}

.session-code-display .code-group:last-child {
    margin-right: 0;
}

/* ===== UTILITY CLASSES ===== */
.text-center {
    text-align: center;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-6 {
    margin-bottom: 6px;
}

.mb-15 {
    margin-bottom: 15px;
}

.mt-0 {
    margin-top: 0;
}

.mt-6 {
    margin-top: 6px;
}

.mt-10 {
    margin-top: 10px;
}

.mt-15 {
    margin-top: 15px;
}

.ml-auto {
    margin-left: auto;
}

.ml-8 {
    margin-left: 8px;
}

.flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.gap-6 {
    gap: 6px;
}

.gap-8 {
    gap: 8px;
}

.gap-10 {
    gap: 10px;
}

.gap-15 {
    gap: 15px;
}

.gap-16 {
    gap: 16px;
}

.text-sm {
    font-size: 0.9rem;
}

.text-gray-600 {
    color: #666;
}

.hidden {
    display: none;
}

/* ===== DISPLAY PAGE SPECIFIC STYLES ===== */
.streaming-section {
    background: #f5f9ff; /* light color to keep focus without harsh contrast */
    border: 2px solid #cfe2ff;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    position: relative;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex: 0.25;
}

.streaming-section.active {
    border-color: #bee5eb; /* subtle state cue; no layout/color jump */
}

.streaming-section h3 {
    color: #856404;
    font-size: 1rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.streaming-indicator {
    width: 10px;
    height: 10px;
    background: #ffc107;
    border-radius: 50%;
    animation: blink 1s infinite;
}

.streaming-text {
    font-size: 2rem;
    color: #333;
    font-weight: 500;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    hyphens: auto;
    line-height: 1.3;
}

/* Live speech: show original (small italic) + translated (bigger) */
.streaming-original {
    font-size: 1rem;
    color: #666;
    font-style: italic;
    margin-bottom: 8px;
}

.streaming-main {
    font-size: 1.8rem;
    color: #111;
    font-weight: 600;
}

.streaming-section.hidden {
    display: none;
}

.final-translation-section {
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 150px;
}

.confidence-chip {
    margin-top: 6px;
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid #e9ecef;
    background: #ffffff;
    color: #333;
}

.confidence-chip .dot {
    margin-right: 6px;
}

.final-translation-section.hidden {
    display: none;
}

.translation-text {
    font-size: 2.2rem;
    font-weight: bold;
    color: #333;
    text-align: center;
    line-height: 1.3;
    margin-bottom: 15px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    hyphens: auto;
}

.original-text {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 10px;
    font-style: italic;
}

.language-badge {
    background: #007bff;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    color: white;
    margin-top: 8px;
}

.history-section {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* allow inner chat to scroll without expanding container */
}

.history-section h3 {
    color: #333;
    font-size: 1rem;
    margin-bottom: 12px;
    text-align: center;
}

.status-section {
    position: fixed;
    bottom: 15px;
    right: 15px;
    background: rgba(248, 249, 250, 0.9);
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 8px 12px;
    text-align: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: #4CAF50;
}

.status-dot.disconnected {
    background: #f44336;
}

.status-text {
    font-size: 0.9rem;
    color: #333;
}

.waiting-message {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 1.1rem;
    margin-top: 20px;
}

.fullscreen-button {
    position: fixed;
    top: 15px;
    right: 15px;
    background: #007bff;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    z-index: 1001;
    font-size: 0.9rem;
}

.fullscreen-button:hover {
    background: #0056b3;
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .landing-page .container {
        padding: 20px;
        margin: 20px;
    }
    
    .landing-page .header h1 {
        font-size: 2rem;
    }
    
    .buttons {
        gap: 15px;
    }
    
    .btn {
        padding: 12px 24px;
        font-size: 1rem;
    }
}
