* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --background: #0a0e27;
    --surface: #1a1f3a;
    --surface-variant: #252d42;
    --text-primary: #ffffff;
    --text-secondary: #b0bec5;
    --accent: #FF6B6B;
    --success: #4CAF50;
    --border-color: #364558;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.header {
    background-color: var(--surface);
    padding: 16px 20px;
    border-bottom: 2px solid var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    max-width: 100%;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

.header-controls {
    display: flex;
    gap: 10px;
    flex: 1;
    max-width: 600px;
    justify-content: flex-end;
}

.search-box {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--surface-variant);
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s ease;
}

.search-box:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--surface);
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.4);
}

.search-box::placeholder {
    color: var(--text-secondary);
}

/* Buttons */
.btn-primary, .btn-secondary, .control-btn, .filter-tab {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--text-primary);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: var(--surface-variant);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
    border-color: var(--primary-color);
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    gap: 12px;
    padding: 12px;
    overflow: hidden;
}

/* Player Section */
.player-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
}

.video-container {
    position: relative;
    width: 100%;
    flex: 1;
    background-color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

video::-webkit-media-controls-panel {
    background-color: rgba(0, 0, 0, 0.5);
}

.player-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.7), rgba(33, 150, 243, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-secondary);
    pointer-events: none;
    backdrop-filter: blur(2px);
}

.player-overlay.hidden {
    display: none;
}

.player-info {
    padding: 12px 15px;
    background-color: var(--surface-variant);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 65px;
}

.channel-info {
    flex: 1;
}

.channel-info h2 {
    font-size: 16px;
    margin-bottom: 4px;
    color: var(--primary-color);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-info p {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-stats {
    font-size: 13px;
    color: var(--text-primary);
    background-color: rgba(33, 150, 243, 0.15);
    padding: 8px 14px;
    border-radius: 4px;
    font-weight: 500;
    white-space: nowrap;
    margin-left: 15px;
}

/* Playback Controls */
.playback-controls {
    display: flex;
    gap: 10px;
    padding: 12px 15px;
    background-color: var(--surface-variant);
    border-top: 1px solid var(--border-color);
    justify-content: center;
    flex-wrap: wrap;
}

.control-btn {
    background-color: var(--primary-color);
    color: var(--text-primary);
    min-width: 95px;
    font-size: 13px;
    padding: 9px 16px;
    border-radius: 6px;
}

.control-btn:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.control-btn:active {
    transform: translateY(0);
}

/* Sidebar */
.sidebar {
    width: 310px;
    background-color: var(--surface);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    border: 1px solid var(--border-color);
    min-height: 0;
}

.sidebar-header {
    padding: 13px 15px;
    border-bottom: 2px solid var(--primary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--surface-variant);
    flex-shrink: 0;
}

.sidebar-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.channel-count {
    font-size: 12px;
    color: var(--primary-color);
    background-color: rgba(33, 150, 243, 0.2);
    padding: 5px 10px;
    border-radius: 12px;
    font-weight: 600;
}

/* Filter Section */
.filter-section {
    position: relative;
    flex-shrink: 0;
    padding: 10px;
    background-color: var(--surface-variant);
    border-bottom: 1px solid var(--border-color);
}

.filter-toggle {
    width: 100%;
    padding: 10px 12px;
    background-color: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.filter-toggle:hover {
    background-color: rgba(33, 150, 243, 0.1);
    border-color: var(--primary-color);
}

.toggle-icon {
    font-size: 10px;
    transition: transform 0.3s ease;
    margin-left: 8px;
}

.filter-toggle.active .toggle-icon {
    transform: rotate(180deg);
}

.filter-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 10px;
    right: 10px;
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.filter-dropdown.show {
    display: block;
}

.filter-option {
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.filter-option:hover {
    background-color: rgba(33, 150, 243, 0.15);
    color: var(--text-primary);
}

.filter-option.active {
    background-color: rgba(33, 150, 243, 0.25);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 500;
}

/* Search Section */
.search-section {
    padding: 10px;
    background-color: var(--surface-variant);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.category-search {
    width: 100%;
    padding: 9px 12px;
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    transition: all 0.3s ease;
}

.category-search:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: rgba(33, 150, 243, 0.05);
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.2);
}

.category-search::placeholder {
    color: var(--text-secondary);
}

/* Channel Filters */
.channel-filters {
    display: flex;
    gap: 6px;
    align-items: center;
}none DEPRECATED */
.filter-tabs {
    display: none;
}

/* Channels List */
.channels-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    min-height: 0;
}

.channel-item {
    padding: 11px 12px;
    margin-bottom: 6px;
    background-color: var(--surface-variant);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary-color);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 50px;
    position: relative;
}

.channel-item.working {
    border-left-color: #4CAF50;
}

.channel-item.broken {
    border-left-color: #FF6B6B;
    opacity: 0.7;
}

.channel-item.broken .channel-item-name {
    color: #FF9999;
    text-decoration: line-through;
}

.channel-item-status {
    position: absolute;
    top: 3px;
    right: 3px;
    font-size: 10px;
    font-weight: bold;
}

.channel-item-status.working {
    color: #4CAF50;
}

.channel-item-status.broken {
    color: #FF6B6B;
}

.channel-item-status.testing {
    color: var(--primary-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.channel-item:hover {
    background-color: rgba(33, 150, 243, 0.1);
    border-left-color: var(--accent);
    box-shadow: inset 0 0 8px rgba(33, 150, 243, 0.15);
}

.channel-item.active {
    background: linear-gradient(90deg, var(--primary-color) 0%, rgba(33, 150, 243, 0.6) 100%);
    border-left-color: var(--accent);
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.35);
    font-weight: 500;
}

.channel-item-info {
    flex: 1;
    overflow: hidden;
}

.channel-item-name {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-item-group {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-item-logo {
    width: 32px;
    height: 32px;
    margin-left: 10px;
    border-radius: 4px;
    object-fit: contain;
    background-color: rgba(255, 255, 255, 0.08);
    padding: 2px;
    flex-shrink: 0;
    border: 1px solid var(--border-color);
}

.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    animation: fadeIn 0.3s ease;
    backdrop-filter: blur(3px);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-variant) 100%);
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    animation: slideUp 0.3s ease;
    border: 1px solid var(--border-color);
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    float: right;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.3s ease;
    line-height: 1;
    width: 32px;
    height: 32px;
    text-align: center;
}

.close:hover {
    color: var(--accent);
}

.modal-content h2 {
    margin-bottom: 20px;
    color: var(--primary-color);
    font-size: 18px;
    font-weight: 600;
    clear: both;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-form label {
    font-size: 13px;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--primary-color);
}

.modal-form textarea {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--background);
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 12px;
    resize: vertical;
    min-height: 100px;
    max-height: 200px;
    transition: all 0.3s ease;
}

.modal-form textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.3);
    background-color: rgba(0, 0, 0, 0.3);
}

.modal-form textarea::placeholder {
    color: var(--text-secondary);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 10px;
}

.modal-buttons button {
    min-width: 120px;
    padding: 10px 20px;
}

#infoContent {
    padding: 15px;
    background-color: rgba(33, 150, 243, 0.08);
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
}

#infoContent p {
    margin-bottom: 12px;
    line-height: 1.6;
    font-size: 13px;
}

#infoContent strong {
    color: var(--primary-color);
    font-weight: 600;
}

#infoContent code {
    background-color: var(--background);
    padding: 3px 7px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    word-break: break-all;
    border: 1px solid var(--border-color);
    display: inline-block;
    color: #FFB74D;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface-variant);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 1280px) {
    .sidebar {
        width: 280px;
    }

    .header-controls {
        max-width: 400px;
    }
}

@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 240px;
        max-height: 30vh;
    }

    .player-section {
        flex: 1;
    }

    .header-controls {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 768px) {
    .container {
        height: 100vh;
    }

    .header {
        padding: 12px 15px;
    }

    .header-content {
        flex-direction: column;
        gap: 10px;
    }

    .logo {
        font-size: 18px;
    }

    .header-controls {
        width: 100%;
        max-width: none;
    }

    .main-content {
        gap: 8px;
        padding: 8px;
        flex-direction: column;
    }

    .player-section {
        flex: 0 0 auto;
        min-height: 45vh;
    }

    .video-container {
        min-height: auto;
    }

    .playback-controls {
        gap: 6px;
        padding: 10px;
        flex-wrap: wrap;
    }

    .control-btn {
        min-width: 70px;
        padding: 8px 12px;
        font-size: 11px;
        flex: 1;
        min-width: 60px;
    }

    .player-info {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        padding: 10px 12px;
        min-height: auto;
    }

    .player-stats {
        margin-left: 0;
        font-size: 11px;
        padding: 5px 8px;
    }

    .channel-info h2 {
        font-size: 14px;
        margin-bottom: 2px;
    }

    .channel-info p {
        font-size: 11px;
    }

    .sidebar {
        width: 100%;
        height: auto;
        min-height: 35vh;
        flex-shrink: 0;
    }

    .sidebar-header {
        padding: 10px 12px;
    }

    .sidebar-header h3 {
        font-size: 14px;
    }

    .channel-count {
        font-size: 10px;
        padding: 4px 8px;
    }

    .filter-section {
        padding: 8px;
    }

    .filter-toggle {
        padding: 8px 10px;
        font-size: 12px;
    }

    .search-section {
        padding: 8px;
    }

    .category-search {
        padding: 8px 10px;
        font-size: 12px;
    }

    .channel-item {
        padding: 8px;
        min-height: 45px;
        margin-bottom: 4px;
    }

    .channel-item-name {
        font-size: 12px;
    }

    .channel-item-group {
        font-size: 10px;
    }

    .channel-item-logo {
        width: 24px;
        height: 24px;
        margin-left: 6px;
    }

    .filter-option {
        padding: 8px 10px;
        font-size: 11px;
    }

    .modal-content {
        padding: 20px;
        width: 90%;
        max-height: 80vh;
    }

    .modal-content h2 {
        font-size: 16px;
        margin-bottom: 15px;
    }

    .modal-form label {
        font-size: 12px;
    }

    .modal-form textarea {
        font-size: 11px;
        min-height: 80px;
        max-height: 150px;
    }

    .modal-buttons button {
        min-width: 100px;
        padding: 8px 16px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    * {
        /* Ensure touch targets are at least 44x44px */
        touch-action: manipulation;
    }

    body {
        font-size: 14px;
    }

    .container {
        height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .header {
        padding: 10px 12px;
        flex-shrink: 0;
    }

    .header-content {
        flex-direction: column;
        gap: 8px;
    }

    .logo {
        font-size: 16px;
        margin: 0;
    }

    .header-controls {
        width: 100%;
        gap: 6px;
    }

    .btn-primary {
        padding: 9px 14px;
        font-size: 12px;
        width: 100%;
    }

    .main-content {
        gap: 6px;
        padding: 6px;
        flex-direction: column;
        flex: 1;
        overflow: hidden;
    }

    .player-section {
        flex: 0 0 auto;
        min-height: 50%;
        max-height: 55%;
    }

    .video-container {
        min-height: auto;
        flex: 1;
    }

    video {
        width: 100%;
        height: 100%;
    }

    .player-overlay {
        font-size: 14px;
    }

    .player-info {
        padding: 8px 10px;
        min-height: auto;
        gap: 6px;
    }

    .channel-info h2 {
        font-size: 12px;
        margin-bottom: 2px;
    }

    .channel-info p {
        font-size: 10px;
        margin: 0;
    }

    .player-stats {
        font-size: 10px;
        padding: 4px 6px;
        margin-left: 0;
    }

    .playback-controls {
        padding: 6px 8px;
        gap: 4px;
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .control-btn {
        flex: 1;
        min-width: 50px;
        padding: 6px 8px;
        font-size: 10px;
        white-space: nowrap;
    }

    .sidebar {
        width: 100%;
        height: auto;
        min-height: 40%;
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .sidebar-header {
        padding: 8px 10px;
        flex-shrink: 0;
        gap: 8px;
    }

    .sidebar-header h3 {
        font-size: 12px;
        margin: 0;
    }

    .channel-count {
        font-size: 9px;
        padding: 3px 6px;
    }

    .filter-section {
        padding: 6px;
        flex-shrink: 0;
    }

    .filter-toggle {
        padding: 8px;
        font-size: 11px;
    }

    .toggle-icon {
        font-size: 9px;
        margin-left: 4px;
    }

    .filter-dropdown {
        max-height: 200px;
    }

    .filter-option {
        padding: 8px;
        font-size: 11px;
    }

    .search-section {
        padding: 6px;
        flex-shrink: 0;
    }

    .category-search {
        padding: 8px;
        font-size: 12px;
        border-radius: 4px;
    }

    .channels-list {
        flex: 1;
        overflow-y: auto;
        padding: 6px;
    }

    .channel-item {
        padding: 7px;
        min-height: 44px;
        margin-bottom: 3px;
        border-radius: 4px;
    }

    .channel-item-info {
        flex: 1;
    }

    .channel-item-name {
        font-size: 11px;
        margin-bottom: 2px;
    }

    .channel-item-group {
        font-size: 9px;
    }

    .channel-item-logo {
        display: none;
    }

    .modal {
        background-color: rgba(0, 0, 0, 0.9);
    }

    .modal-content {
        padding: 16px;
        width: 92%;
        max-height: 85vh;
        border-radius: 8px;
    }

    .modal-content h2 {
        font-size: 14px;
        margin-bottom: 12px;
    }

    .modal-form {
        gap: 10px;
    }

    .modal-form label {
        font-size: 11px;
        margin-bottom: 4px;
    }

    .modal-form textarea {
        padding: 8px;
        font-size: 11px;
        min-height: 70px;
        max-height: 120px;
        border-radius: 4px;
    }

    .modal-buttons {
        gap: 8px;
        margin-top: 8px;
    }

    .modal-buttons button {
        flex: 1;
        min-width: auto;
        padding: 8px 12px;
        font-size: 11px;
    }

    .close {
        font-size: 24px;
        width: 28px;
        height: 28px;
    }

    #infoContent {
        padding: 12px;
        border-radius: 4px;
        font-size: 11px;
    }

    #infoContent p {
        margin-bottom: 8px;
        line-height: 1.4;
        font-size: 10px;
    }

    #infoContent strong {
        font-size: 11px;
    }

    #infoContent code {
        font-size: 9px;
        word-break: break-all;
    }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .header {
        padding: 8px 12px;
    }

    .logo {
        font-size: 14px;
    }

    .player-section {
        min-height: 65vh;
    }

    .sidebar {
        height: 30vh;
        max-height: 30vh;
    }

    .playback-controls {
        padding: 6px 8px;
    }

    .control-btn {
        min-width: 60px;
        padding: 6px 10px;
        font-size: 10px;
    }
}

@media (max-width: 480px) and (orientation: landscape) {
    .main-content {
        flex-direction: row;
    }

    .player-section {
        flex: 1;
        min-height: auto;
    }

    .sidebar {
        min-height: auto;
        max-width: 35%;
        flex: 0 0 35%;
    }

    .playback-controls {
        flex-direction: column;
        gap: 3px;
    }

    .control-btn {
        padding: 4px 6px;
        font-size: 9px;
    }

    .channel-item {
        min-height: 38px;
        padding: 6px;
    }

    .channel-item-name {
        font-size: 10px;
    }
}


/* Error & Success Messages */
.error-message {
    background-color: rgba(255, 107, 107, 0.15);
    border: 1px solid var(--accent);
    color: #FF6B6B;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 13px;
}

.success-message {
    background-color: rgba(76, 175, 80, 0.15);
    border: 1px solid var(--success);
    color: #4CAF50;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 13px;
}
