:root {
    --primary-color: #28a745; /* Changed from blue to green */
    --dark-bg: #ffffff;
    --light-bg: #f8f9fa;
    --text-color: #212529;
    --border-color: #dee2e6;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--dark-bg);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.main-container {
    background-color: var(--light-bg);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 800px;
    text-align: center;
    border: 1px solid var(--border-color);
}

h1 {
    color: var(--primary-color);
}

/* Config Section */
.config-section {
    margin: 20px 0;
}

#model-selector {
    padding: 8px;
    border-radius: 4px;
    background-color: #ffffff;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

/* Tabs */
.input-tabs {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-button {
    background: none;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    color: var(--text-color);
    opacity: 0.6;
    border-bottom: 3px solid transparent;
}

.tab-button.active {
    opacity: 1;
    border-bottom: 3px solid var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Video Grid for Examples */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.video-option {
    padding: 15px;
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    color: var(--text-color);
}

.video-option:hover {
    background-color: #e9ecef;
}

.video-option.selected {
    background-color: var(--primary-color);
    color: white; /* Added for better contrast */
    transform: scale(1.05);
    border-color: var(--primary-color);
}

/* Upload & Record Tabs */
#video-upload {
    color: var(--text-color);
}

#record-button {
    margin: 10px;
    padding: 10px 20px;
    cursor: pointer;
}

#recording-preview {
    background-color: #000;
    width: 100%;
    max-width: 400px;
    border-radius: 5px;
    margin: 0 auto 10px;
    display: block;
}

/* Submit Button */
#submit-button {
    background-color: var(--success-color);
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 5px;
    font-size: 1.2rem;
    cursor: pointer;
    margin-top: 20px;
    width: 100%;
    transition: background-color 0.2s;
}

#submit-button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

#submit-button:not(:disabled):hover {
    background-color: #218838;
}

/* Overlay */
.hidden {
    display: none !important;
}

#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.overlay-content {
    background-color: var(--light-bg);
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    height: 90%;
    max-width: 1400px;
    display: flex;
    gap: 20px;
    position: relative;
    overflow-y: auto;
}

#close-overlay {
    position: absolute;
    top: 10px;
    right: 15px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 16px;
    line-height: 30px;
    text-align: center;
}

.video-player-container {
    flex: 6;
}

#result-video {
    width: 100%;
    height: auto;
    max-height: 100%;
    border-radius: 5px;
}

.ai-response-container {
    flex: 4;
    overflow-y: auto;
    border-left: 1px solid var(--border-color);
    padding-left: 20px;
}

.response-section {
    margin-bottom: 20px;
}

.response-section h3 {
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

#details-output li {
    background: #e9ecef;
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 4px;
    list-style-type: none;
    border: 1px solid var(--border-color);
    border-left: 5px solid var(--primary-color); /* Added color accent */
    transition: background-color 0.2s;
}

#details-output li:hover {
    background: #dce2e6; /* Added hover effect */
}

#functions-output .function-call {
    background: #f8f9fa;
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    border-left: 4px solid var(--warning-color);
    border: 1px solid var(--border-color);
}

.function-call.police {
    border-color: var(--primary-color);
}

.function-call.ambulance {
    border-color: var(--danger-color);
}

.function-call.firefighters {
    border-color: #fd7e14;
}

.function-call.alert-ok {
    border-color: var(--success-color);
}

#generate-audio-button {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 15px;
    transition: background-color 0.2s;
}

#generate-audio-button:hover {
    background-color: #218838;
}

#generate-audio-button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

#generate-audio-button:disabled:hover {
    background-color: #6c757d;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
}

#audio-player {
    display: block; /* It will be shown/hidden via JS */
    width: 100%;
    max-width: 250px; /* Adjust as needed */
}

#audio-player.hidden {
    display: none;
}

/* Loading spinner animation */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 5px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}