/* ==================== ROOT & RESET ==================== */
:root {
    --primary: #FF0000;
    --primary-dark: #CC0000;
    --primary-light: #FF3333;
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-card: #1a1a1a;
    --bg-card-hover: #222222;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #666666;
    --border: #333333;
    --success: #4CAF50;
    --warning: #ff9800;
    --danger: #f44336;
    --shadow: rgba(0, 0, 0, 0.5);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 50px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    padding-bottom: env(safe-area-inset-bottom);
}

/* ==================== CONTAINER ==================== */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    padding-top: env(safe-area-inset-top);
    min-height: 100vh;
}

/* ==================== HEADER ==================== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 30px;
}

.logo-container {
    text-align: right;
}

.logo {
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    letter-spacing: 2px;
}

.logo-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: -5px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover,
.icon-btn:active {
    background: var(--bg-card-hover);
    border-color: var(--primary);
    transform: scale(1.05);
}

.badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-full);
    padding: 2px 6px;
    font-size: 0.7rem;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

/* ==================== SEARCH SECTION ==================== */
.search-section {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-container {
    position: relative;
    flex: 1;
}

.search-input {
    width: 100%;
    padding: 16px 45px 16px 20px;
    border-radius: var(--radius-full);
    border: 2px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
    outline: none;
}

.search-input:focus {
    border-color: var(--primary);
    background: var(--bg-secondary);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.clear-btn {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--text-muted);
    color: var(--bg-primary);
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.clear-btn:hover {
    background: var(--text-secondary);
    transform: translateY(-50%) scale(1.1);
}

.search-btn {
    padding: 16px 30px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--primary);
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.search-btn:hover,
.search-btn:active {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.search-btn svg {
    flex-shrink: 0;
}

/* ==================== QUICK FILTERS ==================== */
.quick-filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 0;
    margin-bottom: 20px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.quick-filters::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    padding: 8px 16px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.filter-chip:hover,
.filter-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ==================== TABS ==================== */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    background: var(--bg-card);
    padding: 5px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.tab {
    flex: 1;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
}

.tab:hover {
    color: var(--text-primary);
}

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

.tab svg {
    flex-shrink: 0;
}

.tab-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--success);
    color: white;
    border-radius: var(--radius-full);
    padding: 2px 6px;
    font-size: 0.7rem;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

/* ==================== STATUS MESSAGE ==================== */
.status-message {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    text-align: center;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    animation: slideDown 0.3s ease;
}

.status-message.success {
    background: rgba(76, 175, 80, 0.2);
    border: 1px solid var(--success);
    color: var(--success);
}

.status-message.error {
    background: rgba(244, 67, 54, 0.2);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.status-message.loading {
    background: rgba(255, 152, 0, 0.2);
    border: 1px solid var(--warning);
    color: var(--warning);
}

/* ==================== RESULTS AREA ==================== */
.results-area {
    animation: fadeIn 0.5s ease;
}

/* ==================== WELCOME SCREEN ==================== */
.welcome-screen {
    text-align: center;
    padding: 60px 20px;
    animation: fadeIn 0.8s ease;
}

.welcome-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: bounce 2s ease infinite;
}

.welcome-screen h2 {
    font-size: 2rem;
    margin-bottom: 15px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-screen p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 40px;
    line-height: 1.8;
}

.welcome-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    max-width: 500px;
    margin: 0 auto;
}

.feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.feature:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
}

.feature-icon {
    font-size: 2rem;
}

/* ==================== VIDEO CARD ==================== */
.video-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 15px;
    border: 1px solid var(--border);
    transition: var(--transition);
    animation: slideUp 0.4s ease;
    animation-fill-mode: both;
}

.video-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--shadow);
}

.video-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 15px;
}

.video-title {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    color: var(--text-primary);
    margin: 0;
}

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

.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.1);
}

.action-btn.favorited {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ==================== PLAYER CONTAINER ==================== */
.player-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 aspect ratio */
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 15px;
}

.player-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.video-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.video-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    animation: fadeIn 0.5s ease;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.empty-state p {
    color: var(--text-muted);
    font-size: 1rem;
}

/* ==================== LOADING INDICATOR ==================== */
.loading-indicator {
    text-align: center;
    padding: 40px 20px;
}

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

/* ==================== MINI PLAYER ==================== */
.mini-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 12px var(--shadow);
}

.mini-player.active {
    transform: translateY(0);
}

.mini-player-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    overflow: hidden;
}

.mini-player-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
}

.mini-player-text {
    flex: 1;
    overflow: hidden;
}

.mini-player-title {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-player-controls {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.mini-control-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-control-btn:hover,
.mini-control-btn:active {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* ==================== MODAL ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header h2 {
    font-size: 1.5rem;
    margin: 0;
}

.close-modal {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.2rem;
}

.close-modal:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

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

.setting-group {
    margin-bottom: 30px;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-group h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--text-secondary);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.setting-item {
    margin-bottom: 15px;
}

.setting-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.setting-select {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

.toggle {
    width: 50px;
    height: 26px;
    appearance: none;
    background: var(--border);
    border-radius: var(--radius-full);
    position: relative;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
}

.toggle::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: var(--transition);
}

.toggle:checked {
    background: var(--primary);
}

.toggle:checked::before {
    left: 26px;
}

.danger-btn {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--danger);
    background: transparent;
    color: var(--danger);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 10px;
}

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

.about-text {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    line-height: 1.8;
}

/* ==================== INSTALL PROMPT ==================== */
.install-prompt {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 15px;
    box-shadow: 0 8px 24px var(--shadow);
    z-index: 1500;
    animation: slideUp 0.3s ease;
}

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

.install-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.install-text {
    flex: 1;
}

.install-text strong {
    display: block;
    margin-bottom: 2px;
    font-size: 0.95rem;
}

.install-text small {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.install-btn {
    padding: 10px 20px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--primary);
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.install-btn:hover {
    background: var(--primary-dark);
}

.close-install {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.close-install:hover {
    background: var(--danger);
    color: white;
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    z-index: 3000;
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 15px 20px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px var(--shadow);
    animation: toastSlideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: all;
}

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

.toast.error {
    border-color: var(--danger);
}

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

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 0.9rem;
}

/* ==================== UTILITY CLASSES ==================== */
.hidden {
    display: none !important;
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== STAGGER ANIMATIONS ==================== */
.video-card:nth-child(1) { animation-delay: 0.1s; }
.video-card:nth-child(2) { animation-delay: 0.2s; }
.video-card:nth-child(3) { animation-delay: 0.3s; }
.video-card:nth-child(4) { animation-delay: 0.4s; }
.video-card:nth-child(5) { animation-delay: 0.5s; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 600px) {
    .container {
        padding: 15px;
    }

    .logo {
        font-size: 2rem;
    }

    .search-section {
        flex-direction: column;
    }

    .search-btn {
        width: 100%;
        justify-content: center;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab {
        font-size: 0.8rem;
        padding: 10px 12px;
    }

    .tab svg {
        width: 16px;
        height: 16px;
    }

    .welcome-screen h2 {
        font-size: 1.5rem;
    }

    .welcome-features {
        grid-template-columns: 1fr;
    }

    .modal-content {
        max-height: 85vh;
    }
}

/* ==================== DARK MODE IMPROVEMENTS ==================== */
@media (prefers-color-scheme: dark) {
    body {
        background: var(--bg-primary);
    }
}

/* ==================== PRINT STYLES ==================== */
@media print {
    .header-actions,
    .search-section,
    .tabs,
    .install-prompt,
    .mini-player,
    .modal {
        display: none !important;
    }
}

/* ==================== IOS SPECIFIC ==================== */
@supports (-webkit-touch-callout: none) {
    .search-input,
    .search-btn {
        -webkit-appearance: none;
    }
    
    input[type="checkbox"] {
        -webkit-appearance: none;
    }
}
