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

:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3a3a3a;
    --bg-hover: #404040;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --accent-primary: #4a9eff;
    --accent-hover: #6bb0ff;
    --success: #4caf50;
    --warning: #ff9800;
    --error: #f44336;
    --border: #404040;
}

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

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.header {
    background: var(--bg-secondary);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.header-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.logo-image {
    height: 50px;
    width: auto;
    object-fit: contain;
}

.header h1 {
    font-size: 20px;
    font-weight: 600;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex: 1;
    max-width: 800px;
}

.url-input-container {
    flex: 1;
    display: flex;
}

.url-input {
    flex: 1;
    padding: 10px 15px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
}

.url-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-history {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    white-space: nowrap;
}

.btn-history:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.btn-history .history-icon {
    font-size: 18px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.btn-history .history-text {
    font-weight: 600;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 350px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid var(--border);
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.tab-btn:hover:not(.active) {
    background: var(--bg-hover);
}

/* Favorites Actions */
.favorites-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    padding: 0;
}

.btn-export,
.btn-import {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-export:hover {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.btn-import:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.search-input {
    width: 100%;
    padding: 10px 15px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Channels List */
.channels-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.channels-list::-webkit-scrollbar {
    width: 8px;
}

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

.channels-list::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.channels-list::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 10px;
}

.empty-hint {
    font-size: 13px;
    opacity: 0.7;
}

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

.group-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.channel-item:hover {
    background: var(--bg-hover);
    transform: translateX(4px);
}

.channel-item.active {
    background: rgba(74, 158, 255, 0.2);
    border-color: var(--accent-primary);
}

.channel-logo,
.channel-logo-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.channel-logo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    font-size: 20px;
}

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

.channel-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-fav-mini {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-fav-mini:hover {
    background: var(--bg-hover);
    transform: scale(1.1);
}

.btn-fav-mini.active {
    border-color: #ffc107;
}

/* Player Container */
.player-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #000;
}

.player-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#videoPlayer {
    width: 100%;
    height: 100%;
    background: #000;
}

.player-overlay,
.loading-indicator,
.error-indicator {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.9);
}

.overlay-content {
    text-align: center;
    padding: 40px;
}

.overlay-content h2 {
    font-size: 28px;
    margin-bottom: 15px;
}

.overlay-content p {
    font-size: 16px;
    color: var(--text-secondary);
}

.loading-indicator {
    display: none;
    flex-direction: column;
    gap: 20px;
}

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

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

.error-indicator {
    display: none;
}

.error-content {
    text-align: center;
    padding: 40px;
    max-width: 500px;
}

.error-icon {
    font-size: 64px;
    display: block;
    margin-bottom: 20px;
}

.error-content h3 {
    font-size: 24px;
    margin-bottom: 15px;
    color: var(--error);
}

.error-content p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 25px;
}

/* Current Channel Info */
.current-channel-info {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.channel-details h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.channel-details p {
    font-size: 13px;
    color: var(--text-secondary);
}

.channel-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-cast {
    width: 48px;
    height: 48px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cast:hover {
    background: var(--bg-hover);
    transform: scale(1.1);
}

.btn-cast.casting {
    border-color: var(--accent-primary);
    background: rgba(74, 158, 255, 0.2);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.btn-favorite {
    width: 48px;
    height: 48px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-favorite:hover {
    background: var(--bg-hover);
    transform: scale(1.1);
}

.btn-favorite.active {
    border-color: #ffc107;
    background: rgba(255, 193, 7, 0.1);
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    background: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
    z-index: 1000;
    max-width: 350px;
    border-left: 4px solid;
}
Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 32px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    line-height: 1;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px 25px;
    overflow-y: auto;
    flex: 1;
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

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

.modal-body::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

/* Saved URLs List */
.saved-urls-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.saved-url-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 15px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all 0.2s;
}

.saved-url-item:hover {
    border-color: var(--accent-primary);
    transform: translateX(4px);
}

.saved-url-info {
    flex: 1;
    min-width: 0;
}

.saved-url-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.saved-url-url {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.saved-url-date {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.7;
}

.saved-url-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn-small {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-small.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-small.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-small.btn-danger {
    background: var(--error);
    color: white;
}

.btn-small.btn-danger:hover {
    background: #d32f2f;
    transform: scale(1.05);
}

/* 
.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-success {
    border-left-color: var(--success);
}

.notification-error {
    border-left-color: var(--error);
}

.notification-warning {
    border-left-color: var(--warning);
}

.notification-info {
    border-left-color: var(--accent-primary);
}

/* Server Modal Styles */
.btn-server {
    position: relative;
}

.btn-server.active {
    background: var(--success);
}

.btn-server.active:hover {
    background: #45a049;
}

.server-modal .modal-content {
    max-width: 600px;
}

.server-status-container {
    padding: 10px;
}

.server-status-info {
    text-align: center;
    margin-bottom: 30px;
}

.server-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: var(--bg-tertiary);
    border-radius: 25px;
    font-size: 1.1em;
    font-weight: 500;
    margin-bottom: 15px;
}

.server-status-badge.active {
    background: rgba(76, 175, 80, 0.2);
    color: var(--success);
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #666;
}

.server-status-badge.active .status-dot {
    background: var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.server-description {
    color: var(--text-secondary);
    font-size: 0.95em;
    line-height: 1.5;
}

.server-info {
    background: var(--bg-tertiary);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.info-card {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.info-card:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.info-label {
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-bottom: 8px;
}

.info-value {
    font-size: 1.1em;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.server-url-input {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 15px;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
}

.btn-copy {
    padding: 10px 15px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.3s;
}

.btn-copy:hover {
    background: var(--bg-hover);
}

.server-qr {
    text-align: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.9em;
}

.server-actions {
    text-align: center;
}

/* Chromecast Styles */
.cast-status-container {
    padding: 20px 0;
}

.cast-status-info {
    margin-bottom: 20px;
}

.cast-status-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.cast-status-badge .status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: pulse-dot 2s infinite;
}

.cast-status-badge.connected .status-dot {
    background: var(--accent-primary);
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.devices-container {
    margin: 20px 0;
}

.devices-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.loading-devices {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 40px 20px;
    color: var(--text-secondary);
}

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

.device-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.device-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    transform: translateX(5px);
}

.device-item.selected {
    background: rgba(74, 158, 255, 0.1);
    border-color: var(--accent-primary);
}

.device-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.device-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.device-address {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.device-icon {
    font-size: 24px;
}

.cast-controls {
    margin-top: 20px;
}

.cast-info-card {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 12px 15px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 10px;
}

.cast-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cast-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.cast-actions {
    margin-top: 15px;
    text-align: center;
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #d32f2f;
}

.btn-large {
    padding: 15px 40px;
    font-size: 1.1em;
    min-width: 200px;
}

.btn-large.btn-danger {
    background: var(--error);
}

.btn-large.btn-danger:hover {
    background: #d32f2f;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 300px;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .header-actions {
        flex-direction: column;
        max-width: none;
    }
    
    .sidebar {
        width: 250px;
    }
}
