/* ===================================
   Azure TTS Avatar Demo - Stylesheet
   Modern Glassmorphism Design
   =================================== */

:root {
    /* Colors - Deep Ocean Theme */
    --primary-hue: 220;
    --primary: hsl(var(--primary-hue), 90%, 56%);
    --primary-light: hsl(var(--primary-hue), 90%, 66%);
    --primary-dark: hsl(var(--primary-hue), 90%, 46%);
    --primary-glow: hsla(var(--primary-hue), 90%, 56%, 0.4);
    
    --accent: hsl(280, 85%, 60%);
    --accent-light: hsl(280, 85%, 70%);
    
    --success: hsl(160, 70%, 45%);
    --error: hsl(0, 75%, 60%);
    --warning: hsl(40, 90%, 55%);
    
    /* Background */
    --bg-base: hsl(225, 30%, 8%);
    --bg-elevated: hsl(225, 28%, 12%);
    --bg-card: hsla(225, 30%, 16%, 0.6);
    --bg-input: hsla(225, 30%, 12%, 0.8);
    
    /* Text */
    --text-primary: hsl(220, 20%, 95%);
    --text-secondary: hsl(220, 15%, 65%);
    --text-muted: hsl(220, 10%, 45%);
    
    /* Borders */
    --border-subtle: hsla(220, 30%, 40%, 0.15);
    --border-default: hsla(220, 30%, 50%, 0.2);
    --border-focus: hsla(var(--primary-hue), 70%, 50%, 0.5);
    
    /* Glass effect */
    --glass-bg: hsla(225, 30%, 18%, 0.65);
    --glass-border: hsla(220, 40%, 60%, 0.12);
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px hsla(0, 0%, 0%, 0.2);
    --shadow-md: 0 4px 20px hsla(0, 0%, 0%, 0.25);
    --shadow-lg: 0 8px 40px hsla(0, 0%, 0%, 0.3);
    --shadow-glow: 0 0 40px var(--primary-glow);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Background Decoration */
.bg-decoration {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.bg-circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s ease-in-out infinite;
}

.bg-circle-1 {
    width: 600px;
    height: 600px;
    background: linear-gradient(135deg, hsl(220, 80%, 30%), hsl(280, 70%, 25%));
    top: -200px;
    right: -100px;
    animation-delay: 0s;
}

.bg-circle-2 {
    width: 500px;
    height: 500px;
    background: linear-gradient(135deg, hsl(200, 80%, 25%), hsl(220, 70%, 30%));
    bottom: -150px;
    left: -100px;
    animation-delay: -7s;
}

.bg-circle-3 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, hsl(280, 70%, 35%), hsl(320, 60%, 30%));
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

.bg-grid {
    position: absolute;
    inset: 0;
    background-image: 
        linear-gradient(hsla(220, 30%, 40%, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, hsla(220, 30%, 40%, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -30px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(-30px, -20px) scale(1.02); }
}

/* Container */
.container {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-lg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) 0;
    margin-bottom: var(--space-xl);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-glow);
}

.logo-icon svg {
    width: 28px;
    height: 28px;
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
}

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

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

.status-indicator.error .status-dot {
    background: var(--error);
    animation: none;
}

.status-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

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

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Panels */
.input-panel,
.preview-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
}

.panel-header {
    margin-bottom: var(--space-xl);
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.panel-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Form Styles */
.synthesis-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.label-icon {
    font-size: 1rem;
}

.form-group textarea,
.form-group select,
.form-group input[type="text"] {
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    transition: var(--transition-fast);
    resize: vertical;
}

.form-group textarea:focus,
.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.form-group select option {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.char-count {
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Avatar Grid */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-md);
}

.avatar-card {
    position: relative;
    background: var(--bg-input);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: center;
}

.avatar-card:hover {
    border-color: var(--border-default);
    transform: translateY(-2px);
}

.avatar-card.selected {
    border-color: var(--primary);
    background: hsla(var(--primary-hue), 70%, 50%, 0.1);
}

.avatar-preview {
    margin-bottom: var(--space-sm);
}

.avatar-placeholder {
    width: 60px;
    height: 60px;
    margin: 0 auto;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 600;
    color: white;
}

.avatar-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.avatar-name {
    font-weight: 500;
    font-size: 0.95rem;
}

.avatar-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.avatar-check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: white;
    opacity: 0;
    transform: scale(0.5);
    transition: var(--transition-fast);
}

.avatar-card.selected .avatar-check {
    opacity: 1;
    transform: scale(1);
}

/* Advanced Options */
.advanced-options {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.advanced-options summary {
    padding: var(--space-md);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    transition: var(--transition-fast);
}

.advanced-options summary:hover {
    color: var(--text-primary);
}

.advanced-options summary::-webkit-details-marker {
    display: none;
}

.advanced-options[open] summary {
    border-bottom: 1px solid var(--border-subtle);
}

.options-content {
    padding: var(--space-md);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.color-input-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    padding: var(--space-xs) var(--space-sm);
}

.color-input-wrapper input[type="color"] {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
    padding: 0;
}

.color-input-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-input-wrapper input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: var(--radius-sm);
}

.color-value {
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Submit Button */
.submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-xl);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-md), 0 0 20px var(--primary-glow);
    margin-top: var(--space-md);
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 30px var(--primary-glow);
}

.submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

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

.submit-btn .btn-loading {
    display: none;
}

.submit-btn.loading .btn-icon,
.submit-btn.loading .btn-text {
    display: none;
}

.submit-btn.loading .btn-loading {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid hsla(0, 0%, 100%, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Preview Panel */
.preview-container {
    min-height: 400px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* Preview States */
.preview-empty,
.preview-loading,
.preview-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-xl);
}

.empty-icon,
.error-icon {
    margin-bottom: var(--space-lg);
    color: var(--text-muted);
}

.empty-icon svg {
    width: 80px;
    height: 80px;
}

.error-icon {
    font-size: 3rem;
}

.preview-empty p,
.preview-loading p,
.preview-error p {
    font-weight: 500;
    margin-bottom: var(--space-xs);
}

.preview-empty span,
.preview-loading span,
.preview-error span {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Loading Animation */
.loading-animation {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: var(--space-lg);
}

.loading-ring {
    position: absolute;
    inset: 0;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}

.loading-avatar {
    position: absolute;
    inset: 15px;
    background: var(--bg-elevated);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.loading-avatar svg {
    width: 40px;
    height: 40px;
}

.progress-bar {
    width: 200px;
    height: 4px;
    background: var(--border-subtle);
    border-radius: 2px;
    overflow: hidden;
    margin-top: var(--space-md);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 2px;
    width: 0%;
    transition: width 0.5s ease;
}

/* Video Player */
.preview-video {
    width: 100%;
    padding: var(--space-md);
}

.preview-video video {
    width: 100%;
    max-height: 400px;
    border-radius: var(--radius-md);
    background: black;
}

.video-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    margin-top: var(--space-md);
}

.action-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.action-btn:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
}

.action-btn.secondary {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
}

.action-btn.secondary:hover {
    background: var(--bg-card);
    border-color: var(--border-focus);
}

.action-btn svg {
    width: 16px;
    height: 16px;
}

/* Retry Button */
.retry-btn {
    margin-top: var(--space-md);
    padding: var(--space-sm) var(--space-lg);
    background: var(--error);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.retry-btn:hover {
    opacity: 0.9;
}

/* History Section */
.history-section {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-subtle);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.section-header h3 {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.clear-history-btn {
    padding: var(--space-xs) var(--space-sm);
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.clear-history-btn:hover {
    border-color: var(--error);
    color: var(--error);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.history-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.history-item:hover {
    border-color: var(--border-default);
}

.history-thumb {
    width: 48px;
    height: 36px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.history-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.history-info {
    flex: 1;
}

.history-title {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.history-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Footer */
.footer {
    text-align: center;
    padding: var(--space-xl) 0 var(--space-md);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer a {
    color: var(--primary-light);
    text-decoration: none;
    transition: var(--transition-fast);
}

.footer a:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: var(--space-md);
    }
    
    .header {
        flex-direction: column;
        gap: var(--space-md);
        text-align: center;
    }
    
    .logo {
        flex-direction: column;
    }
    
    .avatar-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .preview-container {
        min-height: 300px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-input);
    border-radius: 4px;
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Selection */
::selection {
    background: var(--primary);
    color: white;
}

