/* Modern Premium CSS Stylesheet for IPTV mobile application */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Color Palette - Premium Neon Blue/Violet & Dark Glass Theme */
    --bg-main: #0B0E14;
    --bg-card: rgba(22, 28, 38, 0.7);
    --bg-glass: rgba(22, 28, 38, 0.45);
    --border-glass: rgba(255, 255, 255, 0.08);
    --accent-glow: rgba(99, 102, 241, 0.15);
    
    --primary: #6366F1;       /* Indigo */
    --primary-hover: #4F46E5;
    --secondary: #EC4899;     /* Pink/Violet accent */
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    
    --text-main: #F3F4F6;
    --text-muted: #9CA3AF;
    --text-dark: #1F2937;
    
    --shadow-main: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --shadow-inset: inset 0 2px 4px 0 rgba(255, 255, 255, 0.06);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* Lock page to viewport height, preventing page-wide scrollbars */
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
}

/* Glassmorphism Background Container */
.app-container {
    max-width: 480px; /* Mobile first boundary */
    margin: 0 auto;
    height: 100vh; /* Lock mobile height to viewport */
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.12), transparent 60%),
                radial-gradient(circle at bottom left, rgba(236, 72, 153, 0.08), transparent 60%);
    position: relative;
    box-shadow: 0 0 40px rgba(0,0,0,0.8);
    overflow: hidden;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1rem;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.35rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo span {
    font-weight: 300;
    color: var(--text-muted);
}

/* Upgrade & Action Buttons */
.btn {
    font-family: var(--font-sans);
    font-size: 0.95rem; /* Mobile first: larger text */
    font-weight: 600;
    padding: 0.75rem 1.5rem; /* Mobile first: larger touch targets */
    min-height: 46px;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

@media (min-width: 768px) {
    .btn {
        font-size: 0.85rem; /* Desktop: sleeker sizes */
        padding: 0.55rem 1.1rem;
        min-height: 38px;
    }
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    min-height: 36px;
}

@media (min-width: 768px) {
    .btn-sm {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
        min-height: 32px;
    }
}

/* Automatically style buttons in tables to be smaller */
table button.btn,
table .btn {
    padding: 0.4rem 0.8rem !important;
    font-size: 0.75rem !important;
    min-height: 32px !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

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

.btn-accent:hover {
    filter: brightness(1.1);
}

.badge-premium {
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    color: white;
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-profile-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.user-profile-btn:hover {
    background: rgba(255,255,255,0.15);
}

/* Video Player Section */
.player-wrapper {
    width: 100%;
    background: #000;
    position: relative;
    aspect-ratio: 16/9;
}

video {
    width: 100%;
    height: 100%;
    display: block;
}

.video-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(180deg, #161C26 0%, #0B0E14 100%);
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.video-placeholder svg {
    width: 48px;
    height: 48px;
    color: var(--primary);
    margin-bottom: 0.75rem;
    filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.5));
}

/* Channel Listing Section */
.app-content-grid {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Allows flex shrinking inside container */
}

.main-content {
    flex: 1;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overflow: hidden;
    min-height: 0; /* Allows flex child to shrink and scroll */
}

.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-dropdown {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem !important;
    cursor: pointer;
    background-color: rgba(22, 28, 38, 0.9) !important;
    border: 1px solid var(--border-glass);
}

.category-dropdown option {
    background-color: #161C26;
    color: white;
    padding: 0.5rem;
}

.channels-grid {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-bottom: 1rem;
    min-height: 0; /* Important for flex-grow scrolling container */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.channels-grid::-webkit-scrollbar {
    width: 6px;
}

.channels-grid::-webkit-scrollbar-thumb {
    background-color: rgba(255,255,255,0.12);
    border-radius: 9999px;
}

.channel-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.channel-card:hover {
    transform: translateX(4px);
    border-color: var(--primary);
    background: rgba(255,255,255,0.06);
}

.channel-logo {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: cover;
    background: #111827;
}

.channel-info {
    flex: 1;
}

.channel-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
}

.channel-category {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.channel-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.channel-badge.free {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.channel-badge.paid {
    background: rgba(236, 72, 153, 0.15);
    color: var(--secondary);
}

/* Modals & Forms */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

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

.modal-content {
    background: #161C26;
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    box-shadow: var(--shadow-main);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

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

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-control {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    color: white;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: var(--transition-smooth);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

.alert-message {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    display: none;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
    display: block;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.25);
    display: block;
}

/* Profile details block in upgrade */
.upgrade-info-block {
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed var(--border-glass);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.upgrade-info-block div {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.upgrade-info-block div:last-child {
    margin-bottom: 0;
}

.upgrade-info-block span {
    font-weight: 600;
}

/* Admin Dashboard CSS Specific Rules */
.admin-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-main);
}

.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    overflow-x: auto;
    padding: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th, td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-glass);
    font-size: 0.9rem;
}

th {
    color: var(--text-muted);
    font-weight: 600;
}

tr:last-child td {
    border-bottom: none;
}

.admin-actions {
    display: flex;
    gap: 0.5rem;
}

/* Toast styling */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #161C26;
    border: 1px solid var(--border-glass);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 9999px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: var(--shadow-main);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast.active {
    transform: translateX(-50%) translateY(0);
}

/* Responsive adjustments for Desktops, Laptops, Tablets, and TVs */
@media (min-width: 768px) {
    /* Lock desktop container height to viewport, disable page scroll */
    .app-container {
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        border: none;
        box-shadow: none;
        overflow: hidden;
        height: 100vh;
        max-height: 100vh;
    }

    /* Side-by-Side Split View: Video player takes 70%, channels column takes 30% */
    .app-content-grid {
        display: grid;
        grid-template-columns: 70% 30%;
        flex: 1;
        height: calc(100vh - 73px); /* Subtract header height */
        overflow: hidden;
    }
    
    .player-wrapper {
        border-right: 1px solid var(--border-glass);
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #000;
        position: relative;
        top: 0;
    }

    .main-content {
        padding: 1.5rem;
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    .channels-grid {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        flex: 1;
        overflow-y: auto;
    }
}

/* Large TV Screen Optimizations */
@media (min-width: 1024px) {
    .app-container {
        max-width: 100%;
    }
    .app-content-grid {
        grid-template-columns: 70% 30%;
    }
    .channels-grid {
        /* Let columns display side-by-side inside the scrollable sidebar on wide screens */
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1rem;
        align-content: start;
    }
}

/* Search bar styling */
.search-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 0.5rem;
}

.search-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 0.7rem 1rem 0.7rem 2.5rem;
    color: white;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: var(--transition-smooth);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

.search-icon {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Expiry warning banner styling */
.expiry-banner {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(239, 68, 68, 0.1) 100%);
    border: 1px solid rgba(245, 158, 11, 0.25);
    color: var(--warning);
    padding: 0.8rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Custom CSS Graphs for Analytics Dashboard */
.analytics-chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 300px;
}

.analytics-grid-two-col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.chart-bar-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.chart-bar-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.chart-bar-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

.chart-bar-track {
    height: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 9999px;
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    border-radius: 9999px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    width: 0;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Password Toggle Input Fields styling */
.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.password-input-wrapper .form-control {
    padding-right: 2.75rem !important;
    width: 100%;
}

.password-toggle-btn {
    position: absolute;
    right: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    z-index: 10;
}

.password-toggle-btn:hover {
    color: white;
}

/* TV QR Code Activation split layout styling */
.auth-split-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.auth-form-side {
    flex: 1;
}

.auth-qr-side {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed var(--border-glass);
    border-radius: 16px;
    padding: 1.25rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.qr-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: white;
}

.qr-wrapper {
    background: white;
    padding: 0.5rem;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.qr-loading-placeholder {
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a1a1a;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
}

.activation-url-link {
    display: inline-block;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    word-break: break-all;
    margin-bottom: 0.75rem;
    transition: var(--transition-smooth);
}

.activation-url-link:hover {
    color: var(--secondary);
    text-decoration: underline;
}

.pin-box {
    margin-top: 0.5rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 0.4rem 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
}

.pin-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    font-weight: 700;
}

.pin-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--secondary);
    letter-spacing: 0.1em;
}

/* Auth Modal responsive layout for tablets and laptops */
@media (min-width: 640px) {
    .auth-split-layout {
        flex-direction: row;
        gap: 2rem;
    }
    
    .auth-form-side {
        border-right: 1px solid var(--border-glass);
        padding-right: 2rem;
        flex: 1.2;
    }
    
    .auth-qr-side {
        flex: 0.8;
    }
}


