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

:root {
    --primary-color: #4CAF50;
    --primary-dark: #388E3C;
    --secondary-color: #2196F3;
    --danger-color: #f44336;
    --text-primary: #212121;
    --text-secondary: #757575;
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-dark: #1a1a1a;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Container */
.container {
    width: 100%;
    max-width: 900px;
    background: var(--bg-primary);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    overflow: visible;
    display: flex;
    flex-direction: column;
    height: auto;
    max-height: none;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 20px 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.robot-icon {
    font-size: 32px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.logo h1 {
    font-size: 24px;
    font-weight: 600;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.2);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-badge.recording .status-dot {
    background: var(--danger-color);
    animation: blink 0.5s ease-in-out infinite;
}

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

.settings-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.3s;
}

.settings-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: rotate(45deg);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Robot Visualization */
.robot-visualization {
    padding: 20px;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.robot-face {
    width: 120px;
    height: 120px;
    background: white;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    box-shadow: var(--shadow);
    position: relative;
    z-index: 2;
}

.robot-eyes {
    display: flex;
    gap: 25px;
}

.eye {
    width: 20px;
    height: 20px;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.pupil {
    width: 8px;
    height: 8px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: all 0.3s;
}

.robot-mouth {
    width: 60px;
    height: 25px;
}

.robot-mouth svg {
    width: 100%;
    height: 100%;
}

.robot-face.talking .pupil {
    transform: scale(1.2);
}

.robot-face.talking #mouthPath {
    animation: talk 0.3s ease-in-out infinite;
}

@keyframes talk {
    0%, 100% { d: path("M 10 15 Q 50 15 90 15"); }
    50% { d: path("M 10 10 Q 50 20 90 10"); }
}

.sound-waves {
    position: absolute;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s;
}

.sound-waves.active {
    opacity: 1;
}

.wave {
    width: 4px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 2px;
    animation: wave 0.8s ease-in-out infinite;
}

.wave:nth-child(2) { animation-delay: 0.1s; }
.wave:nth-child(3) { animation-delay: 0.2s; }
.wave:nth-child(4) { animation-delay: 0.3s; }

@keyframes wave {
    0%, 100% { height: 20px; }
    50% { height: 40px; }
}

/* Conversation */
.conversation-container {
    flex: 1;
    overflow: hidden;
    background: white;
    min-height: 250px;
    max-height: 60vh;
}

.conversation-scroll {
    height: 100%;
    overflow-y: auto;
    padding: 20px;
}

.conversation {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.robot-icon-large {
    font-size: 64px;
    margin-bottom: 20px;
}

.welcome-message h2 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 28px;
}

.message {
    display: flex;
    gap: 12px;
    animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

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

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

.message-content {
    flex: 1;
    max-width: 85%;
}

.message-bubble {
    padding: 14px 18px;
    border-radius: 18px;
    margin-bottom: 6px;
    word-wrap: break-word;
    font-size: 15px;
    line-height: 1.5;
}

.message.user .message-bubble {
    background: var(--secondary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.bot .message-bubble {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 0 8px;
}

.message.user .message-meta {
    justify-content: flex-end;
}

.play-button {
    background: var(--primary-color);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.play-button:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.5);
}

.play-button.playing {
    background: var(--secondary-color);
    animation: pulse 1.5s ease-in-out infinite;
}

.play-button.pulse {
    animation: attention 0.5s ease-in-out 3;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes attention {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
    }
    50% { 
        transform: scale(1.2);
        box-shadow: 0 4px 16px rgba(76, 175, 80, 0.8);
    }
}

.tech-details {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    padding: 8px;
    background: rgba(0,0,0,0.03);
    border-radius: 8px;
    font-family: 'Courier New', monospace;
}

/* Control Panel */
.control-panel {
    padding: 20px 30px;
    background: white;
    border-top: 2px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    flex-shrink: 0;
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
}

.recording-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-size: 14px;
    color: var(--text-secondary);
}

.recording-timer {
    font-family: 'Courier New', monospace;
    font-weight: bold;
}

.mic-button {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
    flex-shrink: 0;
}

.mic-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.mic-button:active {
    transform: scale(0.95);
}

.mic-button.recording {
    background: var(--danger-color);
    animation: recordingPulse 1.5s ease-in-out infinite;
}

@keyframes recordingPulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(244, 67, 54, 0.3); }
    50% { box-shadow: 0 4px 32px rgba(244, 67, 54, 0.6); }
}

.mic-icon {
    font-size: 40px;
    line-height: 1;
}

.mic-text {
    position: absolute;
    bottom: -30px;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.quick-actions {
    display: flex;
    gap: 12px;
}

.action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
}

.action-btn:hover {
    background: var(--bg-secondary);
    transform: scale(1.1);
}

/* Stats Panel */
.stats-panel {
    display: flex;
    justify-content: space-around;
    padding: 15px 30px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.stat-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.quality-bar {
    width: 60px;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.quality-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--danger-color) 0%, var(--primary-color) 100%);
    transition: width 0.3s;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 20px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: all 0.3s;
}

.close-btn:hover {
    background: var(--bg-secondary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 500;
}

.setting-item select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.95);
    z-index: 999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: var(--text-primary);
    font-size: 16px;
}

/* Scrollbar */
.conversation-scroll::-webkit-scrollbar {
    width: 8px;
}

.conversation-scroll::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.conversation-scroll::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.conversation-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }

    .header {
        padding: 15px 20px;
    }

    .logo h1 {
        font-size: 20px;
    }

    .message-content {
        max-width: 85%;
    }

    .stats-panel {
        padding: 10px 15px;
    }

    .stat-label {
        font-size: 10px;
    }

    .stat-value {
        font-size: 14px;
    }
}
