/* Premium Dark Mode Glassmorphism Theme for Link Analyst */
:root {
    --bg-color: #0f172a; /* Slate 900 */
    --card-bg: rgba(30, 41, 59, 0.7); /* Slate 800 with opacity */
    --card-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc; /* Slate 50 */
    --text-secondary: #94a3b8; /* Slate 400 */
    --accent: #3b82f6; /* Blue 500 */
    --accent-hover: #2563eb; /* Blue 600 */
    --success: #10b981;
    --error: #ef4444;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

#link-analyst-wip-app-container {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: #ffffff !important;
    min-height: 500px;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
    line-height: 1.6;
}

#link-analyst-wip-app-container * {
    color: inherit;
}

/* Background glow effect */
#link-analyst-wip-app-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.la-content {
    position: relative;
    z-index: 1;
}

/* Typography */
.la-title {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 2rem;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Mode Switcher */
.la-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.la-tab-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.la-tab-btn:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.la-tab-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
}

/* Panels */
.la-panel {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

.la-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Inputs and Forms */
.la-input-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.la-input {
    flex: 1;
    background: rgba(15, 23, 42, 0.6) !important;
    border: 1px solid var(--card-border) !important;
    padding: 1rem 1.5rem !important;
    border-radius: 12px !important;
    color: #f8fafc !important; /* Force white text */
    font-size: 1rem !important;
    transition: all 0.3s ease;
}

.la-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.la-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.la-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.la-btn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Glass Cards */
.la-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    backdrop-filter: blur(12px);
    transition: transform 0.3s ease;
}

.la-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Video Results */
.la-video-result {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
}

.la-video-frame {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}

.la-video-info h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.2rem;
}

.la-video-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.la-transcript-match {
    background: rgba(16, 185, 129, 0.1);
    border-left: 4px solid var(--success);
    padding: 1rem;
    border-radius: 0 8px 8px 0;
    font-style: italic;
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

.la-transcript-match span {
    font-weight: bold;
    color: var(--success);
}

/* File Upload */
.la-upload-zone {
    border: 2px dashed var(--card-border);
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    background: rgba(15, 23, 42, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
}

.la-upload-zone:hover, .la-upload-zone.dragover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
}

.la-upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

.la-upload-text {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.la-file-input {
    display: none;
}

/* Audio Results Grid */
.la-audio-results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 2rem;
}
/* Modal Styles */
#la-translation-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.la-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.la-modal-content {
    position: relative;
    z-index: 101;
    width: 90%;
    max-width: 1000px;
    max-height: 90%;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.95) !important;
}

.la-modal-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.3s;
}

.la-modal-close:hover {
    color: #ffffff;
}
.la-result-box {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.5rem;
}

.la-result-box h4 {
    margin-top: 0;
    color: var(--accent);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.la-text-content {
    color: var(--text-primary);
    white-space: pre-wrap;
    font-size: 0.95rem;
    line-height: 1.7;
}

/* Loaders */
.la-loader {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.la-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

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

@media (max-width: 768px) {
    .la-video-result {
        grid-template-columns: 1fr;
    }
    .la-audio-results {
        grid-template-columns: 1fr;
    }
}

/* ---------------------------------------------------------------------------
   Karaoke mode in the script panel.

   Siemens Orange is #EC6602; it is used both for the switch when it is on and
   for the line currently being spoken, so the two read as one feature.
   --------------------------------------------------------------------------- */

.la-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
    flex: none;
}

.la-switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.la-switch-track {
    position: absolute;
    inset: 0;
    background: #475569;
    border-radius: 999px;
    transition: background 0.2s ease;
    pointer-events: none;
}

.la-switch-track::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: #f8fafc;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.la-switch input:checked ~ .la-switch-track {
    background: #EC6602;
}

.la-switch input:checked ~ .la-switch-track::before {
    transform: translateX(22px);
}

.la-switch input:focus-visible ~ .la-switch-track {
    outline: 2px solid #EC6602;
    outline-offset: 2px;
}

/* The line being spoken right now. Left in place when playback pauses. */
.la-karaoke-active {
    background: #EC6602;
    color: #0f172a;
    border-radius: 3px;
    box-shadow: 0 0 0 2px #EC6602;
}

/* Selecting a phrase in the script shows its English above the selection. */
#la-translation-tip {
    position: fixed;
    z-index: 10000;
    max-width: min(420px, 80vw);
    padding: 0.6rem 0.85rem;
    background: #0b1220;
    color: #e2e8f0;
    border: 1px solid #EC6602;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.45;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
    pointer-events: none;
}

/* ---------------------------------------------------------------------------
   The two search drop-downs: Duration next to the keyword box, and Sort above
   the results. Smaller than the surrounding inputs, with the label centred
   both ways.

   .la-input declares its padding and font-size with !important, so these have
   to as well — an ID selector alone does not beat an important declaration.
   text-align centres the closed control's label in Chrome; text-align-last is
   what Firefox reads.
   --------------------------------------------------------------------------- */

#la-yt-license,
#la-yt-duration,
#la-yt-sort {
    font-size: 0.85rem !important;
    padding: 0.6rem 0.75rem !important;
    line-height: 1.2;
    text-align: center;
    text-align-last: center;
    /* Vertical centring needs nothing more than equal padding: a select centres
       its own label in the content box, however tall the row stretches it.
       display:flex would also work in Chrome but is not defined for a replaced
       element, and other engines render it as something other than a menu. */
}

#la-yt-license option,
#la-yt-duration option,
#la-yt-sort option {
    text-align: center;
}

/* ---------------------------------------------------------------------------
   Search progress strip, under the results.

   A search runs as a chain of rounds and can take minutes, so it has to be
   visible that more is coming — while making clear that what is already listed
   is ready to work with.
   --------------------------------------------------------------------------- */

.la-progress {
    margin-top: 1.25rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.55);
}

.la-progress-head {
    font-size: 0.85rem;
    margin-bottom: 0.6rem;
    /* Leaves the bottom right corner free for the maintenance panel, which is
       pinned there and would otherwise cover the end of this line. */
    padding-right: 12rem;
}

@media (max-width: 900px) {
    .la-progress-head,
    .la-progress-note { padding-right: 0; }
}

.la-progress-track {
    position: relative;
    height: 7px;
    border-radius: 999px;
    background: #1e293b;
    overflow: hidden;
}

.la-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #8b5cf6, #22d3ee);
    transition: width 0.45s ease;
}

/* A moving sheen while rounds are still running, so a bar that has not grown
   for a few seconds still reads as "working" rather than "stuck". */
.la-progress-track.is-running::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
    transform: translateX(-100%);
    animation: la-progress-sheen 1.4s ease-in-out infinite;
}

@keyframes la-progress-sheen {
    to { transform: translateX(100%); }
}

.la-progress-note {
    margin: 0.6rem 0 0;
    font-size: 0.8rem;
    color: var(--text-secondary, #94a3b8);
    /* Same reason as .la-progress-head: keep clear of the pinned panel. */
    padding-right: 12rem;
}

@media (prefers-reduced-motion: reduce) {
    .la-progress-track.is-running::after { animation: none; }
    .la-progress-fill { transition: none; }
}
