/*movie_editor.css*/

.editor-container {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 16px 16px 20px;
    box-sizing: border-box;
}


.compact-header {
    margin: 6px 0;
    height: 24px;
}

.editor-header {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-link {
    color: var(--color-muted);
    font-size: 0.9rem;
}

.movie-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
}

.movie-director {
    color: var(--color-muted);
    font-size: 0.9rem;
}

.editor-layout {
    display: grid;
    grid-template-columns: 45% 55%;
    gap: 8px;
    align-items: start;
}


.video-panel {
    display: flex;
    flex-direction: column;
}

.video-header {
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: 11px 14px;
}

.video-header .movie-title {
    font-size: 1.1rem;
    margin: 0;
}

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    background: #000;
    border-radius: 0;
    overflow: hidden;
}

.yt-player {
    position: absolute;
    width: 100%;
    height: 100%;
}

.subtitle-display {
    background: var(--color-walnut);
    color: white;
    text-align: center;
    padding: 10px;
    font-size: 1rem;
    min-height: 44px;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.table-panel {
    border: 1px solid var(--color-line);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
    height: calc(100vh - 90px);
    overflow: hidden;
}

.table-container {
    overflow-y: auto;
    height: 100%;
    max-height: none;
    contain: layout paint;
}

.cue-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.cue-table thead {
    background: var(--color-surface-2);
    position: sticky;
    top: 0;
    z-index: 1;
}

.cue-table th {
    padding: 4px;
    text-align: left;
    color: var(--color-faint);
    font-weight: 500;
}

.cue-table td {
    padding: 4px;
}

/* order column: flush left, tight against the timing column */
.cue-table td.cue-order-layout,
.cue-table th.order-column {
    padding-left: 0;
    padding-right: 0;
}

.cue-table td.cue-timing-layout,
.cue-table th.timing-column {
    padding-left: 0;
}

.order-column,
.cue-order-layout {
    width: 34px;
}

.timing-column,
.cue-timing-layout {
    width: 210px;
}

.text-column,
.cue-text-layout {
    width: auto;
}



.cue-row {
    border-bottom: 1px solid var(--color-line);
}

.cue-row.active {
    background: var(--color-brand-soft);
    box-shadow: inset 4px 0 0 var(--color-brand);
}

.cue-row.last-edited {
    background: var(--color-brass-soft);
    box-shadow: inset 4px 0 0 var(--color-brass);
    transition: background-color .6s ease, box-shadow .6s ease;
}

.cue-order-layout {
    text-align: center;
    vertical-align: middle;
}

.cue-number {
    font-size: 0.72rem;
    color: var(--color-ink-2);
    margin: 4px 0;
}

.order-button {
    background: var(--color-surface-2);
    border: 1px solid var(--color-line);
    cursor: pointer;
    padding: 3px 4px;
    color: var(--color-muted);
    border-radius: 4px;
    font-size: 0.7rem;
}

.cue-timing-layout {
    vertical-align: middle;
}

.time-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-bottom: 4px;
}

.time-label {
    display: block;
    font-size: 0.68rem;
    color: var(--color-faint);
    margin-bottom: 2px;
}

.cue-input {
    width: 100%;
    box-sizing: border-box;
    padding: 3px 5px;
    border: 1px solid var(--color-line-strong);
    border-radius: 4px;
    color: var(--color-ink-2);
    font-size: 0.82rem;
}

.cue-buttons-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 4px;
}

.cue-action-button {
    padding: 3px 6px;
    background: var(--color-surface-2);
    color: var(--color-muted);
    border: 1px solid var(--color-line);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.82rem;
}

.delete-button {
    color: var(--color-faint);
}

.cue-text-layout {
    vertical-align: middle;
}

.cue-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 6px;
    border: 1px solid var(--color-line-strong);
    border-radius: 4px;
    resize: vertical;
    min-height: 76px;
    color: var(--color-ink-2);
    font-size: 0.9rem;
}

.cue-text {
    color: var(--color-ink-2);
    font-size: 0.9rem;
}

.loading-cell {
    padding: 20px;
    text-align: center;
    color: var(--color-faint);
}

.color-dot-small {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
}


.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.toolbar-label {
    font-size: 0.78rem;
    color: var(--color-faint);
}

.version-label {
    margin-left: 8px;
}

.current-time {
    font-variant-numeric: tabular-nums;
}

.subtitle-select {
    border: 1px solid var(--color-line-strong);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--color-ink-2);
}

.toolbar-spacer {
    flex: 1;
}

.btn {
    padding: 6px 12px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}

.btn:not(:disabled):hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--color-brand-soft);
    color: var(--color-brand-dark);
    border: 1px solid #e7c4b6;
}
#assign-btn.btn-primary {
    background: var(--color-surface-2);
    border-color: var(--color-line);
    color: var(--color-muted);
}

.btn-secondary {
    background: var(--color-surface-2);
    color: var(--color-muted);
    border: 1px solid var(--color-line);
}

.context-menu {
    display: none;
    position: fixed;
    z-index: 9999;
    background: white;
    border: 1px solid var(--color-line);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    padding: 6px;
    min-width: 120px;
}

.context-menu-item {
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.context-menu-item:hover {
    background: var(--color-surface-2);
}

.color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
}

.context-menu-divider {
    margin: 4px 0;
    border: none;
    border-top: 1px solid var(--color-line);
}

.clear-item {
    color: var(--color-faint);
    font-size: 0.85rem;
}

@media (max-width: 1100px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
}


.cue-input-warn {
    border-color: var(--color-danger) !important;
    background: var(--color-danger-soft);
}

.ripple-widget {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ripple-input {
    width: 80px;
}

.btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.editor-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-walnut);
    color: var(--color-cream);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    z-index: 10000;
}

.editor-toast.visible {
    opacity: 0.95;
}

.time-box .cue-input,
.time-box .cue-time {
    font-size: 0.72rem;
}

.time-box .cue-input {
    height: 34px;
    padding: 0 5px;
}

.time-input-wrap {
    display: flex;
    align-items: stretch;
    gap: 2px;
}

.time-nudge {
    display: flex;
    flex-direction: column;
}

.nudge-btn {
    flex: 1;
    padding: 0 5px;
    font-size: 0.8rem;
    line-height: 1;
    background: var(--color-surface-2);
    border: 1px solid var(--color-line);
    color: var(--color-muted);
    cursor: pointer;
    border-radius: 2px;
}


/* active subtitle language: filled grey, white text */
.editor-controls .lang-btn.active-lang {
    background: var(--color-brand);
    border-color: var(--color-brand);
    color: var(--color-surface);
}

/* inactive: transparent */
.editor-controls .lang-btn {
    background: transparent;
    border-color: var(--color-line-strong);
    color: var(--color-muted);
}

/* translate dropdown: minimum width */
#translate-target {
    width: auto;
    min-width: 0;
    flex: 0 0 auto;
}

/* autoscroll: text-only, no fill */
#autoscroll-btn,
#autoscroll-btn.btn-primary {
    background: transparent;
    border: 1px solid var(--color-line);
    color: var(--color-muted);
}

/* translate: neutral, not blue */
#translate-btn.btn-primary {
    background: var(--color-surface-2);
    border-color: var(--color-line);
    color: var(--color-muted);
}

/* translate button error state */
#translate-btn.btn-error {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: var(--color-surface);
}


/* ultima cue attiva, evidenziazione attenuata */
.cue-row.last-active {
    background: var(--color-surface-2);
}

/* bottone stato completato */
#status-btn.btn-completed {
    background: var(--color-success-soft);
    border-color: #b9d3ae;
    color: var(--color-success);
}



/* ===== Editor controls panel ===== */
.editor-controls {
    margin-top: 12px;
    padding: 14px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* rows inside the panel */
.editor-controls .editor-toolbar,
.editor-controls .subtitle-language-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0;
}

/* consistent button sizing */
.editor-controls .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 14px;
    line-height: 1.2;
    border-radius: 8px;
    white-space: nowrap;
}

/* big primary actions: Save / Redaktor ol */
.editor-controls .btn-lg {
    padding: 4px 14px;
    font-size: 15px;
    font-weight: 400;
    border-radius: 10px;
}

/* ripple widget: visually grouped box, pushed to the right */
.editor-controls .ripple-widget {
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    gap: 6px;
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: 10px;
}
.ctrl-group-ripple .ctrl-label {
    margin-left: 0;
    padding-left: 4px;
}

.editor-controls .ripple-input {
    width: 72px;
    padding: 7px 9px;
    border: 1px solid var(--color-line-strong);
    border-radius: 7px;
    font-size: 13px;
}

/* language row: separated with a divider, pill-shaped buttons */
.editor-controls .subtitle-language-buttons {
    padding-top: 12px;
    border-top: 1px solid var(--color-line);
}

.editor-controls .lang-btn {
    border-radius: 999px;
    padding: 3px 12px;
    min-width: 40px;
    justify-content: center;
}

/* translate group pushed to the right */
.editor-controls #translate-target {
    padding: 7px 10px;
    border: 1px solid var(--color-line-strong);
    border-radius: 8px;
    font-size: 13px;
}


/* ===== Labelled control groups ===== */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, max-content));
    justify-content: start;
    align-items: end;
    gap: 8px 14px;
}

.ctrl-group {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 3px;
    min-width: 0;
}

.ctrl-label {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;          /* labels line up even when text wraps to 1 vs 2 lines */
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--color-muted);
    line-height: 1.3;
}

.ctrl-row {
    display: inline-flex;
    gap: 8px;
}

/* ripple group spans the space it needs and sits at the row end */
.ctrl-group-ripple {
    grid-column: span 2;
    max-width: 510px;
}

/* save button: one label line + one button line */
.ctrl-group-save {
    align-self: end;
}

.ctrl-group-save::before {
    content: "";
    min-height: 32px;   /* invisible stand-in for the missing label */
}

.ctrl-group-save .btn-lg {
    align-self: stretch;
    height: auto;
    justify-content: center;
}
/* save: neutral fill, faded when nothing to save */
#save-all-btn,
#save-all-btn.btn-primary {
    background: var(--color-surface-2);
    border-color: var(--color-line-strong);
    color: var(--color-ink-2);
}

#save-all-btn:disabled {
    background: var(--color-surface-2);
    border-color: var(--color-line);
    color: var(--color-faint);
    opacity: 0.6;
}
.ctrl-label-full {
    flex-basis: 100%;
    min-height: 0;
}

/* uniform button height so every group's baseline matches */
.editor-controls .btn {
    min-height: 30px;
}

.editor-controls .btn-lg {
    min-height: 30px;
    font-weight: 400;
}


/* uniform font family + weight across the whole panel */
.editor-controls,
.editor-controls .btn,
.editor-controls .ctrl-label,
.editor-controls .cue-input,
.editor-controls #translate-target {
    font-family: inherit;
    font-weight: 400;
}

.info-i {
    font-weight: 400;
}
/* ===== Info button + tooltip ===== */
.info-i {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid var(--color-line-strong);
    background: var(--color-surface);
    color: var(--color-muted);
    font-size: 11px;
    font-weight: 400;
    font-style: italic;
    line-height: 1;
    cursor: help;
    position: relative;
    user-select: none;
}

.info-i:hover {
    background: var(--color-brand);
    border-color: var(--color-brand);
    color: var(--color-surface);
}

/* tooltip bubble */
.info-i::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 260px;
    padding: 8px 10px;
    background: var(--color-walnut);
    color: var(--color-cream);
    font-size: 12px;
    font-weight: 400;
    font-style: normal;
    line-height: 1.4;
    text-align: left;
    white-space: normal;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s;
    z-index: 10001;
}

/* little arrow */
.info-i::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--color-walnut);
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s;
    z-index: 10001;
}

.info-i:hover::after,
.info-i:hover::before,
.info-i:focus::after,
.info-i:focus::before {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 640px) {
    .controls-grid {
        grid-template-columns: 1fr;
    }

    /* phones: each line stacks - number + timing on top, the text full
       width below (three columns left only ~50px for the text) */
    .cue-table,
    .cue-table tbody {
        display: block;
    }

    .cue-table thead {
        display: none;
    }

    .cue-table tr.cue-row {
        display: grid;
        grid-template-columns: 34px 1fr;
        align-items: start;
    }

    .cue-table td.cue-timing-layout {
        width: auto;
    }

    .cue-table td.cue-text-layout {
        grid-column: 1 / -1;
        padding: 0 4px 10px;
    }
.ctrl-group-ripple,
    .ctrl-group-save {
        grid-column: auto;
        grid-row: auto;
        max-width: none;
    }

    .ctrl-label {
        min-height: 0;
    }
}



/* ===== Draggable split between video and table ===== */
.editor-layout {
    grid-template-columns: var(--video-col, 45%) 6px 1fr;
}

.layout-resizer {
    align-self: stretch;
    height: calc(100vh - 90px);
    background: var(--color-line);
    border-radius: 3px;
    cursor: col-resize;
    transition: background .15s;
}

.layout-resizer:hover,
.layout-resizer.dragging {
    background: var(--color-brand);
}

/* while dragging, don't let the iframe swallow mouse events */
body.resizing {
    cursor: col-resize;
    user-select: none;
}

body.resizing .video-wrapper::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 5;
}

@media (max-width: 1100px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }

    .layout-resizer {
        display: none;
    }
}

/* stale-tab warning: save button turns red */
#save-all-btn.btn-stale,
#save-all-btn.btn-stale:disabled {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: var(--color-surface);
    opacity: 1;
    font-weight: 600;
}

/* error variant of the toast */
.editor-toast.error {
    background: var(--color-danger);
    font-size: 1.05rem;
    font-weight: 600;
    padding: 14px 24px;
    max-width: 90vw;
    text-align: center;
    line-height: 1.4;
}

.editor-toast.error.visible {
    opacity: 1;
}

/* JS hides controls with the hidden attribute; keep it stronger than the
   display rules of .ctrl-group and friends */
.editor-container [hidden] {
    display: none !important;
}

.demo-note {
    margin: 0 0 10px;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--color-warning-soft);
    color: var(--color-warning);
    font-size: 0.85rem;
    line-height: 1.4;
}

/* video speed next to auto-scroll: a read-only field with + / − like the
   cue time fields */
.speed-control {
    display: inline-flex;
    align-items: stretch;
    gap: 2px;
    height: 34px;
}

.speed-value {
    width: 4.2em;
    padding: 0 6px;
    border: 1px solid var(--color-line);
    border-radius: 4px;
    background: var(--color-surface);
    color: var(--color-ink);
    font: inherit;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.speed-control .nudge-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

/* Cue colour dots (next to the cue number and in the right-click menu).
   They were never given a colour, so a marked cue looked unmarked. A thin
   dark ring keeps the yellow visible on the light background. */
.color-dot.color-yellow,
.color-dot-small.color-yellow {
    background: #e0a526;
}

.color-dot.color-green,
.color-dot-small.color-green {
    background: #3f8f4e;
}

.color-dot.color-red,
.color-dot-small.color-red {
    background: #c0392b;
}

.color-dot,
.color-dot-small {
    box-shadow: inset 0 0 0 1px rgba(43, 29, 21, 0.25);
}

/* Cue colours. Admins also see the text in the colour (movie_editor.js,
   tintClass); yellow is shown as an orange-brown that stays readable. */
.cue-row.tint-red .cue-textarea,
.cue-row.tint-red .cue-text {
    color: var(--color-danger);
}

.cue-row.tint-yellow .cue-textarea,
.cue-row.tint-yellow .cue-text {
    color: #a1500c;              /* 4.6:1 even on the highlighted row */
}

.cue-row.tint-green .cue-textarea,
.cue-row.tint-green .cue-text {
    color: var(--color-success);
}

/* feedback after choosing a colour in the right-click menu */
@keyframes cue-color-flash {
    from { background-color: var(--color-brass-soft); }
    to { background-color: transparent; }
}

.cue-row.color-flash > td {
    animation: cue-color-flash 0.7s ease-out;
}
