/* ══════════════════════════════════════════════════
   MyTube — Video Cards & Tube UI
══════════════════════════════════════════════════ */

/* ── Video grid card ──────────────────────────── */
.videos .card {
    height: 100%;
    background: var(--mt-surface);
    border: 1px solid var(--mt-border);
    border-radius: var(--mt-radius);
    overflow: hidden;
    transition: border-color var(--mt-ease), box-shadow var(--mt-ease), transform var(--mt-ease);
}

.videos .card:hover {
    border-color: var(--mt-border-hover);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
    transform: translateY(-3px);
}

/* ── Thumbnail area ───────────────────────────── */
.tube-card-image {
    /* Bootstrap's .ratio > * sets position: absolute; top/left/width/height — don't override */
    overflow: hidden;
    background: #000;
}

.tube-card-image a {
    display: block;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.tube-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease, filter 0.35s ease;
    filter: brightness(0.9);
}

.videos .card:hover .tube-card-image img {
    transform: scale(1.04);
    filter: brightness(1);
}

/* ── Duration badge ───────────────────────────── */
.duration {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.5;
    border-radius: 4px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* ── Card body / metadata ─────────────────────── */
.card-body {
    padding: 0.65rem 0.75rem 0.75rem;
}

.tube-title {
    color: var(--mt-text);
    text-decoration: none;
    font-size: 0.825rem;
    font-weight: 600;
    display: block;
    line-height: 1.35;
    transition: color var(--mt-ease);
}

.tube-title:hover {
    color: #fff;
}

/* Channel icon */
.d-flex .flex-shrink-0 img {
    object-fit: cover;
    opacity: 0.85;
    transition: opacity var(--mt-ease);
}

.d-flex .flex-shrink-0 img:hover {
    opacity: 1;
}

.tube-info {
    font-size: 0.75rem;
    color: var(--mt-text-muted);
    margin-top: 0.25rem;
    line-height: 1.4;
}

#primary .tube-info {
    font-size: 0.85rem;
}

.tube-info a {
    color: var(--mt-text-muted);
    text-decoration: none;
    transition: color var(--mt-ease);
}

.tube-info a:hover {
    color: var(--mt-text);
}

/* ── Tags ─────────────────────────────────────── */
.tag {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 500;
    padding: 2px 8px 2px 6px;
    margin: 2px 2px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0 20px 20px 0;
    color: var(--mt-text-muted);
    text-decoration: none;
    line-height: normal;
    background: rgba(255, 255, 255, 0.04);
    transition: background var(--mt-ease), color var(--mt-ease), border-color var(--mt-ease);
}

.tag:hover {
    background: rgba(230, 57, 80, 0.12);
    color: var(--mt-accent);
    border-color: rgba(230, 57, 80, 0.3);
}

/* ── Tag links (watch page sidebar) ──────────── */
.tag-link {
    color: var(--mt-text-muted);
    text-decoration: none;
    padding: 2px 5px;
    border-radius: var(--mt-radius-sm);
    transition: background var(--mt-ease), color var(--mt-ease);
    vertical-align: middle;
}

.tag-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--mt-text);
}

.tag-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* ── Dropdown actions on card ─────────────────── */
.dropdown-video-actions {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 10;
}

.dropdown-video-actions .btn {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.75);
    border-radius: 50%;
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity var(--mt-ease), background var(--mt-ease), color var(--mt-ease);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.videos .card:hover .dropdown-video-actions .btn {
    opacity: 1;
}

.dropdown-video-actions .btn:hover {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.25);
}

.border-none { border: none !important; }

/* ── Buttons (card size) ──────────────────────── */
.btn.btn-xs {
    padding: 0.1rem 0.35rem;
    font-size: 0.75rem;
    line-height: 1.4;
    border-radius: var(--mt-radius-sm);
}

/* ── FAB — Add Tube ───────────────────────────── */
#js-add-tube {
    position: fixed;
    bottom: 36px;
    right: 18px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mt-accent);
    border-radius: 50%;
    color: #fff;
    font-size: 26px;
    font-weight: 300;
    line-height: 1;
    text-decoration: none;
    box-shadow: 0 4px 20px var(--mt-accent-glow), 0 2px 8px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow var(--mt-ease), background var(--mt-ease);
    z-index: 500;
}

#js-add-tube:hover {
    background: #c8283a;
    transform: scale(1.12);
    box-shadow: 0 6px 28px var(--mt-accent-glow), 0 2px 10px rgba(0, 0, 0, 0.5);
    color: #fff;
}

#js-add-tube span {
    display: none;
}

/* ── Watch page layout ────────────────────────── */
#columns {
    display: flex;
    justify-content: center;
}

#primary {
    width: calc(100% - 425px);

}

#secondary {
    width: 410px;
    padding: 0 1rem 1rem 1rem;
}

iframe {
    max-width: 100%;
    max-height: 100%;
    z-index: 10;
}

.main-img {
    max-width: 100%;
    max-height: 100%;
    position: absolute;
    z-index: -1;
}

/*body {*/
/*    overflow-y: hidden;*/
/*}*/

/*
 * Below lg the sidebar goes under the player. #primary has an inline min-width of 360px × aspect ratio (640px for 16:9)
 * and #secondary a fixed 410px, both wider than a phone, so they are reset here.
 */
@media (max-width: 991.98px) {

    #columns {
        display: block;
    }

    #primary {
        width: auto;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    #primary .ratio {
       max-width: 100% !important;
       min-height: auto !important;
    }

    #secondary {
        width: auto;
        padding: 1rem 0;
    }
}

@media (max-width: 575px) {

    #player {
        border-radius: 0 !important;
    }

    /* The player goes edge to edge, the text below it keeps a margin */
    #primaryInfo,
    #secondary {
        padding-left: .75rem;
        padding-right: .75rem;
    }
}

/* Long words and URLs in the title, tags and description wrap instead of widening the page */
#primaryInfo {
    overflow-wrap: anywhere;
}

/* The title next to the 168px thumbnail may shrink below its content width */
.sidebar-video .flex-grow-1 {
    min-width: 0;
}

#player {
    border-radius: var(--mt-radius-lg);
    overflow: hidden;
    background: #000;
}

/* ── Sidebar video items ──────────────────────── */
a.video-title-side {
    color: var(--mt-text);
    text-decoration: none;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8125rem;
    line-height: 1.35;
    font-weight: 600;
    transition: color var(--mt-ease);
}

a.video-title-side:hover {
    color: #fff;
}

.playlist-small-thumb {

}
.video-small-thumb {
    display: inline-block;
    width: 168px;
    height: 94px;
    border-radius: var(--mt-radius-sm);
    overflow: hidden;
    border: 1px solid var(--mt-border);
    flex-shrink: 0;
    background: var(--mt-surface-2);
}

.video-small-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.video-small-thumb:hover img {
    transform: scale(1.04);
}

/* ── Offcanvas ────────────────────────────────── */
.offcanvas.offcanvas-start {
    width: 240px;
    background: var(--mt-surface);
    border-right: 1px solid var(--mt-border);
}

/* ── Watch playlist drag and drop ─────────────── */
.js-watch-playlist > tr,
.js-playlist-reorder > tr {
    cursor: grab;
}

.js-watch-playlist > tr.watch-playlist-dragging,
.js-playlist-reorder > tr.watch-playlist-dragging {
    opacity: 0.4;
}

.js-watch-playlist > tr.table-active .watch-playlist-title::before {
    content: "\f04b";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    color: var(--bs-success);
    margin-right: 0.25rem;
}

.watch-playlist-handle,
.watch-playlist-remove {
    color: var(--mt-text-muted);
}

.watch-playlist-remove:hover,
.watch-playlist-remove:focus-visible {
    color: var(--bs-danger);
}

/* Thumbnail in the playlist modal with the duration on it */
.watch-playlist-thumb {
    position: relative;
    display: inline-block;
    line-height: 0;
}

.watch-playlist-thumb img {
    border-radius: var(--mt-radius-sm);
}

.watch-playlist-thumb .duration {
    bottom: 2px;
    right: 2px;
    padding: 1px 3px;
    font-size: 9px;
    line-height: 1.3;
    border-radius: 3px;
}

/* Phones: the playlist modal uses almost the whole width */
@media (max-width: 575.98px) {
    .modal:has(.playlist-search) .modal-dialog {
        margin-left: 0.25rem;
        margin-right: 0.25rem;
    }

    .modal-body:has(.playlist-search) {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .modal-body .container:has(.playlist-search) {
        padding-left: 0;
        padding-right: 0;
    }
}

/* ── Playlist search ──────────────────────────── */
.playlist-search {
    position: relative;
}

/* The search stays fixed at the top while the list scrolls, with room for its suggestions */
.modal-dialog-scrollable .modal-body:has(.playlist-search) {
    min-height: min(480px, 60vh);
    padding-top: 0;
}

.modal-dialog-scrollable .playlist-search {
    position: sticky;
    top: 0;
    z-index: 2;
    padding-block: 0.75rem;
    background: var(--mt-surface);
}

.modal-dialog-scrollable .playlist-search .ac-dropdown {
    top: calc(100% - 0.5rem);
}

.playlist-search .ac-dropdown {
    left: 0;
    right: 0;
    width: auto;
    transform: none;
}

.playlist-search .ac-meta {
    flex-grow: 1;
}

.playlist-search .playlist-search-input {
    padding-right: 2.25rem;
}

.playlist-search .playlist-search-input::-webkit-search-cancel-button {
    display: none;
}

.playlist-search-clear {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    color: var(--mt-text-muted);
}

.playlist-search-clear:hover,
.playlist-search-clear:focus-visible {
    color: var(--mt-text);
}

.ac-add-icon {
    flex-shrink: 0;
    color: var(--mt-text-muted);
}

.ac-item.ac-added {
    cursor: default;
    opacity: 0.6;
}

.ac-item.ac-added .ac-add-icon {
    color: var(--bs-success);
}

/* ── Autocomplete count badge ─────────────────── */
.ac-count {
    position: absolute;
    top: 50%;
    right: 44px;    /* clears the search submit button */
    transform: translateY(-50%);
    background: var(--mt-surface-3);
    color: white;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    pointer-events: none;
    user-select: none;
    z-index: 20;
    line-height: 1;
}

/* ── Autocomplete dropdown ────────────────────── */
.ac-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    width: min(760px, calc(100vw - 24px));
    z-index: 9999;
    background: var(--mt-surface-2);
    border: 1px solid var(--mt-border-hover);
    border-radius: var(--mt-radius);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    max-height: 420px;
    overflow-y: auto;
}

/* Artists and videos side by side, each scrolling on its own */
.ac-dropdown.ac-columns:not([hidden]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    overflow: hidden;
}

.ac-columns .ac-section {
    max-height: 418px;
    overflow-y: auto;
}

.ac-columns .ac-section + .ac-section {
    border-left: 1px solid var(--mt-border);
}

.ac-heading {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 6px 12px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--mt-text-muted);
    background: var(--mt-surface-2);
    border-bottom: 1px solid var(--mt-border);
}

.ac-artist-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    font-size: 0.75rem;
    color: var(--mt-text-muted);
    background: var(--mt-surface-3);
}

/* Phones: artists and videos stay side by side, with smaller items so both columns fit */
@media (max-width: 767.98px) {
    .ac-dropdown.ac-columns:not([hidden]) {
        grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    }

    .ac-dropdown,
    .ac-columns .ac-section {
        max-height: min(420px, 60vh);
    }

    .ac-columns .ac-heading {
        padding: 5px 8px;
    }

    .ac-columns .ac-item {
        gap: 6px;
        padding: 6px 8px;
    }

    .ac-columns .ac-artist-icon {
        width: 24px;
        height: 24px;
        font-size: 0.65rem;
    }

    .ac-columns .ac-artist {
        font-size: 0.75rem;
    }

    /* Artist names in the narrow column wrap instead of being cut */
    .ac-columns .ac-item > .ac-artist {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .ac-columns .ac-thumb {
        width: 56px;
        height: 32px;
    }

    .ac-columns .ac-name {
        font-size: 0.7rem;
    }

    .ac-columns .ac-year {
        font-size: 0.65rem;
    }
}

.ac-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--mt-text);
    border-bottom: 1px solid var(--mt-border);
    transition: background var(--mt-ease);
    scroll-margin-top: 30px;    /* keep keyboard-selected items clear of the sticky heading */
}

.ac-item:last-child {
    border-bottom: none;
}

.ac-item:hover,
.ac-item.ac-active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--mt-text);
}

.ac-thumb {
    width: 80px;
    height: 45px;
    object-fit: cover;
    border-radius: var(--mt-radius-sm);
    flex-shrink: 0;
    background: var(--mt-surface-3);
}

.ac-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ac-artist {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--mt-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ac-name {
    font-size: 0.75rem;
    color: var(--mt-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ac-year {
    font-size: 0.7rem;
    color: var(--mt-text-muted);
}

/* ── Dropdown toggle arrow ────────────────────── */
.dropdown-toggle::after {
    display: inline-block;
    margin-left: 0.255em;
    vertical-align: 0.255em;
    content: "";
    border-top: 0.3em solid;
    border-right: 0.3em solid transparent;
    border-bottom: 0;
    border-left: 0.3em solid transparent;
}

/* ══════════════════════════════════════════════════
   Artists index
══════════════════════════════════════════════════ */

#artist-search {
    width: 100%;
    max-width: 360px;
    padding: 0.45rem 0.85rem;
    background: var(--mt-surface);
    border: 1px solid var(--mt-border);
    border-radius: var(--mt-radius);
    color: var(--mt-text);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--mt-ease), box-shadow var(--mt-ease);
}

#artist-search:focus {
    border-color: rgba(230, 57, 80, 0.45);
    box-shadow: 0 0 0 3px var(--mt-accent-dim);
}

#artist-search::placeholder {
    color: var(--mt-text-subtle);
}

#artistsCount {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.5rem;
    background: var(--mt-surface-2);
    border: 1px solid var(--mt-border);
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--mt-text-muted);
    vertical-align: middle;
}

/* Override inline column-count with flex wrap */
#artists {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.4rem;
    list-style: none;
    padding: 0;
    margin: 1rem 0 0;
}

#artists li {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.28rem 0.65rem 0.28rem 0.55rem;
    background: var(--mt-surface);
    border: 1px solid var(--mt-border);
    border-radius: 100px;
    font-size: 0.7rem;
    color: var(--mt-text-muted);    /* count text node inherits this */
    line-height: 1;
    transition: background var(--mt-ease), border-color var(--mt-ease);
    cursor: default;
}

#artists li:hover {
    background: var(--mt-surface-2);
    border-color: var(--mt-border-hover);
}

#artists li a {
    color: var(--mt-text);          /* artist name stands out */
    text-decoration: none;
    font-weight: 500;
    font-size: 0.825rem;
    transition: color var(--mt-ease);
}

#artists li:hover a {
    color: #fff;
}

.playlist-item {
    display: flex !important;
    margin-bottom: 0.5rem;
}
.videos-list-item {
    display: flex !important;
    margin-top: 0.5rem;
    padding: 5px;
    border-radius: var(--mt-radius-sm);
    transition: background-color var(--mt-ease);
}

.videos-list-item:hover {
    background-color: #1c1c24;
}

.playlist-item.active,
.videos-list-item.active,
.videos-list-item.active:hover {
    background-color: var(--mt-accent-dim);
}

/* The duration is 2px from the bottom and right edge of the thumbnail, so it does not cover its border. The link around
   the thumbnail is 6px taller than the image (inline-block baseline), hence the larger bottom. */
.videos-list-item .duration {
    bottom: 8px;
    right: 2px;
}

/* The video playing now: framed thumbnail, white title and a "Now playing" badge */
.videos-list-item.active .video-small-thumb {
    border-color: var(--mt-accent);
}

.videos-list-item.active a.video-title-side {
    color: #fff;
}

.videos-list-item.active .flex-shrink-0 > a.watch-link::before {
    content: "\25B6\FE0E  Now playing";
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 1;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.5;
    color: #fff;
    background: var(--mt-accent);
    border-radius: 4px;
    white-space: pre;
}

/* Prevents pointer events on iframe overlays from trapping tooltips */
iframe[src*="youtube"] {
    title: "";
}
