body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #1a2634 0%, #2c3e50 100%);
        color: #ecf0f1;
    }
}

body.dark-mode {
    background: linear-gradient(135deg, #1a2634 0%, #2c3e50 100%);
    color: #ecf0f1;
}

body.green-theme {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
}
body.green-theme.dark-mode {
    background: linear-gradient(135deg, #1b5e20 0%, #2e7d32 100%);
}
body.green-theme button {
    background: linear-gradient(135deg, #2e7d32 0%, #4caf50 100%);
}
body.purple-theme {
    background: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%);
}
body.purple-theme.dark-mode {
    background: linear-gradient(135deg, #4a148c 0%, #6a1b9a 100%);
}
body.purple-theme button {
    background: linear-gradient(135deg, #6a1b9a 0%, #ab47bc 100%);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: linear-gradient(90deg, #14212f 0%, #1e3449 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 10;
}

.logo {
    font-size: clamp(18px, 2vw, 24px);
    font-weight: bold;
}

.header-logo {
    max-width: 100%;
    height: auto;
    max-height: 40px;
    object-fit: contain;
    vertical-align: middle;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
}

input:checked + .slider {
    background-color: #2196F3;
}

input:focus + .slider {
    box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 28px;
}

.slider.round:before {
    border-radius: 50%;
}

main {
    padding: 15px;
    max-width: 1400px;
    margin: 0 auto;
    flex: 1;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#controls-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
}

.dark-mode #controls-container {
    background: #343a40;
}

.controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.first-row, .second-row {
    justify-content: space-between;
}

.first-row input,
.first-row button,
.second-row .export-group,
.second-row button {
    flex: 1 1 calc(25% - 10px);
    min-width: 150px;
}

.export-group {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    align-items: center;
}

.filters, .settings {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.filter-group, .setting-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label, .setting-group label {
    font-size: 0.9rem;
}

button, select, input {
    padding: 10px;
    font-size: 0.9rem;
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

input, select {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid transparent;
}

input:focus, select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

body.dark-mode input, body.dark-mode select {
    background: rgba(52, 73, 94, 0.9);
    color: #ecf0f1;
}

button {
    background: linear-gradient(135deg, #0056b3 0%, #007bff 100%);
    color: white;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

button#stopCheck {
    background: linear-gradient(135deg, #c82333 0%, #dc3545 100%);
}

button#exportLinks {
    background: linear-gradient(135deg, #218838 0%, #28a745 100%);
}

button#clearHistory {
    background: linear-gradient(135deg, #5a6268 0%, #6c757d 100%);
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.history-container, #groupsContainer, #favoritesContainer, #resultsContainer, #comparisonContainer {
    margin: 15px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(8px);
    overflow-x: auto;
}

body.dark-mode .history-container, body.dark-mode #groupsContainer, 
body.dark-mode #favoritesContainer, body.dark-mode #resultsContainer, 
body.dark-mode #comparisonContainer {
    background: rgba(0, 0, 0, 0.8);
}

.history-container h2, #groupsContainer h2, #favoritesContainer h2, 
#resultsContainer h2, #comparisonContainer h2 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
    color: #007bff;
}

body.dark-mode .history-container h2, body.dark-mode #groupsContainer h2, 
body.dark-mode #favoritesContainer h2, body.dark-mode #resultsContainer h2, 
body.dark-mode #comparisonContainer h2 {
    color: #00c6ff;
}

#historyList, #groupsList {
    list-style: none;
    padding: 0;
    max-height: 150px;
    overflow-y: auto;
}

#historyList li, #groupsList li {
    padding: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#historyList li:hover, #groupsList li:hover {
    background: rgba(0, 123, 255, 0.1);
}

body.dark-mode #historyList li, body.dark-mode #groupsList li {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#progressBar {
    margin: 10px 0;
    position: relative;
    width: 100%;
    height: 25px;
    background: linear-gradient(90deg, #e0e0e0 0%, #f0f0f0 100%);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 1px 6px rgba(0, 0, 0, 0.2);
}

#progress {
    width: 100%;
    height: 100%;
    position: relative;
    background: rgba(0, 123, 255, 0.15);
    border-radius: 12px;
    overflow: hidden;
}

.progress-inner {
    position: absolute;
    height: 100%;
    width: 0;
    background: linear-gradient(45deg, #007bff 0%, #00c6ff 100%);
    transition: width 0.5s ease-in-out;
}

#progressText {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

body.dark-mode #progressBar {
    background: linear-gradient(90deg, #2c3e50 0%, #34495e 100%);
}

body.dark-mode .progress-inner {
    background: linear-gradient(45deg, #00c6ff 0%, #007bff 100%);
}

#resultsContainer, #favoritesContainer, #comparisonContainer {
    max-height: 50vh;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    background: rgba(1, 139, 31, 0.863);
    color: #fff;
    padding: 8px;
    text-align: left;
    font-weight: 500;
    border-bottom: 2px solid #007bff;
    position: sticky;
    top: 0;
    z-index: 1;
    white-space: nowrap;
}

body.dark-mode th {
    background: rgba(0, 123, 255, 0.2);
}

td {
    padding: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 0;
}

body.dark-mode td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

tr:hover {
    background: rgba(0, 123, 255, 0.05);
}

body.dark-mode tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

th:first-child, td:first-child { width: 10%; min-width: 50px; }
th:nth-child(2), td:nth-child(2) { width: 35%; min-width: 120px; }
th:nth-child(3), td:nth-child(3) { width: 25%; min-width: 100px; }
th:nth-child(4), td:nth-child(4) { width: 15%; min-width: 70px; }
th:last-child, td:last-child { width: 15%; min-width: 90px; }

td:last-child {
    display: flex;
    gap: 5px;
    padding: 5px 8px;
}

.channel-logo {
    width: 30px;
    height: 30px;
    object-fit: cover;
    border-radius: 6px;
    vertical-align: middle;
}

.action-btn {
    border: none;
    border-radius: 4px;
    padding: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-btn { background: #2196F3; color: white; }
.external-btn { background: #4CAF50; color: white; }
.favorite-btn { background: #ffca28; color: #333; }

.play-btn:hover { background: #1976D2; }
.external-btn:hover { background: #45a049; }
.favorite-btn:hover { background: #ffb300; }

#videoPlayerOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#videoPlayerContainer {
    position: relative;
    width: 90%;
    max-width: 900px;
    background: #000;
    border-radius: 6px;
}

#streamPlayer {
    width: 100%;
    height: auto;
    max-height: 90vh;
    border-radius: 6px;
}

#closePlayer {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#closePlayer:hover {
    background: rgba(255, 255, 255, 0.3);
}

.hidden {
    display: none !important;
}

#notificationOverlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 1000;
}

#notificationPopup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.98);
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    padding: 20px;
    text-align: center;
    max-width: 90%;
    width: 350px;
}

body.dark-mode #notificationPopup {
    background: rgba(44, 62, 80, 0.98);
}

#notificationPopup h2 {
    color: #007bff;
    margin: 0 0 15px 0;
    font-size: 1.2rem;
}

body.dark-mode #notificationPopup h2 {
    color: #00c6ff;
}

#resultStats {
    margin: 15px 0;
    line-height: 1.5;
    color: #333;
    font-size: 0.95rem;
}

body.dark-mode #resultStats {
    color: #ecf0f1;
}

#closePopup {
    margin-top: 20px;
    padding: 10px 25px;
    background: linear-gradient(135deg, #0056b3 0%, #007bff 100%);
    border: none;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#closePopup:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

footer {
    margin-top: auto;
    padding: 15px;
    text-align: center;
    background: rgba(20, 33, 47, 0.95);
    color: #fff;
    font-size: 0.9rem;
}

/* Desktop Responsiveness */
@media (min-width: 1024px) {
    .controls-row.first-row, .controls-row.second-row {
        flex-wrap: nowrap;
    }
    .filters, .settings {
        grid-template-columns: repeat(3, 1fr);
    }
    table {
        font-size: 0.95rem;
    }
    th, td {
        padding: 10px;
    }
    .channel-logo {
        width: 35px;
        height: 35px;
    }
    .action-btn {
        width: 30px;
        height: 30px;
    }
}

/* Tablet Responsiveness */
@media (max-width: 1023px) and (min-width: 768px) {
    header {
        padding: 10px 15px;
    }
    main {
        padding: 10px;
    }
    .first-row input,
    .first-row button,
    .second-row .export-group,
    .second-row button {
        flex: 1 1 calc(50% - 10px);
    }
    .filters, .settings {
        grid-template-columns: repeat(2, 1fr);
    }
    #historyList, #groupsList {
        max-height: 120px;
    }
    table {
        font-size: 0.85rem;
    }
    th, td {
        padding: 6px;
    }
    .channel-logo {
        width: 25px;
        height: 25px;
    }
    .action-btn {
        width: 25px;
        height: 25px;
    }
}

/* Mobile Responsiveness */
@media (max-width: 767px) {
    header {
        padding: 8px 12px;
    }
    .logo {
        font-size: clamp(16px, 3.5vw, 20px);
    }
    .header-logo {
        max-height: 35px;
    }
    .switch {
        width: 45px;
        height: 25px;
    }
    .slider:before {
        height: 18px;
        width: 18px;
    }
    input:checked + .slider:before {
        transform: translateX(20px);
    }
    main {
        padding: 8px;
    }
    #controls-container {
        padding: 10px;
    }
    .controls-row {
        flex-direction: column;
        gap: 8px;
    }
    .first-row input,
    .first-row button,
    .second-row .export-group,
    .second-row button {
        flex: 1 1 100%;
        min-width: 0;
    }
    .export-group {
        flex-direction: column;
    }
    .filters, .settings {
        grid-template-columns: 1fr;
    }
    #historyList, #groupsList {
        max-height: 100px;
    }
    table {
        font-size: 0.8rem;
    }
    th, td {
        padding: 5px;
    }
    .channel-logo {
        width: 20px;
        height: 20px;
    }
    .action-btn {
        width: 22px;
        height: 22px;
    }
    #videoPlayerContainer {
        width: 95%;
    }
    #notificationPopup {
        width: 90%;
        max-width: 300px;
    }
    footer {
        font-size: 0.8rem;
    }
}