:root {
    --primary: #10b981;
    --primary-hover: #059669;
    --bg-dark: #0f172a; /* Darkest (Header) */
    --bg-card: #1e293b; /* Lighter (Content) */
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --danger-hover: #dc2626;
}

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

body {
    background-color: var(--bg-card); /* Lighter background for body/content */
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    height: 100vh;
    width: 100vw;
    margin: 0;
    overflow: hidden; /* Prevent body scroll */
}

.app-container {
    width: 100%;
    height: 100%;
    background-color: var(--bg-card); /* Match body */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.app-header {
    padding: 16px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.85); /* Darker Header with Glass */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    flex-shrink: 0;
    position: fixed; /* Fixed to viewport */
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2); /* Stronger shadow */
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.call-timer {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: 600;
}

.language-select {
    background-color: var(--bg-dark);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s ease;
}

.language-select:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.language-select:focus {
    border-color: var(--primary);
}

.language-select option {
    background-color: var(--bg-card);
    color: var(--text-main);
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #64748b; /* Grey for disconnected/idle */
    transition: all 0.3s ease;
}

.status-dot.connected {
    background-color: var(--primary);
    box-shadow: 0 0 8px var(--primary);
}

.status-dot.disconnected {
    background-color: var(--danger);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo i {
    font-size: 32px; /* Larger Icon */
    color: var(--primary);
    filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.4));
}

.logo h1 {
    font-size: 1.5rem; /* Larger Text */
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Chat Interface */
.chat-interface {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    /* No margin-top, allow full height */
}

.transcription-feed {
    flex: 1;
    overflow-y: auto;
    padding: 100px 20px 140px 20px; /* Top for header, Bottom for controls space */
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 900px; /* Constrain content width */
    margin: 0 auto; /* Center the feed */
}

.message {
    display: flex;
    gap: 12px;
    width: 100%;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-out;
    align-items: flex-start;
}

/* Voice Controls - Fixed Bottom */
.voice-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    background: linear-gradient(to top, var(--bg-card) 80%, transparent); /* Match content background */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 20;
}

/* Constrain control width too */
.input-area, .control-buttons {
    width: 100%;
    max-width: 600px;
}

.footer-links {
    display: flex;
    gap: 16px;
    margin-top: 12px;
}

.footer-links a {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.copyright {
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.5;
    margin-top: 8px;
}

.message.user {
    flex-direction: row-reverse;
}

.message .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-top: 2px; /* Visual alignment with first line of text */
}

.message.agent .avatar {
    background: #334155;
    color: #38bdf8;
}

.message.system .avatar { /* Mapped from agent in JS */
    background: #334155;
    color: #38bdf8;
}

.message.user .avatar {
    background: var(--primary);
    color: white;
}

.message .content {
    max-width: 70%; /* Slightly narrower for better reading */
    padding: 14px 20px; /* More breathing room */
    border-radius: 22px;
    font-size: 1.05rem; /* Slightly larger text */
    line-height: 1.6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); /* Softer shadow */
    position: relative;
    word-wrap: break-word;
    text-align: left !important;
}

.message.system .content {
    background: #1e293b;
    color: #e2e8f0;
    border-top-left-radius: 4px;
    border: 1px solid rgba(255,255,255,0.05);
}

.message.user .content {
    background: var(--primary);
    color: white;
    border-top-right-radius: 4px;
}

/* Welcome / UI Notification Style */
.message.welcome {
    align-self: center;
    justify-content: center;
    width: 100%;
    margin: 24px 0;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.message.welcome .avatar {
    width: 40px;
    height: 40px;
    font-size: 24px;
    background: transparent;
    color: var(--text-muted);
    box-shadow: none;
}

.message.welcome .content {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    text-align: center !important; /* Force Center for Welcome */
    padding: 0;
    box-shadow: none;
    border: none;
    max-width: 90%;
}

.language-line {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 8px;
    min-height: 1.2em;
    font-weight: 500;
}

.typewriter-text {
    color: var(--primary);
    font-weight: 700;
    border-bottom: 2px solid var(--primary); /* Underline effect */
    padding-bottom: 2px;
}

.message.system {
    align-self: center;
    max-width: 100%;
    margin: 10px 0;
}

.message.system .content {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
    padding: 0;
}

.message.system .avatar {
    display: none;
}

/* Old Voice Controls Block Removed/Superseded */

/* Visualizer Bars */
.visualizer-container {
    flex: 1; 
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    max-width: 120px;
    margin: 0 auto;
    opacity: 0;
    transition: opacity 0.3s;
}

.visualizer-container.active {
    opacity: 1;
}

.bar {
    width: 4px;
    background: var(--primary);
    border-radius: 4px;
    height: 6px;
    animation: none;
}

.visualizer-container.active .bar {
    animation: sound 0.8s infinite ease-in-out alternate;
}

@keyframes sound {
    0% { height: 6px; opacity: 0.5; }
    100% { height: 24px; opacity: 1; }
}

.visualizer-container.active .bar:nth-child(1) { animation-delay: 0.0s; }
.visualizer-container.active .bar:nth-child(2) { animation-delay: 0.2s; }
.visualizer-container.active .bar:nth-child(3) { animation-delay: 0.4s; }
.visualizer-container.active .bar:nth-child(4) { animation-delay: 0.1s; }
.visualizer-container.active .bar:nth-child(5) { animation-delay: 0.3s; }

/* Control Buttons (Start Button Wrapper) */
.control-buttons {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.primary-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 100px;
    border: none;
    background: var(--primary);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* INPUT AREA - THE SQUARISH BOX (Buttons Inside & Below) */
.input-area {
    width: 100%;
    display: flex;
    flex-direction: column; /* Stack Input above Buttons */
    gap: 12px;
    background: rgba(255, 255, 255, 0.08); /* Visible Box */
    padding: 12px;
    border-radius: 20px; /* Squarish corners */
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    margin-bottom: 0;
}

.input-area:focus-within {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
}

.input-area input {
    width: 100%;
    background: transparent; /* Transparent inside the box */
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1); /* Separator line */
    border-radius: 0;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    padding: 8px 4px;
    outline: none;
    transition: all 0.2s;
}

.input-area input:focus {
    background: transparent;
    border-bottom-color: rgba(255, 255, 255, 0.3);
}

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

.action-row {
    display: flex;
    align-items: center;
    justify-content: space-between; /* Spread Left Group vs Right Button */
    width: 100%;
    padding: 0 4px;
}

.left-actions {
    display: flex;
    gap: 12px; /* Space between Mic and Stop */
}

/* Modern Neat Icons */
.input-area .icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px; /* Squarish buttons matching box */
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 20px;
}

.input-area .icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.input-area .icon-btn.primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.input-area .icon-btn.primary:hover {
    background: var(--primary-hover);
}

.input-area .icon-btn.danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.input-area .icon-btn.danger:hover {
    background: var(--danger);
    color: white;
}

.hidden {
    display: none !important;
}

/* Scrollbar */
.transcription-feed::-webkit-scrollbar {
    width: 6px;
}

.transcription-feed::-webkit-scrollbar-track {
    background: transparent;
}

.transcription-feed::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.status-dot.speaking { background-color: #f59e0b; box-shadow: 0 0 8px #f59e0b; }
