/* ==================================================================
   Speech to Text Notetaker — Styles
   Theme: Dark Mode with Mint Green palette
   Primary: #10B981 | Secondary: #34D399 | Accent: #6EE7B7 | BG: #0D1F17
   ================================================================== */

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

:root {
    --primary: #10B981;
    --primary-rgb: 16, 185, 129;
    --secondary: #34D399;
    --secondary-rgb: 52, 211, 153;
    --accent: #6EE7B7;
    --accent-rgb: 110, 231, 183;
    --bg: #0D1F17;
    --bg-card: rgba(13, 31, 23, 0.8);
    --bg-elevated: rgba(20, 45, 33, 0.6);
    --text: #E2E8F0;
    --text-muted: #94A3B8;
    --text-dim: #64748B;
    --border: rgba(16, 185, 129, 0.15);
    --border-hover: rgba(16, 185, 129, 0.35);
    --danger: #EF4444;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-glow: 0 0 30px rgba(var(--primary-rgb), 0.15);
}

/* Light theme overrides */
body.light {
    --bg: #F8FAF9;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-elevated: rgba(241, 245, 243, 0.8);
    --text: #1E293B;
    --text-muted: #475569;
    --text-dim: #94A3B8;
    --border: rgba(16, 185, 129, 0.2);
    --border-hover: rgba(16, 185, 129, 0.4);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

.ambient-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.1;
    pointer-events: none;
    z-index: 0;
}

.glow-1 {
    width: 500px;
    height: 500px;
    background: var(--primary);
    top: -200px;
    right: -100px;
    animation: floatGlow 15s ease-in-out infinite;
}

.glow-2 {
    width: 400px;
    height: 400px;
    background: var(--accent);
    bottom: -150px;
    left: -100px;
    animation: floatGlow 18s ease-in-out infinite reverse;
}

@keyframes floatGlow {

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

    50% {
        transform: translate(20px, -15px) scale(1.05)
    }
}

body.light .ambient-glow {
    opacity: 0.05;
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.glass-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-glow);
}

/* ── Layout ──────────────────────────────────────────────────── */
.app-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    position: relative;
    z-index: 1;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text);
    transition: border-color var(--transition);
}

.icon-btn:hover {
    border-color: var(--border-hover);
}

/* ── Banner ──────────────────────────────────────────────────── */
.banner {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.banner-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #F87171;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tab-nav {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 0.25rem;
    margin-bottom: 1.25rem;
}

.tab-btn {
    flex: 1;
    padding: 0.5rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-xs);
    color: var(--text-dim);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.tab-btn.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.tab-btn:hover:not(.active) {
    color: var(--text-muted);
}

.panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.panel.active {
    display: block;
}

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

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

/* ── Record Area ─────────────────────────────────────────────── */
.mic-visualizer-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

#mic-canvas {
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 400px;
    height: 60px;
}

.record-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.record-btn {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.875rem 2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 50px;
    color: #fff;
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    position: relative;
}

.record-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(var(--primary-rgb), 0.35);
}

.record-btn:active {
    transform: translateY(0);
}

.record-dot {
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    display: inline-block;
}

.record-btn.recording {
    background: linear-gradient(135deg, var(--danger), #F87171);
}

.record-btn.recording .record-dot {
    animation: pulseDot 1s ease-in-out infinite;
    border-radius: 3px;
}

@keyframes pulseDot {

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

    50% {
        transform: scale(1.3)
    }
}

.recording-status {
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* ── Language Row ────────────────────────────────────────────── */
.lang-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.control-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    white-space: nowrap;
}

.control-select {
    flex: 1;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394A3B8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    padding-right: 1.75rem;
}

.control-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ── Live Transcription ──────────────────────────────────────── */
.live-transcription {
    margin-bottom: 1rem;
    min-height: 120px;
}

.transcription-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.section-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
}

.confidence-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    background: rgba(var(--primary-rgb), 0.15);
    border: 1px solid rgba(var(--primary-rgb), 0.25);
    border-radius: 20px;
    color: var(--primary);
}

.live-text {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text);
    min-height: 60px;
}

.live-text .interim {
    color: var(--text-muted);
    opacity: 0.7;
}

.placeholder-text {
    color: var(--text-dim);
    font-style: italic;
    font-size: 0.875rem;
}

.timestamp-marker {
    font-size: 0.65rem;
    background: rgba(var(--primary-rgb), 0.1);
    border: 1px solid rgba(var(--primary-rgb), 0.2);
    border-radius: 4px;
    padding: 0.05rem 0.35rem;
    color: var(--primary);
    font-weight: 600;
    margin-right: 0.25rem;
    cursor: pointer;
}

/* ── Action Row ──────────────────────────────────────────────── */
.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.5rem 0.75rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition), opacity var(--transition);
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.action-btn:not(:disabled):hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.action-btn-primary {
    background: rgba(var(--primary-rgb), 0.15);
    border-color: rgba(var(--primary-rgb), 0.3);
    color: var(--primary);
}

.action-btn-primary:not(:disabled):hover {
    background: rgba(var(--primary-rgb), 0.25);
}

.action-btn-danger:not(:disabled):hover {
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--danger);
}

/* ── Editor ──────────────────────────────────────────────────── */
.editor-toolbar {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.toolbar-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition);
}

.toolbar-btn:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.editor-textarea {
    width: 100%;
    min-height: 200px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9rem;
    padding: 1rem;
    resize: vertical;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.editor-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.editor-preview-wrap {
    min-height: 80px;
}

.editor-preview {
    font-size: 0.9rem;
    line-height: 1.7;
}

.editor-preview h1,
.editor-preview h2,
.editor-preview h3 {
    color: var(--primary);
    margin: 0.5rem 0 0.25rem;
}

.editor-preview ul,
.editor-preview ol {
    padding-left: 1.25rem;
}

.editor-preview strong {
    color: var(--accent);
}

.editor-preview code {
    background: var(--bg-elevated);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85em;
}

/* ── History ──────────────────────────────────────────────────── */
.history-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
}

.search-input {
    flex: 1;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
}

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

.search-input::placeholder {
    color: var(--text-dim);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.875rem;
    cursor: pointer;
    transition: border-color var(--transition);
}

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

.history-item-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.history-item-meta {
    font-size: 0.7rem;
    color: var(--text-dim);
    display: flex;
    gap: 0.75rem;
}

.history-item-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-actions {
    display: flex;
    gap: 0.375rem;
    margin-top: 0.5rem;
}

.history-item-actions .action-btn {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
}

/* ── Settings Modal ──────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    width: 90%;
    max-width: 400px;
    padding: 1.5rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.setting-group {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.setting-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.setting-desc {
    font-size: 0.75rem;
    color: var(--text-dim);
    width: 100%;
}

.toggle-btn-setting {
    width: 42px;
    height: 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
    padding: 0;
    margin-left: auto;
}

.toggle-knob-s {
    display: block;
    width: 18px;
    height: 18px;
    background: var(--text-muted);
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform var(--transition), background var(--transition);
}

.toggle-btn-setting[aria-pressed="true"] {
    background: rgba(var(--primary-rgb), 0.25);
    border-color: var(--primary);
}

.toggle-btn-setting[aria-pressed="true"] .toggle-knob-s {
    transform: translateX(18px);
    background: var(--primary);
}

/* ── Toast ────────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--primary);
    color: #fff;
    padding: 0.6rem 1.25rem;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 200;
    box-shadow: 0 4px 20px rgba(var(--primary-rgb), 0.4);
}

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

/* ── Footer ──────────────────────────────────────────────────── */
.app-footer {
    text-align: center;
    padding: 2rem 0 0.5rem;
    color: var(--text-dim);
    font-size: 0.7rem;
}

.hidden {
    display: none !important;
}

@media (max-width: 540px) {
    .app-header h1 {
        font-size: 1.25rem;
    }

    .app-container {
        padding: 1rem 0.75rem;
    }

    .action-row {
        gap: 0.375rem;
    }

    .action-btn {
        font-size: 0.7rem;
        padding: 0.4rem 0.5rem;
    }

    .editor-toolbar {
        flex-wrap: wrap;
    }
}