/* ======================================================
   LearnFlow — AI Learning Assistant
   Dark, Minimal, Futuristic
   ====================================================== */

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

:root {
    /* Palette */
    --bg-base: #0a0a0f;
    --bg-surface: #111118;
    --bg-elevated: #17171f;
    --bg-card: rgba(20, 20, 30, 0.65);
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);

    --text-primary: #e4e4ec;
    --text-secondary: #8b8b9e;
    --text-tertiary: #5a5a6e;

    --accent: #6c7bff;
    --accent-soft: rgba(108, 123, 255, 0.15);
    --accent-glow: rgba(108, 123, 255, 0.35);
    --accent-muted: #5a68d6;

    --purple: #9b7bff;
    --purple-glow: rgba(155, 123, 255, 0.25);

    --success: #4ade80;
    --error: #f87171;

    /* Sizing */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --radius-full: 999px;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --duration: 0.35s;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ── Ambient Background Glows ─────────────────────── */
.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.4;
    pointer-events: none;
    z-index: 0;
    animation: glowDrift 18s ease-in-out infinite alternate;
}

.bg-glow--1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--accent-glow), transparent 70%);
    top: -120px;
    left: -80px;
    animation-duration: 22s;
}

.bg-glow--2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--purple-glow), transparent 70%);
    bottom: -100px;
    right: -60px;
    animation-duration: 26s;
    animation-delay: -8s;
}

.bg-glow--3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(108, 123, 255, 0.12), transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-duration: 20s;
    animation-delay: -4s;
}

@keyframes glowDrift {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(30px, -20px) scale(1.08);
    }

    100% {
        transform: translate(-20px, 15px) scale(0.95);
    }
}

/* ── App Container ────────────────────────────────── */
.app {
    position: relative;
    z-index: 1;
    max-width: 880px;
    margin: 0 auto;
    padding: 60px 28px 80px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 48px;
}

/* ── Header ───────────────────────────────────────── */
.header {
    text-align: center;
    animation: fadeInUp 0.8s var(--ease-out) both;
}

.header__logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.header__icon {
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 8px;
    mix-blend-mode: lighten;
    filter: drop-shadow(0 0 10px var(--accent-glow));
}

.header__title {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    color: var(--text-primary);
}

.header__title-dot {
    color: var(--accent);
}

.header__tagline {
    font-size: 0.88rem;
    font-weight: 400;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

/* ── Upload Section ───────────────────────────────── */
.upload-section {
    width: 100%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    position: relative;
    z-index: 100;
    animation: fadeInUp 0.8s var(--ease-out) 0.1s both;
}

/* ── Text Input ───────────────────────────────────── */
.text-input {
    width: 100%;
    min-height: 120px;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1.5px solid var(--border-hover);
    border-radius: var(--radius-lg);
    padding: 16px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    outline: none;
    transition: all var(--duration) var(--ease-out);
}

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

.text-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ── Controls (dropdowns) ─────────────────────────── */
.controls {
    display: flex;
    flex-direction: row;
    gap: 16px;
    width: 100%;
    position: relative;
    z-index: 20;
}

.control-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    padding-left: 2px;
}

/* ── Custom Dropdown ──────────────────────────────── */
.dropdown {
    position: relative;
    width: 100%;
}

.dropdown__trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--bg-elevated);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--duration) var(--ease-out);
    outline: none;
}

.dropdown__trigger:hover {
    border-color: var(--border-hover);
    background: var(--bg-card);
}

.dropdown__trigger:focus-visible,
.dropdown.open .dropdown__trigger {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.dropdown__chevron {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    flex-shrink: 0;
    transition: transform 0.25s var(--ease-out);
}

.dropdown.open .dropdown__chevron {
    transform: rotate(180deg);
}

.dropdown__value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Menu */
.dropdown__menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    list-style: none;
    background: var(--bg-elevated);
    border: 1.5px solid var(--border-hover);
    border-radius: var(--radius-md);
    padding: 6px;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.97);
    transition: all 0.25s var(--ease-out);
    box-shadow: 0 12px 40px -8px rgba(0, 0, 0, 0.6);
}

.dropdown.open .dropdown__menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.dropdown__item {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.dropdown__item:hover {
    background: var(--accent-soft);
    color: var(--text-primary);
}

.dropdown__item.active {
    color: var(--accent);
    background: rgba(108, 123, 255, 0.08);
    font-weight: 600;
}

/* ── Generate Button ──────────────────────────────── */
.btn-generate {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 48px;
    border: none;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--accent), var(--purple));
    color: #fff;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    overflow: hidden;
    transition: all var(--duration) var(--ease-out);
    box-shadow: 0 4px 24px -4px var(--accent-glow);
}

.btn-generate::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-generate:hover:not(:disabled)::before {
    opacity: 1;
}

.btn-generate:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 32px -4px var(--accent-glow);
}

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

.btn-generate:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-generate.loading {
    pointer-events: none;
    padding: 14px 56px;
}

.btn-generate.loading .btn-generate__text {
    opacity: 0;
}

.btn-generate.loading .btn-generate__loader {
    display: flex;
}

.btn-generate__loader {
    position: absolute;
    display: none;
    gap: 5px;
    align-items: center;
}

.btn-generate__loader span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    animation: loaderBounce 1.2s ease-in-out infinite;
}

.btn-generate__loader span:nth-child(2) {
    animation-delay: 0.15s;
}

.btn-generate__loader span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes loaderBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ── Output Section ───────────────────────────────── */
.output-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.7s var(--ease-out) both;
}

/* ── Audio Player ─────────────────────────────────── */
.player {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    transition: border-color var(--duration) var(--ease-out);
}

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

.player__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.player__wave-icon {
    width: 20px;
    height: 20px;
    color: var(--accent);
    animation: wavePulse 2s ease-in-out infinite;
}

@keyframes wavePulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

.player__title {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.player__controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.player__play-btn {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--duration) var(--ease-out);
    box-shadow: 0 2px 16px -3px var(--accent-glow);
}

.player__play-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 24px -3px var(--accent-glow);
}

.player__play-icon,
.player__pause-icon {
    width: 20px;
    height: 20px;
}

.player__play-icon {
    margin-left: 2px;
}

.player__track {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.player__progress-bar {
    position: relative;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    cursor: pointer;
    overflow: visible;
}

.player__progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--purple));
    border-radius: var(--radius-full);
    transition: width 0.1s linear;
    position: relative;
}

.player__thumb {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px var(--accent-glow);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.player__progress-bar:hover .player__thumb {
    opacity: 1;
}

.player__times {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
}

/* ── Transcript ───────────────────────────────────── */
.transcript {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    animation: fadeInUp 0.7s var(--ease-out) 0.15s both;
    transition: border-color var(--duration) var(--ease-out);
}

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

.transcript__heading {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.transcript__body {
    max-height: 360px;
    overflow-y: auto;
    font-size: 0.92rem;
    line-height: 1.8;
    color: var(--text-primary);
    font-weight: 400;
    padding-right: 8px;
    white-space: pre-wrap;
}

/* Custom scrollbar */
.transcript__body::-webkit-scrollbar {
    width: 5px;
}

.transcript__body::-webkit-scrollbar-track {
    background: transparent;
}

.transcript__body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.transcript__body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* ── Utilities ────────────────────────────────────── */
.hidden {
    display: none !important;
}

/* ── Animations ───────────────────────────────────── */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@keyframes fadeScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ── Error Toast ──────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-elevated);
    border: 1px solid rgba(248, 113, 113, 0.25);
    color: var(--error);
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-size: 0.84rem;
    font-weight: 500;
    z-index: 100;
    opacity: 0;
    transition: all 0.4s var(--ease-out);
    pointer-events: none;
}

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

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 680px) {
    .app {
        padding: 40px 18px 60px;
        gap: 36px;
    }

    .upload-section {
        max-width: 100%;
    }

    .dropzone {
        min-height: 170px;
    }

    .player {
        padding: 20px;
    }

    .player__controls {
        gap: 12px;
    }

    .player__play-btn {
        width: 42px;
        height: 42px;
    }

    .transcript {
        padding: 20px;
    }

    .transcript__body {
        max-height: 280px;
    }
}

@media (max-width: 400px) {
    .header__title {
        font-size: 1.3rem;
    }

    .btn-generate {
        width: 100%;
        padding: 14px 24px;
    }

    .controls {
        flex-direction: column;
    }
}