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

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --border-color: #e5e7eb;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.3);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--primary-gradient);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 900px;
    height: 80vh;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header Styles */
.header {
    background: var(--primary-gradient);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.header-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header h1 {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.status {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.status-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transition: var(--transition);
    position: relative;
}

.status-indicator.active {
    background: #4ade80;
    animation: pulse 2s infinite;
}

.status-indicator.active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(74, 222, 128, 0.3);
    animation: ripple 2s infinite;
}

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

@keyframes ripple {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

.status-text {
    font-size: 13px;
    font-weight: 500;
}

.elapsed-time {
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    min-width: 70px;
    text-align: center;
    backdrop-filter: blur(10px);
}

/* Transcript Container */
.transcript-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-secondary);
    -webkit-overflow-scrolling: touch;
}

.transcript-content {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.dictation-view {
    padding: 24px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.dictation-text {
    font-size: 18px;
    line-height: 1.8;
    color: var(--text-primary);
    word-wrap: break-word;
    flex: 1;
    white-space: pre-wrap;
}

.dictation-text .finalized {
    color: var(--text-primary);
}

.dictation-text .interim {
    color: var(--text-secondary);
    opacity: 0.7;
    font-style: italic;
    transition: opacity 0.2s ease;
}

.dictation-text .interim::before {
    content: '';
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: var(--warning-color);
    margin-right: 2px;
    animation: blink 1s infinite;
    vertical-align: middle;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    padding: 24px;
}

.empty-state-icon {
    font-size: 56px;
    margin-bottom: 16px;
    opacity: 0.5;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.empty-state-text {
    font-size: 16px;
    font-weight: 500;
}

/* Controls */
.controls {
    padding: 20px 24px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.controls-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.settings-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.settings-group .button-clear-minimal {
    margin-left: auto;
}

.stats-footer {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin-top: 12px;
    padding: 8px 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
}

.stat-value {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.button-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Button Styles */
.button {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.button:active::before {
    width: 300px;
    height: 300px;
}

.button-clear {
    background: var(--danger-color);
    color: white;
    border: none;
}

.button-clear:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

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

.button-clear-minimal {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    min-width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.button-clear-minimal:hover {
    background: var(--bg-secondary);
    border-color: var(--danger-color);
    color: var(--danger-color);
    transform: translateY(-1px);
}

.button-clear-minimal:active {
    transform: translateY(0);
    background: rgba(239, 68, 68, 0.1);
}

.clear-icon {
    font-size: 16px;
    line-height: 1;
    display: block;
}

.button-toggle {
    background: var(--success-color);
    color: white;
    width: 70px;
    height: 70px;
    padding: 0;
    border-radius: 50%;
    font-size: 24px;
    font-weight: 600;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    overflow: visible;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.button-toggle:hover {
    background: #059669;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.button-toggle:active {
    transform: translateY(0) scale(0.98);
}

.button-toggle.recording {
    background: var(--danger-color);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.5), 
                0 0 0 4px rgba(239, 68, 68, 0.1);
    animation: none;
    border-color: rgba(255, 255, 255, 0.3);
}

.button-toggle.recording:hover {
    background: #dc2626;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.button-icon {
    width: 28px;
    height: 28px;
    display: block;
    transition: transform 0.3s ease;
    position: relative;
    z-index: 2;
    color: currentColor;
}

.button-toggle:hover .button-icon {
    transform: scale(1.1);
}

.button-toggle.recording .button-icon {
    display: none;
}

@keyframes microphonePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
}

.button-text {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
    opacity: 0.9;
    position: relative;
    z-index: 2;
}

.button-toggle.recording .button-text {
    display: none;
}

/* Wave Animation Container */
.wave-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 24px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.button-toggle.recording .wave-container {
    opacity: 1;
}

.wave-bar {
    width: 3px;
    height: 8px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 1.5px;
    transform-origin: center bottom;
    border: none;
    box-shadow: none;
}

.wave-bar-1 {
    animation: audioWave 1.2s ease-in-out infinite;
    animation-delay: 0s;
}

.wave-bar-2 {
    animation: audioWave 1.2s ease-in-out infinite;
    animation-delay: 0.15s;
}

.wave-bar-3 {
    animation: audioWave 1.2s ease-in-out infinite;
    animation-delay: 0.3s;
}

.wave-bar-4 {
    animation: audioWave 1.2s ease-in-out infinite;
    animation-delay: 0.45s;
}

.wave-bar-5 {
    animation: audioWave 1.2s ease-in-out infinite;
    animation-delay: 0.6s;
}

@keyframes audioWave {
    0%, 100% {
        transform: scaleY(0.4);
        opacity: 0.3;
    }
    50% {
        transform: scaleY(1);
        opacity: 0.6;
    }
}

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

/* Source Selector */
.source-selector {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.source-selector label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.source-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--bg-primary);
    cursor: pointer;
    min-width: 160px;
    transition: var(--transition);
}

.source-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

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

/* Auth Container */
#authContainer {
    display: flex;
    align-items: center;
    gap: 10px;
}

#authContainer .sign-in-button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

#authContainer .sign-in-button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.auth-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: white;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
    transition: var(--transition);
}

.user-avatar:hover {
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.user-avatar-placeholder {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

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

.user-name {
    font-weight: 500;
    color: white;
    font-size: 13px;
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-button {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.sign-in-button {
    background: var(--primary-color);
    color: white;
}

.sign-in-button:hover {
    background: #5568d3;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

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

.sign-out-button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    padding: 6px 12px;
    font-size: 12px;
}

.sign-out-button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

/* Scrollbar Styling */
.transcript-container::-webkit-scrollbar {
    width: 6px;
}

.transcript-container::-webkit-scrollbar-track {
    background: transparent;
}

.transcript-container::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

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

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        padding: 8px;
    }

    .container {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .header {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
    }

    .header-left {
        width: 100%;
    }

    .header-right {
        width: 100%;
        justify-content: flex-end;
    }

    .header h1 {
        font-size: 18px;
    }

    .status {
        width: 100%;
        justify-content: space-between;
    }

    .status-text {
        font-size: 12px;
    }

    .elapsed-time {
        font-size: 13px;
        padding: 5px 10px;
        min-width: 60px;
    }

    .transcript-container {
        padding: 16px;
    }

    .dictation-view {
        padding: 16px;
    }

    .dictation-text {
        font-size: 16px;
        line-height: 1.6;
    }

    .controls {
        padding: 16px;
    }

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

    .stats-footer {
        margin-top: 8px;
        gap: 16px;
    }

    .button-group {
        width: 100%;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 12px;
    }

    .button-toggle {
        width: 70px;
        height: 70px;
        flex-shrink: 0;
    }

    .settings-group {
        width: 100%;
        justify-content: space-between;
    }

    .settings-group .button-clear-minimal {
        margin-left: 0;
    }

    .source-selector {
        flex: 1;
        min-width: 0;
    }

    .source-select {
        width: 100%;
        min-width: unset;
    }

    .button:not(.button-toggle) {
        width: 100%;
        justify-content: center;
    }

    .auth-user {
        flex-wrap: wrap;
        justify-content: center;
    }

    .user-name {
        max-width: 120px;
    }

    .empty-state-icon {
        font-size: 48px;
    }

    .empty-state-text {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 16px;
    }

    .status-text {
        font-size: 11px;
    }

    .dictation-text {
        font-size: 15px;
    }

    .button {
        padding: 12px 16px;
        font-size: 13px;
    }

    .user-avatar {
        width: 32px;
        height: 32px;
    }

    .user-name {
        max-width: 100px;
        font-size: 12px;
    }
}

/* Hidden class for conditional visibility */
.hidden {
    display: none !important;
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}
