/* 
 * -------------------------------------------------------------------
 *  1. Основной макет страницы
 * -------------------------------------------------------------------
 */

.history-page-container {
    max-width: 920px;
    margin-top: 20px;
    margin-right: auto;
    margin-bottom: 28px;
    margin-left: auto;
    padding: 18px 22px 20px;
    background: linear-gradient(165deg, #1a1a1c 0%, #161618 100%);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.history-page-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 18px;
}

.history-page-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

/* Кнопки и селектор на общем тёмном фоне — без отдельной «полоски» */
.history-toolbar-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    justify-content: space-between;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.history-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.history-filter-slot {
    flex-shrink: 0;
    margin-left: auto;
    order: 2;
}

.history-header-actions {
    order: 1;
}

.history-action-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: rgba(39, 39, 39, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    color: #ececec;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    box-sizing: border-box;
    transition: background-color 0.18s, border-color 0.18s, transform 0.05s ease, box-shadow 0.18s;
}

.history-action-pill:hover {
    background-color: rgba(55, 55, 58, 0.98);
    border-color: rgba(255, 255, 255, 0.16);
    color: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.history-action-pill:active {
    transform: translateY(1px);
}

.history-action-pill img {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    filter: invert(1);
    opacity: 0.92;
}

.history-action-pill--clear {
    border-color: rgba(255, 82, 82, 0.35);
}

.history-action-pill--clear:hover {
    background-color: rgba(255, 82, 82, 0.12);
    border-color: rgba(255, 82, 82, 0.5);
    color: #ffcdd2;
}

.history-toolbar {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-bottom: 0;
    width: 100%;
}

.history-toolbar--playlist-style {
    max-width: 100%;
}

.history-filters {
    display: grid;
    grid-template-columns: 1fr 220px 150px 150px 170px 170px auto auto;
    gap: 12px;
    align-items: end;
}

.history-filters--compact {
    grid-template-columns: 1fr 240px auto auto auto;
    align-items: center;
}

.history-search--compact,
.history-filter--compact {
    height: 36px;
    border-radius: 999px;
}

.history-btn--small {
    height: 36px;
    border-radius: 999px;
    padding: 0 12px;
    font-size: 13px;
}

.history-search,
.history-filter,
.history-filter-label input[type="date"],
.history-filter-label input[type="number"] {
    width: 100%;
    box-sizing: border-box;
    height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid #3f3f3f;
    background: #121212;
    color: #f1f1f1;
    font-size: 14px;
    font-family: inherit;
}

.history-filter-label {
    display: grid;
    gap: 6px;
    color: #aaa;
    font-size: 12px;
}

.history-btn {
    height: 40px;
    padding: 0 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(62, 166, 255, 0.9);
    color: #0f0f0f;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}
.history-btn:hover { background: rgba(62, 166, 255, 1); }

.history-btn--ghost {
    background: rgba(255, 255, 255, 0.06);
    color: #f1f1f1;
}
.history-btn--ghost:hover { background: rgba(255, 255, 255, 0.1); }

.history-sidepanels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.history-panel {
    background: #121212;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 16px;
}
.history-panel-title {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 700;
    color: #f1f1f1;
}

.history-stats {
    display: flex;
    gap: 16px;
}
.history-stat {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 12px;
}
.history-stat-val {
    font-size: 20px;
    font-weight: 800;
    line-height: 1.2;
}
.history-stat-label {
    font-size: 12px;
    color: #aaa;
    margin-top: 4px;
}

.history-topcats {
    margin-top: 12px;
}
.history-topcats-title {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 8px;
}
.history-topcats-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 13px;
}
.history-topcats-cnt {
    color: #aaa;
}

.history-privacy-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #aaa;
    font-size: 13px;
}

.history-progress {
    position: absolute;
    left: 6px;
    right: 6px;
    bottom: 1px;
    height:4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.25);
    overflow: hidden;
}
.history-progress-bar {
    height: 100%;
    background: #3ea6ff;
}

.history-playlists-section {
    margin-bottom: 28px;
}

.history-view-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 0;
}

.history-view-filters .history-btn.is-active {
    background: rgba(62, 166, 255, 0.92);
    color: #0f0f0f;
    border-color: rgba(62, 166, 255, 0.9);
}

.history-sort-menu .sort-menu-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    background-color: rgba(39, 39, 39, 0.95);
    color: #ececec;
    transition: background-color 0.18s, border-color 0.18s;
}

.history-sort-menu {
    position: relative;
}

.history-sort-menu .sort-menu-details > summary {
    list-style: none;
}

.history-sort-menu .sort-menu-details > summary::-webkit-details-marker {
    display: none;
}

.history-sort-menu .sort-menu-details[open] .sort-menu-button {
    background-color: rgba(55, 55, 58, 0.98);
    border-color: rgba(255, 255, 255, 0.16);
}

.history-filter-slot .history-sort-menu .sort-menu-dropdown {
    left: auto;
    right: 0;
}

.history-sort-menu .sort-arrow-icon {
    width: 14px;
    height: 14px;
    filter: invert(1);
    transition: transform 0.2s;
}

.history-sort-menu .sort-menu-details[open] .sort-arrow-icon {
    transform: rotate(180deg);
}

.history-sort-menu .sort-menu-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background-color: #282828;
    border-radius: 12px;
    padding: 8px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 20;
    min-width: 220px;
}

.history-sort-menu .sort-menu-details[open] .sort-menu-dropdown {
    display: block;
}

.history-sort-menu .sort-option {
    display: block;
    padding: 10px 14px;
    color: #f1f1f1;
    text-decoration: none;
    font-size: 13px;
}

.history-sort-menu .sort-option:hover {
    background-color: #3f3f3f;
}

/* History stats modal polish */
#history-stats-modal .modal-content-small {
    width: min(420px, calc(100vw - 28px));
    border-radius: 14px;
    padding: 20px 20px 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(180deg, #242424 0%, #1a1a1c 100%);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5);
}

#history-stats-modal .modal-content-small h3 {
    margin: 0 0 12px;
    padding-right: 48px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

#history-stats-modal .modal-close-button {
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 50%;
    box-sizing: border-box;
    display: block;
    font-size: 0;
    line-height: 0;
    color: #d0d0d0;
    cursor: pointer;
    overflow: hidden;
}

#history-stats-modal .modal-close-button::before,
#history-stats-modal .modal-close-button::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 14px;
    height: 2px;
    margin: 0;
    background: currentColor;
    border-radius: 1px;
    transform-origin: center;
}

#history-stats-modal .modal-close-button::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

#history-stats-modal .modal-close-button::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

#history-stats-modal .modal-close-button:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

#history-stats-modal .history-stats {
    gap: 10px;
    margin-bottom: 12px;
}

#history-stats-modal .history-stat {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 12px;
    padding: 12px 14px;
}

#history-stats-modal .history-stat-val {
    font-size: 28px;
    line-height: 1;
    font-weight: 800;
}

#history-stats-modal .history-stat-label {
    margin-top: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
}

#history-stats-modal .history-topcats {
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

#history-stats-modal .history-topcats-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 8px;
}

.history-playlist-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.history-playlist-card {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    border-radius: 0;
    overflow: visible;
}

.history-playlist-card-link {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    text-decoration: none;
    color: inherit;
    background: transparent;
    border: none;
    transition: opacity 0.2s ease;
    flex: 1 1 auto;
    min-width: 0;
}

.history-playlist-card-link:hover {
    opacity: 0.95;
}

.history-playlist-thumb-wrap {
    position: relative;
    width: 360px;
    height: 202px;
    flex-shrink: 0;
    background: #111;
    border-radius: 12px;
    overflow: hidden;
}

.history-playlist-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.history-playlist-count {
    position: absolute;
    right: 8px;
    bottom: 8px;
    background: rgba(0, 0, 0, 0.76);
    color: #fff;
    border-radius: 6px;
    padding: 3px 7px;
    font-size: 12px;
    font-weight: 600;
}

.history-playlist-body {
    padding: 0;
    min-width: 0;
    width: 100%;
}

.history-playlist-title {
    color: #f1f1f1;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-playlist-meta {
    font-size: 14px;
    color: #aaa;
}

.history-playlist-remove-btn {
    margin-top: 8px;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: #f1f1f1;
    font-size: 12px;
    font-weight: 600;
    padding: 8px 10px;
    cursor: pointer;
}

.history-playlist-remove-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.history-playlist-menu {
    position: relative;
    flex-shrink: 0;
    margin-top: 2px;
}

.history-playlist-menu .context-menu-button {
    background: transparent;
}

.history-playlist-menu .context-menu-dropdown {
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
}

.history-menu-divider {
    border: none;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 6px 0;
}

/* 
 * -------------------------------------------------------------------
 *  3. РЎРџРРЎРћРљ Р’РР”Р•Рћ (Р’РѕР·РІСЂР°С‰РµРЅС‹ РѕСЂРёРіРёРЅР°Р»СЊРЅС‹Рµ СЃС‚РёР»Рё)
 * -------------------------------------------------------------------
 */

.history-date-header {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 14px;
    margin-top: 4px;
    padding-bottom: 6px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #3f3f3f;
    text-transform: capitalize;
}

.history-video-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 32px;
}

.history-video-item {
    display: flex;
    gap: 16px;
    position: relative;
}

.history-thumbnail-wrapper {
    position: relative;
    flex-shrink: 0;
}

.history-thumbnail {
    width: 360px;
    height: 202px;
    border-radius: 12px;
    object-fit: cover;
    display: block;
}

.history-thumbnail-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background-color: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.history-video-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex-grow: 1;
    align-items: flex-start;
}

.history-video-title {
    font-size: 18px;
    font-weight: 500;
    margin: 0 0 12px 0;
    color: #f1f1f1;
}

.history-channel-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    background-color: #272727;
    padding: 6px 12px;
    border-radius: 5px;
}

.history-channel-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s;
}

.history-channel-link:hover {
    opacity: 0.8;
}

.history-channel-name {
    font-size: 13px;
    color: #f1f1f1;
    font-weight: 500;
}

.history-channel-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.history-video-meta {
    font-size: 13px;
    color: #aaa;
    margin: 0;
}

.history-video-description {
    font-size: 13px;
    color: #aaa;
    margin-top: 12px;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}


/* 
 * -------------------------------------------------------------------
 *  4. РљРћРќРўР•РљРЎРўРќРћР• РњР•РќР® (РўР РћР•РўРћР§РР•) (Р’РѕР·РІСЂР°С‰РµРЅС‹ РѕСЂРёРіРёРЅР°Р»СЊРЅС‹Рµ СЃС‚РёР»Рё)
 * -------------------------------------------------------------------
 */

 .context-menu-container {
    position: relative;
    flex-shrink: 0;
}

.context-menu-button {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.context-menu-button:hover { 
    background-color: #272727; 
}

.context-menu-button img { 
    width: 24px; 
    height: 24px; 
    filter: invert(1); 
}

.context-menu-dropdown {
    display: none;
    position: absolute;
    top: 40px;
    right: 0;
    background-color: #282828;
    border-radius: 12px;
    padding: 8px 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    z-index: 10;
    min-width: 280px;
}

.context-menu-dropdown.opens-upward {
    top: auto;
    bottom: 40px;
}

.context-menu-dropdown.active { 
    display: block; 
}

.context-menu-dropdown a {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    color: #f1f1f1;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
}

.context-menu-dropdown a:hover { 
    background-color: #3f3f3f; 
}

.context-menu-dropdown a img { 
    width: 24px; 
    height: 24px; 
    filter: invert(1); 
}

/* 
 * ===================================================================
 *  5. РџР РћР§РР• Р РђР”РђРџРўРР’РќР«Р• РЎРўРР›Р (РЎРѕС…СЂР°РЅРµРЅС‹ РѕСЂРёРіРёРЅР°Р»СЊРЅС‹Рµ СЃС‚РёР»Рё)
 * ===================================================================
 */

.empty-page-placeholder {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 60vh;
    padding: 24px;
}
.empty-page-placeholder img {
    width: 144px;
    height: 144px;
    margin-bottom: 24px;
}
.empty-page-placeholder h2 {
    font-size: 24px;
    font-weight: 500;
    color: #f1f1f1;
    margin: 0 0 8px 0;
}
.empty-page-placeholder p {
    color: #aaa;
    font-size: 14px;
    max-width: 450px;
    line-height: 1.5;
    margin: 0;
}
.empty-page-button {
    display: inline-block;
    margin-top: 24px;
    background-color: #ffffff;
    color: #000000;
    border: none;
    border-radius: 18px;
    padding: 10px 24px;
    font-weight: 500;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
}

@media (max-width: 1024px) {
    .history-toolbar-line {
        flex-direction: column;
        align-items: stretch;
    }
    .history-header-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .history-filter-slot {
        margin-left: 0;
        width: 100%;
    }
    .history-filter-slot .history-sort-menu .sort-menu-button {
        width: 100%;
        justify-content: space-between;
    }
    .history-action-pill {
        flex: 1 1 auto;
        justify-content: center;
        min-width: 0;
    }
    .history-filters {
        grid-template-columns: 1fr 1fr;
    }
    .history-sidepanels {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .history-page-container {
        padding: 16px;
        margin: 16px;
    }
    .history-video-item {
        flex-direction: column;
        align-items: flex-start;
    }
    .history-thumbnail {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
    }
    .history-video-title {
        font-size: 16px;
    }
    .context-menu-container {
        position: absolute;
        top: 8px;
        right: 8px;
    }
}
