/* frontend/style.css - Premium Glassmorphism Design System */

:root {
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.5);
    --accent: #f59e0b;
    --accent-glow: rgba(245, 158, 11, 0.4);
    --bg-dark: #020617;
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --success: #10b981;
    --error: #ef4444;
    --font-main: 'Outfit', sans-serif;
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
    font-family: var(--font-main);
    background: radial-gradient(circle at top left, #1e1b4b, #020617 60%);
    background-attachment: fixed;
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-glass {
    width: 95vw;
    height: 90vh;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* TOP NAV */
.top-nav {
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.02);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.logo h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo h1 span {
    color: var(--primary);
    margin-left: 2px;
}

/* MAIN LAYOUT */
.main-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
    overflow: hidden;
}

/* SIDEBAR & CARDS */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.card {
    padding: 1.5rem;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.03);
    transition: transform 0.3s ease;
}

.card h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
}

/* COLLAPSIBLE */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    margin-bottom: 0;
}

.collapsible .card-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease, margin-top 0.3s ease;
    margin-top: 1rem;
}

.collapsible.collapsed .card-content {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    pointer-events: none;
}

#collapse-icon {
    font-size: 0.8rem;
    transition: transform 0.3s;
    color: var(--text-dim);
}

.collapsed #collapse-icon {
    transform: rotate(-90deg);
}

/* INPUT STACK */
.input-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

input[type="text"],
select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 0.8rem 1rem;
    border-radius: 12px;
    color: white;
    font-family: var(--font-main);
    outline: none;
    transition: all 0.2s;
}

input[type="text"]:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

.row {
    display: flex;
    gap: 0.5rem;
}

.row select {
    flex: 1;
}

.primary-btn {
    background: var(--primary);
    border: none;
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--primary-glow);
}

/* MODERN PLAYER */
.player-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
}

#video-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modern-controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.video-card {
    position: relative;
    padding: 0;
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

.expand-video-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.expand-video-btn:hover {
    background: var(--primary);
    transform: scale(1.1);
}

#youtube-player {
    width: 100%;
    height: 100%;
}

.main-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.control-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
    transition: all 0.2s;
}

.control-btn.accent {
    color: var(--accent);
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.play-pulse-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 0 20px var(--accent-glow);
    transition: all 0.3s;
}

.play-pulse-btn:hover {
    transform: scale(1.1);
}

.progress-info {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

.progress-info #current-sentence-num {
    color: white;
}

.progress-info .sep {
    color: var(--text-dim);
    margin: 0 4px;
}

/* CONTENT AREA */
.content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow: hidden;
}

.waveform-container {
    padding: 1rem;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.2);
}

.transcript-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.transcript-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

#transcript-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* SENTENCE ITEM */
.sentence {
    padding: 0.85rem 1rem;
    border-radius: 16px;
    display: flex;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.sentence:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(99, 102, 241, 0.3);
}

.sentence.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.1);
}

.sentence.completed {
    opacity: 0.5;
}

.timestamp {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
    height: fit-content;
}

.sentence-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.sentence-text {
    font-size: 0.95rem;
    line-height: 1.5;
    font-weight: 400;
}

.clickable-word {
    display: inline-block;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px dashed transparent;
}

.clickable-word:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
    transform: translateY(-1px);
}

/* TRANSLATION BOX - NOW SLEEKER */
.sentence-translation-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.sentence-translation {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    display: none;
    line-height: 1.4;
}

.sentence-translation.visible {
    display: block;
}

.translate-icon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.translate-icon:hover {
    color: white;
    background: var(--primary);
}

/* MODAL SYSTEMS */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.3s;
}

/* LARGE VIDEO MODAL */
.large-video-container {
    width: 80vw;
    aspect-ratio: 16 / 9;
    background: black;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

#large-youtube-player {
    width: 100%;
    height: 100%;
}

.close-video-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    z-index: 20;
    line-height: 1;
    width: 44px;
    height: 44px;
    border-radius: 50%;
}

.modal-card {
    min-width: 400px;
    padding: 2rem;
    border-radius: 24px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
}

.config-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.config-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* WORD MODAL SPECIFICS */
.word-modal-card {
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

.word-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.context-info {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.translation-result {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
    padding: 1rem;
}

/* SWITCH COMPONENT */
.switch {
    width: 50px;
    height: 26px;
    position: relative;
    cursor: pointer;
}

.switch input {
    display: none;
}

.slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 34px;
    transition: 0.4s;
}

.slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 4px;
    bottom: 4px;
    background: white;
    border-radius: 50%;
    transition: 0.4s;
}

input:checked+.slider {
    background: var(--success);
}

input:checked+.slider::before {
    transform: translateX(24px);
}

/* MULTIPLIER GRID */
.multiplier-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.multiplier-grid input {
    display: none;
}

.multiplier-grid label {
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    text-align: center;
    transition: all 0.2s;
}

.multiplier-grid input:checked+label {
    background: var(--primary);
    color: white;
}

/* OVERLAYS */
.pause-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.pause-content {
    max-width: 800px;
    padding: 4rem;
    border-radius: 32px;
    text-align: center;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--primary);
    box-shadow: 0 0 50px rgba(0, 0, 0, 1);
}

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

.pulse {
    animation: pulseAnim 2s infinite;
}

.pause-text {
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.pause-sentence {
    font-size: 1.25rem;
    font-style: italic;
    margin-bottom: 2rem;
}

.timer-ring {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
}

@keyframes pulseAnim {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }

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

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

.custom-scroll::-webkit-scrollbar {
    width: 6px;
}

.custom-scroll::-webkit-scrollbar-track {
    background: transparent;
}

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

.icon-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.icon-btn:hover {
    transform: rotate(45deg);
}

.ghost-btn {
    background: none;
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    color: var(--text-muted);
    font-family: var(--font-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ghost-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

/* SPINNERS */
.spinner-mini {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 0.5rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* RESPONSIVE */
@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        max-height: none;
    }
}

/* PHRASES MODAL */
.phrases-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 60vh;
    padding: 0.5rem;
}

.phrase-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    transition: background 0.2s;
}

.phrase-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.phrase-original {
    font-weight: 600;
    color: white;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.phrase-translation {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.95rem;
}

/* TOAST */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(16, 185, 129, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 99px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 5000;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
}

.toast.hidden {
    bottom: -100px;
    opacity: 0;
}