/* ========================================
   Xtream Info - Modern UI with Glassmorphism
   ======================================== */

:root {
    --primary: #8b5cf6;
    --primary-light: #a78bfa;
    --primary-dark: #7c3aed;
    --secondary: #06b6d4;
    --accent: #10b981;
    --accent-light: #34d399;
    --warning: #f59e0b;
    --danger: #ef4444;
    --pink: #ec4899;
    
    --bg-dark: #030014;
    --bg-gradient: linear-gradient(135deg, #030014 0%, #0a0a1f 50%, #150a2e 100%);
    
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--bg-gradient);
    z-index: -2;
}

body::after {
    content: '';
    position: fixed;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(139, 92, 246, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 20%, rgba(6, 182, 212, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 40% 40%, rgba(236, 72, 153, 0.08) 0%, transparent 30%);
    animation: bgMove 20s ease-in-out infinite;
    z-index: -1;
}

@keyframes bgMove {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(2%, 2%) rotate(1deg); }
    50% { transform: translate(0, 4%) rotate(0deg); }
    75% { transform: translate(-2%, 2%) rotate(-1deg); }
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    min-height: 100vh;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    margin-bottom: 32px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
}

.logo i {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo strong {
    background: linear-gradient(135deg, var(--primary), var(--pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before { left: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.5);
}

.btn-secondary {
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255,255,255,0.1);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
}

.btn-outline:hover {
    background: var(--glass-bg);
    color: var(--text-primary);
}

.btn-block { width: 100%; }
.btn-loader { display: none; }
.btn.loading .btn-text { display: none; }
.btn.loading .btn-loader { display: inline-flex; }

/* Login */
.login-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 150px);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 440px;
    background: var(--glass-bg);
    backdrop-filter: blur(40px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    box-shadow: var(--glass-shadow);
    position: relative;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
}

.login-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 28px;
    background: rgba(0,0,0,0.3);
    padding: 6px;
    border-radius: var(--radius-md);
}

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

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

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.tab-content { display: none; }
.tab-content.active {
    display: block;
    animation: fadeSlideUp 0.4s ease;
}

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

/* Forms */
.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-wrapper { position: relative; }

.input-wrapper i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: color var(--transition);
    pointer-events: none;
}

.input-wrapper input,
.input-wrapper textarea {
    width: 100%;
    padding: 16px 16px 16px 48px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: all var(--transition);
}

.input-wrapper textarea {
    resize: vertical;
    min-height: 100px;
}

.input-wrapper input:focus,
.input-wrapper textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

.input-wrapper:focus-within i { color: var(--primary); }

.input-wrapper input::placeholder,
.input-wrapper textarea::placeholder { color: var(--text-muted); }

.form-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.login-footer {
    text-align: center;
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--glass-border);
}

.login-footer p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Dashboard */
.dashboard-section { animation: fadeSlideUp 0.5s ease; }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    position: relative;
    padding: 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    opacity: 0;
    transition: opacity var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255,255,255,0.15);
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.stat-card:hover::before { opacity: 1; }

.stat-card.status-active::before {
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    opacity: 1;
}

.stat-card.status-expired::before {
    background: linear-gradient(90deg, var(--danger), #f87171);
    opacity: 1;
}

.stat-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(6, 182, 212, 0.2));
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 1.25rem;
    color: var(--primary-light);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
}

.stat-value.active { color: var(--accent); }
.stat-value.expired { color: var(--danger); }
.stat-value.warning { color: var(--warning); }
.stat-value.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Categories Panel */
.categories-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 32px;
    position: relative;
}

.categories-panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
}

.panel-header { margin-bottom: 24px; }

.panel-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.panel-title i { color: var(--primary); }

/* Type Tabs */
.type-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.type-tab {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: rgba(0,0,0,0.3);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.type-tab::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary), var(--pink));
    opacity: 0;
    transition: opacity var(--transition);
}

.type-tab:hover {
    border-color: rgba(255,255,255,0.2);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.type-tab.active {
    border-color: transparent;
    color: white;
}

.type-tab.active::before { opacity: 1; }

.type-tab > * {
    position: relative;
    z-index: 1;
}

.type-tab-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    font-size: 1.25rem;
}

.type-tab-info {
    flex: 1;
}

.type-tab-name {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
    display: block;
}

.type-tab-stats {
    font-size: 0.8rem;
    opacity: 0.8;
}

.type-tab-stats span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    padding: 20px 0;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 20px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
}

.checkbox-wrapper label {
    font-weight: 500;
    cursor: pointer;
}

.selected-count {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.toolbar-right {
    display: flex;
    gap: 10px;
}

/* Search */
.search-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.search-wrapper i {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-wrapper input {
    width: 100%;
    padding: 16px 50px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all var(--transition);
}

.search-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

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

.clear-search {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all var(--transition);
}

.clear-search:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

/* Categories List */
.categories-list {
    max-height: 500px;
    overflow-y: auto;
    padding-right: 8px;
}

.categories-list::-webkit-scrollbar { width: 6px; }
.categories-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 3px; }
.categories-list::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 3px; }

.category-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    background: rgba(0,0,0,0.2);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    cursor: pointer;
    transition: all var(--transition);
}

.category-item:hover {
    background: rgba(255,255,255,0.05);
    border-color: var(--glass-border);
    transform: translateX(4px);
}

.category-item.selected {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--primary);
}

.category-item.selected .category-icon {
    background: var(--primary);
    color: white;
}

.category-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(139, 92, 246, 0.2);
    border-radius: var(--radius-sm);
    color: var(--primary-light);
    font-size: 1.1rem;
    transition: all var(--transition);
}

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

.category-name {
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-meta {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.category-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.category-streams {
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(6, 182, 212, 0.2));
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Loading & Empty */
.loading-state,
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.loading-state i,
.empty-state i {
    font-size: 3rem;
    margin-bottom: 20px;
    display: block;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active { display: flex; }

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

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

.modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    background: linear-gradient(135deg, rgba(30, 30, 60, 0.95), rgba(20, 20, 40, 0.98));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    animation: modalSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-close {
    background: rgba(255,255,255,0.1);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all var(--transition);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(255,255,255,0.2);
    color: var(--text-primary);
}

.modal-body { padding: 28px; }

.format-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.format-option { cursor: pointer; }
.format-option input { display: none; }

.format-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 12px;
    background: rgba(0,0,0,0.3);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-md);
    text-align: center;
    transition: all var(--transition);
}

.format-option input:checked + .format-card {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.15);
}

.format-card i {
    font-size: 1.75rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.format-card strong { font-size: 0.95rem; }
.format-card small { font-size: 0.7rem; color: var(--text-muted); }

.playlist-type-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.playlist-type-option { cursor: pointer; }
.playlist-type-option input { display: none; }

.type-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px;
    background: rgba(0,0,0,0.3);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-md);
    transition: all var(--transition);
}

.playlist-type-option input:checked + .type-card {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.15);
}

.type-card i {
    font-size: 1.5rem;
    color: var(--primary);
    width: 40px;
    text-align: center;
}

.type-card div { display: flex; flex-direction: column; }
.type-card strong { font-size: 0.95rem; }
.type-card small { font-size: 0.8rem; color: var(--text-muted); }

.content-type-info {
    display: flex;
    justify-content: space-between;
    padding: 16px 18px;
    background: rgba(0,0,0,0.3);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 28px;
    border-top: 1px solid var(--glass-border);
    background: rgba(0,0,0,0.2);
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(30, 30, 60, 0.95), rgba(20, 20, 40, 0.98));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    animation: toastSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 320px;
    backdrop-filter: blur(20px);
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.success { border-left: 4px solid var(--accent); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }

.toast i { font-size: 1.25rem; }
.toast.success i { color: var(--accent); }
.toast.error i { color: var(--danger); }
.toast.warning i { color: var(--warning); }

.toast-message { flex: 1; font-weight: 500; }

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

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

/* Responsive */
@media (max-width: 768px) {
    .app-container { padding: 16px; }
    .header { flex-direction: column; gap: 16px; }
    .login-card { padding: 32px 24px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .type-tabs { grid-template-columns: 1fr; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-right { justify-content: stretch; }
    .toolbar-right .btn { flex: 1; }
    .format-options { grid-template-columns: 1fr; }
    .modal-footer { flex-direction: column; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .toast-container { left: 16px; right: 16px; }
    .toast { min-width: auto; }
}
