:root {
    --primary-color: #ff6b35;
    --primary-hover: #ff5722;
    --secondary-color: #ffa726;
    --success-color: #66bb6a;
    --danger-color: #ef5350;
    --warning-color: #ffa726;
    --background: #fafafa;
    --surface: #ffffff;
    --surface-light: #f5f5f5;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.08);
    --accent: #ff6b35;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    background: var(--surface);
    padding: 1.5rem 2rem;
    border-radius: 16px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px var(--shadow);
    border: 1px solid var(--border);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.site-logo {
    height: 50px;
    width: auto;
}

.header-text {
    flex: 1;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.25rem 0;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0;
}

/* Start Screen */
.start-screen {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 0;
}

.welcome-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
    box-shadow: 0 4px 12px var(--shadow);
    border: 1px solid var(--border);
}

.microphone-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: pulse-icon 2s ease-in-out infinite;
}

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

.welcome-card h2 {
    font-size: 1.8rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.welcome-card p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.btn-large {
    padding: 1.25rem 2.5rem;
    font-size: 1.1rem;
    margin: 0 auto;
}

/* Connecting state animation */
.btn-large.connecting {
    animation: pulse-button 1.5s ease-in-out infinite;
    cursor: wait;
}

@keyframes pulse-button {
    0%, 100% {
        box-shadow: 0 6px 16px rgba(255, 107, 53, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 6px 24px rgba(255, 107, 53, 0.6);
        transform: scale(1.02);
    }
}

/* Animated dots for "Connexion en cours..." */
.btn-large .dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% {
        content: '';
    }
    40% {
        content: '.';
    }
    60% {
        content: '..';
    }
    80%, 100% {
        content: '...';
    }
}

/* Main App */
.main-app {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Conversation Section */
.conversation-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.conversation-header {
    background: var(--surface);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    border: 1px solid var(--border);
    box-shadow: 0 2px 4px var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.status-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: 0 2px 4px var(--shadow);
}

.status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 1.1rem;
}

.status-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--danger-color);
    animation: pulse 2s ease-in-out infinite;
}

.status-indicator.connected .status-dot {
    background: var(--success-color);
}

.status-indicator.disconnected .status-dot {
    background: var(--text-secondary);
    animation: none;
}

.status-indicator.listening .status-dot {
    background: var(--warning-color);
    animation: pulse-fast 0.5s ease-in-out infinite;
}

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

@keyframes pulse-fast {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.3); }
}

.controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 6px var(--shadow);
    flex: 1;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon {
    font-size: 1.5rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px var(--shadow);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px var(--shadow);
}

.audio-visualizer {
    background: var(--surface);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid var(--border);
    box-shadow: 0 2px 4px var(--shadow);
}

#visualizer {
    width: 100%;
    height: 100px;
    display: block;
    border-radius: 8px;
    background: var(--surface-light);
}

.transcript-container,
.actions-log {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: 0 2px 4px var(--shadow);
}

.transcript-container h3,
.actions-log h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.transcript,
.log-content {
    max-height: 300px;
    overflow-y: auto;
    padding: 1rem;
    background: var(--surface-light);
    border-radius: 8px;
}

.transcript::-webkit-scrollbar,
.log-content::-webkit-scrollbar {
    width: 8px;
}

.transcript::-webkit-scrollbar-track,
.log-content::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: 4px;
}

.transcript::-webkit-scrollbar-thumb,
.log-content::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 4px;
}

.transcript-empty,
.log-empty {
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
    font-style: italic;
}

.transcript-message {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    animation: slideIn 0.3s ease-out;
}

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

.transcript-message.user {
    background: var(--primary-color);
    margin-left: 2rem;
    text-align: right;
    color: white;
}

.transcript-message.assistant {
    background: var(--surface-light);
    margin-right: 2rem;
    border: 1px solid var(--border);
}

.transcript-message.system {
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.1), rgba(255, 167, 38, 0.1));
    border: 2px solid var(--primary-color);
    text-align: center;
    font-weight: 600;
    color: var(--primary-color);
    margin: 1rem 0;
}

.transcript-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
    opacity: 0.8;
}

.log-entry {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: 6px;
    font-size: 0.85rem;
    border-left: 3px solid var(--primary-color);
    background: var(--surface);
    animation: slideIn 0.3s ease-out;
}

.log-entry strong {
    color: var(--primary-color);
}

/* Profile Section */
.profile-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.profile-section h2 {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    padding: 0 0.5rem;
}

.profile-field {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--border);
    box-shadow: 0 2px 4px var(--shadow);
    animation: slideInField 0.5s ease-out;
}

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

.profile-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
}

.field-value {
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.6;
    word-wrap: break-word;
}

.narrative-field .field-value {
    font-size: 0.95rem;
    line-height: 1.7;
}

.bio-field {
    border: 2px solid var(--primary-color);
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.05), rgba(255, 167, 38, 0.05));
}

.bio-field label {
    color: var(--primary-color);
    font-size: 1rem;
}

.bio-field .field-value {
    font-style: italic;
    font-size: 0.95rem;
    line-height: 1.8;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-light);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(217, 70, 239, 0.1);
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.bio-section {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    border: 2px solid var(--primary-color);
}

.bio-section label {
    font-size: 1.1rem;
    color: var(--primary-color);
    font-weight: 600;
}

.bio-section textarea {
    min-height: 150px;
    font-style: italic;
    line-height: 1.8;
    background: var(--surface-light);
}

.profile-header {
    margin-bottom: 1.5rem;
}

.profile-divider {
    height: 1px;
    background: var(--border);
    margin: 2rem 0;
}

.narrative-field label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    text-transform: none;
}

.narrative-field textarea {
    min-height: 100px;
    font-style: normal;
    line-height: 1.8;
}

.form-group input.updated,
.form-group textarea.updated {
    animation: fieldUpdate 0.6s ease-out;
}

@keyframes fieldUpdate {
    0% {
        background: var(--primary-color);
        transform: scale(1.02);
    }
    100% {
        background: var(--background);
        transform: scale(1);
    }
}

footer {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

footer a:hover {
    color: var(--primary-hover);
}

/* Responsive Design */
@media (max-width: 768px) {
    header {
        padding: 1rem;
    }
    
    .logo-container {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .site-logo {
        height: 40px;
    }
    
    header h1 {
        font-size: 1.2rem;
    }
    
    .subtitle {
        font-size: 0.85rem;
    }
    
    .welcome-card {
        padding: 2rem 1.5rem;
    }
    
    .welcome-card h2 {
        font-size: 1.5rem;
    }
    
    .conversation-header {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
    }
    
    .btn-small {
        width: 100%;
    }
    
    .profile-section h2 {
        font-size: 1.2rem;
    }
    
    .transcript-container h3 {
        font-size: 1rem;
    }
}
