:root {
    --bg-color: #121212;
    --sidebar-bg: #1e1e1e;
    --text-color: #ffffff;
    --text-secondary: #aaaaaa;
    --accent-color: #304098;
    --hover-color: #303030;
    --player-bg: #000000;
    --epg-bg: #252525;
    --header-bg: #1a1a1a;
    --dialog-bg: #2c2c2c;
    --dialog-border: #444;
    --input-bg: #333;
    --input-border: #555;
    --button-primary: #4CAF50;
    --button-primary-hover: #45a049;
    --button-secondary: #3f51b5;
    --button-secondary-hover: #5c6bc0;
    --button-danger: #f44336;
    --button-danger-hover: #d32f2f;
    --radius:6px;
    --fg:#f2f6ff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
}
/* Для всех браузеров */
::-webkit-scrollbar {
    display: none;
}

body {
    -ms-overflow-style: none;  /* IE и Edge */
    scrollbar-width: none;     /* Firefox */
}

#header {
    height: 60px;
    background-color: var(--header-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    font-size: 14px;
    flex-shrink: 0;
    flex-wrap: wrap-reverse;
}

.header-section {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 2px 0;
}

.header-button {
    background-color: var(--epg-bg);
    color: white;
    border: none;
    text-align: center;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
    -webkit-appearance: none;
}

.header-button:hover {
    background-color: #383838;
}

#app-title {
    font-size: 1.1rem;
    color: var(--text-color);
    white-space: nowrap;
    font-weight: 600;
}

#main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    flex-direction: row;
    min-height: 0;
}

.time-zone-info {
    text-align: center;
    font-size: 12px;
}

.welcome-text {
    text-align: center;
    margin-bottom: 20px;
    color: #959494;
    font-size: 14px;
    line-height: 1.5;
}

.welcome-text strong {
    color: #959494;
}

.form-hint {
    text-align: center;
    margin-bottom: 20px;
    color: #959494;
    font-size: 14px;
    line-height: 1.5;
}

a {
    text-align: center;
    margin-bottom: 20px;
    color: #959494;
    font-size: 14px;
    line-height: 1.5;
}

p {
    text-align: center;
    margin-bottom: 20px;
    color: #959494;
    font-size: 14px;
    line-height: 1.5;
}

.text-primary {
    color: #cfcece !important;
}

#sidebar {
    width: 28%;
    min-width: 200px;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

#filter-controls {
    padding: 8px;
    border-bottom: 1px solid var(--hover-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#group-filter {
    width: 100%;
    padding: 8px;
    font-size: 0.9rem;
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--hover-color);
    border-radius: 6px;
    -webkit-appearance: none;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

#search {
    width: 100%;
    padding: 8px 32px 8px 8px;
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--hover-color);
    border-radius: 4px;
    font-size: 14px;
}

.search-clear {
    position: absolute;
    right: 8px;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    display: none;
    transition: color 0.2s;
}

.search-clear:hover {
    color: var(--text-color);
}

#channels-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
}

.channel-item {
    display: flex;
    padding: 10px;
    cursor: pointer;
    border-radius: 6px;
    margin-bottom: 6px;
    transition: all 0.2s;
    background-color: var(--hover-color);
    box-shadow:
            0 12px 50px rgba(0,0,0,.45),
            0 0 0 1px rgba(255,255,255,.06),
            0 0 50px rgba(76,175,80,.18);
    justify-content: space-between;
    align-items: center;
}

.channel-item:hover {
    background-color: #383838;
    transform: translateY(-1px);
}

.channel-item.active {
    background-color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(63, 81, 181, 0.3);
}

.channel-logo {
    width: 3vw;
    height: 5vh;
    margin-right: 10px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 4px;
}

.channel-info {
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

.channel-name {
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

.channel-program {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-progress-container {
    width: 100%;
    height: 3px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin: 4px 0;
    overflow: hidden;
}

.channel-progress-bar {
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--button-primary), #66BB6A);
    transition: width 0.3s ease;
}

#main-content {
    width: 75%;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
}

#player-container {
    width: 100%;
    position: relative;
    background-color: var(--player-bg);
    flex-shrink: 0;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

#player-container iframe,
#player-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#epg-container {
    flex-grow: 1;
    background-color: var(--epg-bg);
    overflow: auto;
    padding: 12px;
    -webkit-overflow-scrolling: touch;
}

.epg-program-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.epg-program-item {
    padding: 12px;
    border-radius: var(--radius);
    background: linear-gradient(180deg, #252525, #11151faa);
    box-shadow:
            0 12px 50px rgba(0,0,0,.45),
            0 0 0 1px rgba(255,255,255,.06),
            0 0 80px rgba(76,175,80,.18);
    border:1px solid rgba(102,187,106,.18);
    color:var(--fg);
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    transition: background-color 0.2s;
    border-left: 3px solid transparent;
}

.epg-program-item:hover {
    background-color: #383838;
}

.current-program {
    background-color: rgba(76, 175, 80, 0.1);
    border-left-color: #36f607;
}

.epg-program-time {
    color: var(--text-secondary);
    min-width: 120px;
    font-weight: 500;
}

.epg-program-title {
    flex-grow: 1;
    padding-left: 12px;
    font-weight: 500;
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    /*border: 2px solid var(--text-secondary);*/
    border-top: 2px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

.no-results {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.error {
    padding: 20px;
    text-align: center;
    color: var(--button-danger);
    font-size: 0.9rem;
}

/* Dialog styles */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: var(--radius);
    background: linear-gradient(180deg, #252525, #11151faa);
    box-shadow:
            0 12px 50px rgba(0,0,0,.45),
            0 0 0 1px rgba(255,255,255,.06),
            0 0 80px rgba(76,175,80,.18);
    border:1px solid rgba(102,187,106,.18);
    padding:28px;
    color:var(--fg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.dialog-overlay.active {
    opacity: 1;
    visibility: visible;
}

.dialog {
    background-color: var(--dialog-bg);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    transform: translateY(30px) scale(0.95);
    transition: all 0.3s ease;
    border: 1px solid var(--dialog-border);
}

.dialog-overlay.active .dialog {
    transform: translateY(0) scale(1);
}

.dialog-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--dialog-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dialog-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
}

.dialog-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.dialog-close:hover {
    background-color: var(--hover-color);
    color: var(--text-color);
}

.dialog-body {
    padding: 24px;
}

.dialog-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--dialog-border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.dialog-tabs {
    display: flex;
    border-bottom: 1px solid var(--dialog-border);
    margin-bottom: 20px;
}

.dialog-tab {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
}

.dialog-tab:hover {
    background-color: var(--hover-color);
}

.dialog-tab.active {
    border-bottom-color: var(--button-primary);
    color: var(--button-primary);
}

.dialog-content {
    display: none;
}

.dialog-content.active {
    display: block;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 12px;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(63, 81, 181, 0.2);
}

.btn {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    -webkit-appearance: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    /*background-color: var(--button-primary);*/
    background-color: transparent;
    border: 1px solid var(--input-border);
    color: var(--text-color);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--button-primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--button-secondary);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--button-secondary-hover);
    transform: translateY(-1px);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--input-border);
    color: var(--text-color);
}

.btn-outline:hover {
    background-color: var(--hover-color);
}

.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

.file-input-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background-color: var(--button-secondary);
    color: white;
    text-align: center;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
}

.file-input-btn:hover {
    background-color: var(--button-secondary-hover);
}

.file-input {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-name {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    word-break: break-all;
}

.status-message {
    padding: 12px;
    margin: 12px 0;
    border-radius: 6px;
    font-size: 0.9rem;
    display: none;
}

.status-success {
    background-color: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
    border: 1px solid rgba(76, 175, 80, 0.3);
    display: block;
}

.status-error {
    background-color: rgba(244, 67, 54, 0.2);
    color: #f44336;
    border: 1px solid rgba(244, 67, 54, 0.3);
    display: block;
}


/* =================================================================
   АДАПТИВНОСТЬ - ОБЪЕДИНЕННАЯ ВЕРСИЯ
   Элементы из первого блока + расположение из второго блока
   ================================================================= */

/* Для больших экранов */
@media (min-width: 1440px) {
    body {
        overflow: hidden;
        height: 100vh;
    }

    #header {
        min-height: 70px;
        padding: 8px 30px;
    }

    #main-container {
        height: calc(100vh - 70px);
        overflow: hidden;
    }

    #sidebar {
        width: 28%;
        min-width: 200px;
    }

    #main-content {
        width: 72%;
    }
}

@media (min-width: 1280px) {
    body {
        overflow: hidden;
        height: 100vh;
    }

    #header {
        min-height: 70px;
        padding: 8px 20px;
    }

    #main-container {
        height: calc(100vh - 70px);
        overflow: hidden;
    }

    #sidebar {
        width: 28%;
        min-width: 200px;
    }

    #main-content {
        width: 72%;
    }
}

@media (min-width: 960px) {
    #header {
        min-height: 70px;
        padding: 8px 20px;
    }

    #main-container {
        height: calc(100vh - 70px);
        overflow: hidden;
    }

    #sidebar {
        width: 28%;
        min-width: 200px;
    }

    #main-content {
        width: 72%;
    }
}

/* Планшеты (ландшафтная ориентация) и небольшие ноутбуки */
@media (min-width: 769px) and (max-width: 1279px) and (orientation: landscape) {
    #header {
        min-height: 70px;
        padding: 8px 30px;
    }

    #main-container {
        height: calc(100vh - 70px);
    }

    #sidebar {
        width: 35%;
        min-width: 220px;
    }

    #main-content {
        width: 75%;
    }

    #player-container {
        aspect-ratio: 16 / 9;
        max-height: 100vh;
    }

    .channel-logo {
        width: 2.5vw;
        height: 4vh;
    }

    .epg-program-item {
        flex-direction: column;
        gap: 4px;
    }

    .epg-program-time {
        min-width: unset;
    }

    #epg-container {
        display: none;
    }

    .search-container {
        display: none;
    }

    #player {
        width: 100% !important;
    }
}

@media (max-width: 959px) {
    .logo-text {
        display: none;
    }

    .time-zone-info {
        font-size: 12px;
    }

    .current-time {
        font-size: 16px;
    }

    .epg-program-item {
        grid-template-columns: repeat(2, 1fr);
        max-height: 100px;
        gap: 6px;
    }
}

/* Планшеты (портретная ориентация) */
@media (min-width: 481px) and (max-width: 1023px) and (orientation: portrait) {
    #header {
        min-height: 116px;
        padding: 0px 0px;
        gap: 0px;
    }

    .header-top {
        flex-wrap: nowrap;
    }

    .header-button {
        padding: 6px 12px;
        font-size: 12px;
    }

    .time-zone-info {
        font-size: 12px;
        text-align: center;
    }

    #main-container {
        flex-direction: column;
        height: calc(100vh - 70px);
    }

    /* Плеер под навбаром */
    #main-content {
        width: 100%;
        height: auto;
        flex-shrink: 0;
        order: 1;
    }

    #player-container {
        aspect-ratio: 16/9;
        max-height: 50vh;
        min-height: 250px;
    }

    /* Скрыть программу передач */
    #epg-container {
        display: none !important;
    }

    /* Сайдбар под плеером занимает все свободное место */
    #sidebar {
        width: 100%;
        min-width: unset;
        flex: 1;
        min-height: 0;
        order: 2;
        flex-direction: column;
    }

    #filter-controls {
        width: 100%;
        flex-direction: row;
        gap: 12px;
        padding: 12px;
        border-bottom: 1px solid var(--hover-color);
        flex-shrink: 0;
    }

    #group-filter {
        width: 100%;
    }

    #search {
        width: 55%;
    }

    #channels-list {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
        padding: 8px;
    }

    .channel-logo {
        width: 32px;
        height: 32px;
    }

    .channel-name {
        font-size: 0.8rem;
    }

    .channel-program {
        font-size: 0.7rem;
    }

    .search-container {
        display: none;
    }

    .dialog {
        width: 95%;
        max-width: 95%;
        margin: 0 auto;
    }

    .dialog-body {
        padding: 12px;
    }

    .dialog-footer {
        padding: 8px 12px;
    }

    .btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}

/* Мобильные телефоны (портретная ориентация) */
@media (max-width: 480px) and (orientation: portrait) {
    #header {
        min-height: 20vh;
        padding: 8px 20px;
        gap: 0px;
    }

    .header-top {
        flex-wrap: nowrap;
    }

    .header-left {
        flex: 1;
        min-width: 0;
    }

    .header-right {
        flex-shrink: 0;
        gap: 6px;
    }

    #app-title {
        font-size: 0.9rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-button {
        padding: 0px 0px;
        font-size: 11px;
        min-width: 54px;
    }

    .time-zone-info {
        font-size: 11px;
        text-align: center;
    }

    .header-center {
        margin-top: 2px;
    }

    #main-container {
        flex-direction: column;
        height: calc(100vh - 70px);
    }

    /* Плеер под навбаром */
    #main-content {
        width: 100%;
        height: auto;
        flex-shrink: 0;
        order: 1;
    }

    #player-container {
        aspect-ratio: 16/9;
        max-height: 40vh;
        min-height: 200px;
    }

    /* Скрыть программу передач */
    #epg-container {
        display: none !important;
    }

    /* Сайдбар под плеером занимает все свободное место */
    #sidebar {
        width: 100%;
        min-width: unset;
        flex: 1;
        min-height: 0;
        order: 2;
    }

    #filter-controls {
        padding: 8px;
        border-bottom: 1px solid var(--hover-color);
        flex-shrink: 0;
    }

    #channels-list {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }

    .channel-logo {
        width: 24px;
        height: 24px;
    }

    .channel-name {
        font-size: 0.8rem;
    }

    .channel-program {
        font-size: 0.7rem;
    }

    .dialog {
        width: 95%;
        max-width: 95%;
        margin: 0 auto;
    }

    .dialog-body {
        padding: 12px;
    }

    .dialog-footer {
        padding: 8px 12px;
    }

    .btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .search-container {
        display: none;
    }
}

/* Подсветка активной записи на любой кнопке с этим классом */
.header-button.recording-active{
    background-color: var(--button-danger) !important;
    border-color: var(--button-danger) !important;
    color:#fff !important;
}
.header-button.recording-active:hover{
    background-color: var(--button-danger-hover) !important;
}
#record-segment{
    width: 100%;
    padding: 8px;
    font-size: 0.9rem;
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--hover-color);
    border-radius: 6px;
    -webkit-appearance: none;
}

/* конец основной таблици */

       /* Убираем стили кнопок для языковых переключателей */
   .lang-btn lang-switcher {
       background: none !important;
       border: none !important;
       padding: 0 !important;
       margin: 0 2px !important;
       color: inherit !important;
       font-size: inherit !important;
       text-decoration: none !important;
       cursor: pointer !important;
       box-shadow: none !important;
       outline: none !important;
   }

/* Стили для активного языка */
.lang-btn.active{
    font-weight: bold !important;
    color: #fff !important; /* или любой цвет для выделения */
}

/* Hover эффект */
.lang-btn:hover {
    opacity: 0.7 !important;
}

#filter-controls {
    display: grid !important;
    grid-template-columns: 1fr auto; /* [селект] ... [звезда] */
    gap: 8px;
}
#group-filter { grid-column: 1/2; }
#favorites-filter-btn { grid-column: 2/3; justify-self: end; }
#filter-controls .search-container { grid-column: 1/3; } /* поиск на вторую строку, на всю ширину */
