:root {
    --bg-color: #f0f2f5;
    --text-color: #333333;
    --primary-color: #1877f2;
    --secondary-color: #e4e6eb;
    --border-color: #dddfe2;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --conversation-bg: #ffffff;
    --ai-message-color: #1877f2;
    --user-message-color: #ffffff;
    --ai-message-bg: #e6f2ff;
    --user-message-bg: #f0f2f5;
    --button-bg: #1877f2;
    --button-text: #ffffff;
    --button-hover: #166fe5;
    --select-bg: #ffffff;
    --select-text: #333333;
}

.dark-mode {
    --bg-color: #121212;
    --text-color: #ffffff;
    --primary-color: #333333;
    --secondary-color: #1e1e1e;
    --border-color: #333333;
    --shadow-color: rgba(255, 255, 255, 0.1);
    --conversation-bg: #1e1e1e;
    --ai-message-color: #25c480;
    --user-message-color: #ffffff;
    --button-bg: #333333;
    --button-text: #ffffff;
    --button-hover: #555555;
    --select-bg: #333333;
    --select-text: #ffffff;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s, color 0.3s;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--secondary-color);
    box-shadow: 0 2px 4px var(--shadow-color);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-controls .main-nav {
    margin-left: 5px;
}

h1 {
    margin: 0;
    font-size: 1.5rem;
    padding-right: 1rem;
    display: flex;
    align-items: center;
}

#mic-icon {
    font-size: 38px; 
    /* cursor: pointer; */
    color: var(--text-color);
    transition: color 0.3s;
    margin-left: 12px; 
}


#mic-icon.mic-on {
    color: red;
}

#mic-icon.mic-off {
    color: inherit;
}


main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

#conversation {
    width: 100%;
    height: 60vh;
    min-height: 350px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    overflow-y: auto;
    background-color: var(--conversation-bg);
    margin-bottom: 1rem;
    box-shadow: 0 0 10px var(--shadow-color);
    box-sizing: border-box;
    position: relative;
}

.ai-message, .user-message {
    margin: 0.5rem 0;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    max-width: 90%;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    line-height: 1.5;
}

.ai-message {
    background-color: var(--secondary-color);
    color: var(--ai-message-color);
    align-self: flex-start;
    margin-left: 15px;
    margin-right: auto;
    border-bottom-left-radius: 4px;
    margin-bottom: 0.5rem;
    width: 100%; /* Increase width to prevent messages stopping short */
}

.user-message {
    background-color: var(--primary-color);
    color: var(--user-message-color);
    align-self: flex-end;
    margin-left: auto;
    margin-right: 55px; /* Add right margin for user messages */
    border-bottom-right-radius: 4px;
    margin-bottom: 0.5rem;
}

/* Style for code blocks */
.ai-message pre, .user-message pre {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 8px 0;
}

.ai-message code, .user-message code {
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.system-message {
    color: #777;
    font-size: 0.9rem;
    text-align: center;
    margin: 0.5rem auto;
    font-style: italic;
    padding: 8px;
    max-width: none;
    width: 90%;
    background-color: transparent; /* Remove background */
    border-radius: 0; /* Remove border radius */
    box-shadow: none; /* Remove shadow */
}

.error-message {
    color: #d9534f;
    padding: 0.5rem;
    margin: 0.5rem auto;
    font-weight: bold;
    max-width: none;
    width: 90%;
    text-align: center;
    background-color: transparent; /* Remove background */
    border-radius: 0; /* Remove border radius */
}

#messages {
    display: flex;
    flex-direction: column;
    padding-bottom: 100px;
}

.controls {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

button {
    padding: 0.5rem 1rem;
    background-color: var(--button-bg);
    color: var(--button-text);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    flex-grow: 1;
    max-width: 200px;
}

button:hover {
    background-color: var(--button-hover);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(1px);
}

.settings {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    width: 100%;
}

.setting-group {
    display: flex;
    flex-direction: column;
}

label {
    margin-bottom: 0.5rem;
}

select {
    padding: 0.5rem;
    background-color: var(--select-bg);
    color: var(--select-text);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 100%;
    transition: border-color 0.3s;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
}

footer {
    background-color: var(--secondary-color);
    padding: 1rem;
    text-align: center;
    box-shadow: 0 -2px 4px var(--shadow-color);
}

a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}


#theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-right: 20px;
}

#theme-toggle svg {
    width: 24px;
    height: 24px;
    color: var(--text-color);
}

#download-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-right: 10px;
}

#download-button svg {
    width: 24px;
    height: 24px;
    color: var(--text-color);
}

#download-history {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-left: 20px;
}

#download-history svg {
    width: 20px;
    height: 20px;
    color: var(--text-color);
}


#voice-animation {
    position: sticky;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 150px;
    height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    background-color: var(--conversation-bg);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--shadow-color);
    transition: opacity 0.3s ease;
}

#voice-animation svg {
    width: 100%;
    height: 100%;
}

#voice-animation circle {
    stroke: var(--text-color);
    stroke-width: 4;
}

#voice-bars rect {
    fill: var(--text-color);
    animation: voiceBars 0.9s ease-in-out infinite;
    transform-origin: 50% 50%;
}

#voice-bars rect:nth-child(2) {
    animation-delay: 0.3s;
}

#voice-bars rect:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes voiceBars {
    0% { transform: scaleY(0.3); }
    50% { transform: scaleY(1); }
    100% { transform: scaleY(0.3); }
}

#voice-animation.hidden {
    display: none;
}

/* Voice animation for Enhanced page */
#voiceWaveAnimation {
    position: sticky;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 150px;
    height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    background-color: var(--conversation-bg);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--shadow-color);
    transition: opacity 0.3s ease;
}

#voiceWaveAnimation svg {
    width: 100%;
    height: 100%;
}

#voiceWaveAnimation circle {
    stroke: var(--text-color);
    stroke-width: 4;
}

#voiceWaveAnimation #voice-bars rect {
    fill: var(--text-color);
    animation: voiceBars 0.9s ease-in-out infinite;
    transform-origin: 50% 50%;
}

#voiceWaveAnimation #voice-bars rect:nth-child(2) {
    animation-delay: 0.3s;
}

#voiceWaveAnimation #voice-bars rect:nth-child(3) {
    animation-delay: 0.6s;
}

#voiceWaveAnimation.hidden {
    display: none;
}

@media (max-width: 768px) {
    main {
        padding: 0.5rem;
    }

    .settings {
        grid-template-columns: 1fr;
    }

    .controls {
        flex-direction: column;
        gap: 20px;
        margin: 0 auto 15px auto;
        width: 30%;
    }

    button {
        max-width: none;
    }

    #conversation {
        height: 40vh;
    }

    .ai-message, .user-message {
        max-width: 90%;
    }
    header {
        padding: 0.5rem 1rem; /* Adjust padding for smaller screens */
    }

    h1 {
        font-size: 1.2rem; /* Slightly smaller font size for mobile */
    }

    #voice-animation {
        width: 100px; /* Larger animation for mobile */
        height: 100px;
        margin: 0 auto;
        bottom: 40px; /* Position higher on mobile */
    }

    #voiceWaveAnimation {
        width: 100px; /* Larger animation for mobile */
        height: 100px;
        margin: 0 auto;
        bottom: 40px; /* Position higher on mobile */
    }
}

@media (min-width: 1200px) {
    main {
        max-width: 1200px;
    }

    .settings {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Navigation styles */
.main-nav {
    display: flex;
    justify-content: center;
    margin-top: 10px;
    font-size: 16px;
}

.main-nav ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
    display: flex;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid #444;
}

.main-nav li {
    margin: 0;
}

.main-nav a {
    display: block;
    padding: 8px 16px;
    text-decoration: none;
    color: #ccc;
    transition: background-color 0.3s;
    white-space: nowrap;
}

.main-nav a:hover {
    background-color: #333;
}

.main-nav a.active {
    background-color: #555;
    color: white;
    font-weight: bold;
}

/* Media query for mobile navigation */
@media (max-width: 480px) {
    .header-controls {
        width: 100%;
        justify-content: center;
    }
    
    .main-nav {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-top: 5px;
    }
    
    .main-nav ul {
        width: 100%;
    }
    
    .main-nav a {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

/* Enhanced page styles */
.enhanced-info {
    background-color: rgba(76, 175, 80, 0.1);
    border-radius: 5px;
    padding: 10px;
    margin-bottom: 15px;
    font-size: 14px;
}

.enhanced-info code {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
}

/* Media query for smaller screens */
@media (max-width: 768px) {
    .main-nav {
        font-size: 14px;
    }
    
    .main-nav a {
        padding: 6px 12px;
    }
}

/* Listening indicator with animated dots */
.listening-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    margin: 0.5rem 0;
    color: #ffc107;
    font-style: italic;
}

.listening-dots {
    display: inline-flex;
    margin-left: 8px;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #ffc107;
    margin: 0 2px;
    animation: dot-fade 1.4s infinite;
}

@keyframes dot-fade {
    0%, 100% {
        opacity: 0.2;
    }
    50% {
        opacity: 1;
    }
}

/* Add animation for the mic icon when waiting for speech */
#mic-icon.mic-waiting {
    color: red;
    animation: pulse 1.5s infinite;
}

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

/* Pulse animation for recording mic */
.pulse-animation {
    animation: pulse-red 1s infinite;
}

@keyframes pulse-red {
    0% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
        color: red;
    }
    100% {
        opacity: 0.6;
    }
}

/* Add specific styling for webRTC transcript to override global styles */
.transcript-container,
.user-speech, 
.ai-speech, 
.system-message.webrtc, 
.error-message.webrtc {
    text-align: left !important;
}
