/* ========================================
   Clinical Transcribe - Modern UI Styles
   ======================================== */

:root {
    /* Color Palette */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a24;
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-glass-hover: rgba(255, 255, 255, 0.06);

    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);

    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);

    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(99, 102, 241, 0.3);

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);
}

/* ========================================
   Reset & Base
   ======================================== */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animated Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(168, 85, 247, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

/* ========================================
   Layout
   ======================================== */

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-lg);
}

/* ========================================
   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: 42px;
    height: 42px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.logo-icon svg {
    width: 22px;
    height: 22px;
    color: white;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.status-badge {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    color: var(--text-muted);
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--error);
}

.btn-logout svg {
    width: 18px;
    height: 18px;
}

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

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

.status-badge.error .status-dot {
    background: var(--error);
}

.status-badge.recording .status-dot {
    background: var(--error);
    animation: pulse-dot 0.8s ease-in-out infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.9);
    }
}

/* ========================================
   Main Content
   ======================================== */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

/* ========================================
   Transcription Panel
   ======================================== */

.transcription-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

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

.panel-header h2 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.panel-actions {
    display: flex;
    gap: var(--space-sm);
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover:not(:disabled) {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
    border-color: var(--border-glow);
}

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

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.transcription-content {
    flex: 1;
    padding: var(--space-lg);
    overflow-y: auto;
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.transcription-content::-webkit-scrollbar {
    width: 6px;
}

.transcription-content::-webkit-scrollbar-track {
    background: transparent;
}

.transcription-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.placeholder-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    gap: var(--space-md);
}

.placeholder-text svg {
    width: 48px;
    height: 48px;
    opacity: 0.3;
}

.placeholder-text p {
    font-size: 0.95rem;
}

.transcription-text {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.transcription-text .segment {
    display: inline;
    animation: fadeIn 0.3s ease;
}

.transcription-text .segment.new {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.2) 0%, transparent 100%);
    border-radius: 4px;
    padding: 2px 0;
}

.transcription-text .segment.partial {
    color: var(--text-secondary);
    font-style: italic;
    opacity: 0.8;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.transcription-footer {
    display: flex;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ========================================
   Controls Section
   ======================================== */

.controls-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xl);
    padding: var(--space-lg) 0;
}

.record-button-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.record-button {
    position: relative;
    width: 80px;
    height: 80px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
}

.record-button-inner {
    width: 100%;
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow), var(--shadow-md);
    transition: all var(--transition-base);
    position: relative;
    z-index: 2;
}

.record-button:hover .record-button-inner {
    transform: scale(1.05);
    box-shadow: 0 0 60px rgba(99, 102, 241, 0.3), var(--shadow-lg);
}

.record-button:active .record-button-inner {
    transform: scale(0.98);
}

.record-button svg {
    width: 32px;
    height: 32px;
    color: white;
}

.record-button.recording .record-button-inner {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 0 60px rgba(239, 68, 68, 0.3), var(--shadow-lg);
}

.record-button .mic-icon,
.record-button .stop-icon {
    transition: all var(--transition-fast);
}

.record-button.recording .mic-icon {
    display: none;
}

.record-button .stop-icon {
    display: none;
}

.record-button.recording .stop-icon {
    display: block;
}

.hidden {
    display: none !important;
}

/* Pulse Animation */
.pulse-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--accent-primary);
    opacity: 0;
    z-index: 1;
}

.record-button.recording .pulse-ring {
    animation: pulse-ring 1.5s ease-out infinite;
}

.record-button.recording .pulse-ring.delay {
    animation-delay: 0.5s;
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }

    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

.record-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: color var(--transition-fast);
}

.record-button.recording+.record-hint {
    color: var(--error);
}

/* Settings */
.settings-row {
    display: flex;
    gap: var(--space-lg);
    flex-wrap: wrap;
    justify-content: center;
}

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

.setting-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.select-input {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    min-width: 140px;
    transition: all var(--transition-fast);
}

.select-input:hover {
    border-color: var(--border-glow);
}

.select-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.select-input option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Provider Info Badge */
.provider-info {
    margin-top: var(--space-sm);
}

.provider-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 500;
    transition: all var(--transition-base);
}

.provider-badge.local {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.provider-badge.cloud {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.provider-badge svg {
    flex-shrink: 0;
}

/* Model Size Group visibility */
#modelSizeGroup.hidden {
    display: none;
}

/* ========================================
   Footer
   ======================================== */

.footer {
    text-align: center;
    padding: var(--space-lg) 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ========================================
   Toast Notification
   ======================================== */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all var(--transition-base);
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-message {
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 640px) {
    .app-container {
        padding: var(--space-md);
    }

    .header {
        flex-direction: column;
        gap: var(--space-md);
    }

    .logo h1 {
        font-size: 1.25rem;
    }

    .transcription-panel {
        min-height: 250px;
    }

    .record-button {
        width: 72px;
        height: 72px;
    }

    .record-button svg {
        width: 28px;
        height: 28px;
    }
}