/* CSS Reset and Base Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    line-height: 1.5;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    color: #333;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus {
    top: 6px;
}

/* Container */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    padding: 2rem 0 1rem;
    text-align: center;
    color: white;
}

.header-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.header-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin: 0;
}

/* Status Indicator */
.status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    margin: 1rem 0;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: currentColor;
}

.status--connected {
    background: rgba(76, 175, 80, 0.9);
    color: white;
}

.status--connecting {
    background: rgba(255, 152, 0, 0.9);
    color: white;
}

.status--disconnected {
    background: rgba(244, 67, 54, 0.9);
    color: white;
}

.status--error {
    background: rgba(244, 67, 54, 0.9);
    color: white;
}

/* Visualizer */
.visualizer-section {
    margin: 2rem 0;
    display: flex;
    justify-content: center;
}

.visualizer {
    width: 100%;
    max-width: 800px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Controls */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin: 2rem 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    text-decoration: none;
    min-height: 48px; /* Accessibility */
}

.btn:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn--primary {
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
}

.btn--primary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.btn--secondary {
    background: rgba(103, 126, 234, 0.9);
    color: white;
}

.btn--secondary:hover:not(:disabled) {
    background: rgba(103, 126, 234, 1);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(103, 126, 234, 0.3);
}

.btn--tertiary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn--tertiary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.btn--record.recording {
    background: rgba(244, 67, 54, 0.9);
    animation: pulse 1.5s infinite;
}

.btn--record.recording:hover:not(:disabled) {
    background: rgba(244, 67, 54, 1);
}

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

/* Transcript */
.transcript-section {
    margin: 2rem 0;
}

.transcript {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 2rem;
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.transcript-placeholder {
    text-align: center;
    color: #666;
    padding: 2rem;
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.placeholder-tips {
    margin-top: 2rem;
    text-align: left;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.placeholder-tips ul {
    padding-left: 1.5rem;
}

.placeholder-tips li {
    margin-bottom: 0.5rem;
}

/* Message Styles */
.message {
    margin: 1rem 0;
    padding: 1rem 1.5rem;
    border-radius: 15px;
    line-height: 1.6;
    word-wrap: break-word;
}

.message--user {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    margin-left: 2rem;
    margin-right: 0.5rem;
    text-align: right;
}

.message--assistant {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    margin-right: 2rem;
    margin-left: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.message--system {
    background: rgba(255, 193, 7, 0.1);
    color: #856404;
    border: 1px solid rgba(255, 193, 7, 0.3);
    text-align: center;
    font-style: italic;
}

.message--error {
    background: rgba(244, 67, 54, 0.1);
    color: #c62828;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.message-role {
    font-weight: 700;
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 0.5rem;
    display: block;
}

.message-time {
    font-size: 0.8rem;
    opacity: 0.6;
    margin-top: 0.5rem;
    display: block;
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.settings-panel[hidden] {
    display: none;
}

.settings-content {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.settings-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.settings-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.settings-close:hover {
    background: #f5f5f5;
}

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

.setting-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.setting-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    transition: border-color 0.3s ease;
}

.setting-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Loading Indicator */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    backdrop-filter: blur(10px);
}

.loading-indicator[hidden] {
    display: none;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    font-weight: 600;
    color: #333;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 1002;
}

.toast {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease;
    max-width: 400px;
    backdrop-filter: blur(10px);
}

.toast--success {
    border-left: 4px solid #4caf50;
}

.toast--error {
    border-left: 4px solid #f44336;
}

.toast--warning {
    border-left: 4px solid #ff9800;
}

.toast--info {
    border-left: 4px solid #2196f3;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Footer */
.footer {
    padding: 2rem 0;
    color: white;
    text-align: center;
    margin-top: 4rem;
}

.footer-links {
    margin-top: 1rem;
}

.footer-link {
    color: white;
    text-decoration: none;
    margin: 0 1rem;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.footer-link:hover {
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-title {
        font-size: 2rem;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .btn {
        justify-content: center;
    }

    .transcript {
        padding: 1rem;
        min-height: 250px;
        max-height: 400px;
    }

    .settings-panel {
        padding: 1rem;
    }

    .settings-content {
        padding: 1.5rem;
    }

    .visualizer {
        height: 80px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .header {
        padding: 1rem 0;
    }

    .status {
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
    }

    .transcript {
        padding: 1rem;
        min-height: 200px;
        max-height: 300px;
    }

    .message {
        padding: 0.75rem 1rem;
        margin: 0.5rem 0;
    }
}

/* Dark Theme */
@media (prefers-color-scheme: dark) {
    body[data-theme="dark"] {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        color: #e2e8f0;
    }

    body[data-theme="dark"] .transcript {
        background: rgba(45, 55, 72, 0.95);
        color: #e2e8f0;
    }

    body[data-theme="dark"] .message--assistant {
        background: rgba(255, 255, 255, 0.1);
        color: #e2e8f0;
        border-color: rgba(255, 255, 255, 0.2);
    }

    body[data-theme="dark"] .settings-content {
        background: #2d3748;
        color: #e2e8f0;
    }

    body[data-theme="dark"] .setting-select {
        background: #1a202c;
        border-color: #4a5568;
        color: #e2e8f0;
    }
}

/* Print Styles */
@media print {
    body {
        background: white !important;
    }

    .header,
    .controls,
    .visualizer-section,
    .settings-panel,
    .footer {
        display: none !important;
    }

    .transcript {
        background: white !important;
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }

    .message {
        break-inside: avoid;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .status {
        border: 2px solid currentColor;
    }

    .btn {
        border: 2px solid currentColor;
    }

    .transcript {
        border: 2px solid #333;
    }

    .message {
        border: 1px solid #333;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}