/* Reset & Variables */
:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-card: #242424;
    --accent-primary: #4ecdc4;
    --accent-secondary: #ff6b6b;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #333333;
    --success: #4caf50;
    --error: #f44336;
    --warning: #ff9800;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* App Layout */
.app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.header__logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header__logo h1 {
    font-size: 28px;
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header__badge {
    background: var(--bg-card);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
}

.header__search {
    min-width: 300px;
}

.search-input {
    width: 100%;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.1);
}

/* Main Content */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Player Section */
.player-section {
    width: 100%;
}

.player-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.player-element {
    width: 100%;
    height: 100%;
}

.player-element video,
.player-element iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Loading Indicator */
.player__loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-primary);
    z-index: 10;
    background: rgba(0, 0, 0, 0.8);
    padding: 30px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-card);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error Indicator */
.player__error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-primary);
    z-index: 10;
    background: rgba(0, 0, 0, 0.9);
    padding: 40px;
    border-radius: 16px;
    min-width: 300px;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 15px;
    display: block;
}

#errorMessage {
    margin-bottom: 20px;
    color: var(--error);
}

.error__retry {
    background: var(--accent-primary);
    color: #000;
    border: none;
    padding: 10px 30px;
    border-radius: 30px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.error__retry:hover {
    background: var(--accent-secondary);
    transform: translateY(-2px);
}

/* Channels Section */
.channels-section {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 20px;
}

.channels-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.channels-header h2 {
    font-size: 20px;
    color: var(--text-primary);
}

.channel-count {
    background: var(--bg-card);
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 14px;
    color: var(--accent-primary);
}

.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding: 5px;
}

/* Channel Card */
.channel-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.channel-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-primary);
    box-shadow: 0 5px 20px rgba(78, 205, 196, 0.2);
}

.channel-card.active {
    border-color: var(--accent-primary);
    background: #2a2a2a;
}

.channel-card.active::before {
    content: '▶';
    position: absolute;
    top: 5px;
    right: 5px;
    color: var(--accent-primary);
    font-size: 12px;
}

.channel-id {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 15px;
    word-break: break-word;
}

.channel-type {
    display: inline-block;
    padding: 4px 10px;
    background: var(--bg-secondary);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.channel-type[data-type="hls"] { color: #4ecdc4; }
.channel-type[data-type="dash"] { color: #ff6b6b; }
.channel-type[data-type="iframe"] { color: #ffd93d; }

/* Footer */
.footer {
    margin-top: 40px;
    padding: 20px 0;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.footer__links {
    display: flex;
    gap: 10px;
}

.footer__links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer__links a:hover {
    color: var(--accent-primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal__content {
    background: var(--bg-secondary);
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

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

.modal__close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.3s ease;
}

.modal__close:hover {
    color: var(--error);
}

.modal__body {
    padding: 20px;
}

.modal__body ul {
    margin: 15px 0;
    padding-left: 20px;
}

.modal__body li {
    margin: 10px 0;
    color: var(--text-secondary);
}

.modal__body hr {
    margin: 20px 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-card);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .app {
        padding: 10px;
    }
    
    .header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .header__search {
        min-width: auto;
    }
    
    .channels-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    .footer {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.channel-card {
    animation: fadeIn 0.3s ease;
}