/* Sophie Chatbot - Modern UI Styles */

:root {
    --primary-color: #ff6b9d;
    --primary-light: #ffb3d1;
    --primary-dark: #e85a8a;
    --secondary-color: #6366f1;
    --background: #f8f9fa;
    --surface: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    background: linear-gradient(135deg, #ffeef7 0%, #fff5f9 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1800px;
    margin: 0 auto;
}

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

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

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2rem;
}

.header-subtitle {
    font-size: 0.95rem;
    opacity: 0.9;
    margin-top: 0.25rem;
}

/* Main Content Layout */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 1.5rem;
    padding: 1.5rem;
}

/* Sidebar */
.sidebar {
    width: 350px;
    flex-shrink: 0;
}

.metrics-panel {
    background: var(--surface);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 2px 12px var(--shadow);
    height: 100%;
    overflow-y: auto;
}

.metrics-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.metric-card {
    background: var(--background);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.metric-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Energy Bar */
.energy-bar-container {
    background: #e5e7eb;
    border-radius: 8px;
    height: 40px;
    overflow: hidden;
    position: relative;
}

.energy-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--success) 0%, var(--warning) 50%, var(--danger) 100%);
    border-radius: 8px;
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.energy-text {
    color: white;
    font-weight: 700;
    font-size: 1rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Phase Indicator */
.phase-indicator {
    display: flex;
    gap: 0.5rem;
}

.phase-badge {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #4f46e5 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Token Display */
.token-display {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.token-bar-container {
    background: #e5e7eb;
    border-radius: 6px;
    height: 8px;
    overflow: hidden;
}

.token-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: 6px;
    transition: width 0.5s ease;
    width: 0%;
}

/* Emotions Display */
.emotions-display {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.emotion-tag {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #78350f;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Indicators */
.indicators {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--surface);
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
}

.indicator-icon {
    font-size: 1.25rem;
}

.indicator-text {
    font-size: 0.875rem;
    font-weight: 500;
}

/* Connection Status */
.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding: 0.75rem;
    background: var(--background);
    border-radius: 8px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--warning);
    animation: pulse 2s infinite;
}

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

.status-text {
    font-size: 0.875rem;
    font-weight: 500;
}

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

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 2px 12px var(--shadow);
    overflow: hidden;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: var(--background);
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

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

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 3rem 2rem;
    max-width: 600px;
    margin: 0 auto;
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.welcome-message h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.75rem;
}

.welcome-message p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1.8;
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 1rem;
    animation: slideIn 0.3s ease;
}

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

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #4f46e5 100%);
}

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

.message-bubble {
    background: var(--background);
    padding: 1rem 1.25rem;
    border-radius: 16px;
    color: var(--text-primary);
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    padding: 0 0.5rem;
}

/* Input Container */
.input-container {
    border-top: 1px solid var(--border);
    padding: 1.5rem;
    background: var(--surface);
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--background);
    border-radius: 12px;
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

.typing-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-left: 0.5rem;
}

.input-wrapper {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    min-height: 50px;
    max-height: 150px;
    transition: border-color 0.3s ease;
}

.message-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.send-button {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

.send-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-lg);
}

.send-button:active {
    transform: translateY(0);
}

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

.input-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.action-button {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.action-button:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

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

.modal-content {
    background: var(--surface);
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px var(--shadow-lg);
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--background);
    border-radius: 8px;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.modal-close:hover {
    background: var(--border);
}

.modal-body {
    padding: 1.5rem;
}

/* Audio Player */
.audio-message {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.audio-player {
    width: 100%;
    margin-bottom: 1rem;
    border-radius: 8px;
}

.audio-actions {
    display: flex;
    gap: 1rem;
}

.download-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.2s ease;
}

.download-button:hover {
    transform: translateY(-2px);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.stat-item {
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: 300px;
    }
    
    .metrics-panel {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }
    
    .logo {
        font-size: 1.25rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}