/* Customer portal — modern dark UI */

.customer-app {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--db-bg);
    overflow-x: hidden;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    padding-top: calc(0.75rem + env(safe-area-inset-top, 0));
    padding-left: calc(1rem + env(safe-area-inset-left, 0));
    padding-right: calc(1rem + env(safe-area-inset-right, 0));
    background: rgba(9, 11, 16, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--db-border);
}

.app-brand img {
    display: block;
    height: 24px;
    width: auto;
}

.app-header-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--db-radius-sm);
    color: var(--db-text-muted);
    text-decoration: none;
    transition: all var(--db-transition);
}

.app-header-btn:hover {
    background: var(--db-surface-hover);
    color: var(--db-text);
}

.app-header-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
    justify-content: center;
}

.header-nav-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.875rem;
    border-radius: var(--db-radius-sm);
    color: var(--db-text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--db-transition);
}

.header-nav-link:hover {
    background: var(--db-surface-hover);
    color: var(--db-text);
}

.header-nav-link.active {
    background: var(--db-accent-soft);
    color: #2D70FF;
}

.app-main {
    flex: 1;
    padding: 1rem;
    padding-bottom: calc(1rem + var(--db-bottom-nav-height) + env(safe-area-inset-bottom, 0));
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.app-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    background: rgba(18, 27, 38, 0.95);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--db-border);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.55rem 0.25rem;
    color: var(--db-text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 500;
    transition: color var(--db-transition);
}

.bottom-nav-item i { font-size: 1.15rem; }
.bottom-nav-item.active { color: #2D70FF; }
.bottom-nav-item.active i { color: var(--db-accent); }
.bottom-nav-item:hover { color: var(--db-text); }

.home-hero {
    text-align: center;
    padding: 2rem 0 1.5rem;
}

.home-hero h1 { font-size: 1.5rem; margin-bottom: 0.35rem; }
.home-hero p { color: var(--db-text-muted); font-size: 0.9rem; margin: 0; }

.home-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.875rem;
    max-width: 420px;
    margin: 0 auto;
    justify-content: center;
    align-items: stretch;
}

.home-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex: 0 0 calc(50% - 0.4375rem);
    width: calc(50% - 0.4375rem);
    min-height: 140px;
    aspect-ratio: 1;
    background: var(--db-surface);
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius-lg);
    color: var(--db-text);
    text-decoration: none;
    transition: all var(--db-transition);
    box-sizing: border-box;
}

@media (min-width: 576px) {
    .home-grid {
        max-width: 420px;
    }

    .home-tile {
        flex: 0 0 180px;
        width: 180px;
        max-width: 180px;
    }
}

.home-tile:hover {
    border-color: var(--db-accent);
    background: var(--db-surface-hover);
    transform: translateY(-2px);
    color: var(--db-text);
    box-shadow: 0 8px 32px var(--db-accent-glow);
}

.home-tile-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--db-radius);
    background: var(--db-accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #2D70FF;
}

.home-tile span { font-weight: 600; font-size: 0.95rem; }

.live-tv-layout {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    min-height: calc(100vh - 180px);
}

.channel-sidebar {
    width: 320px;
    flex: 0 0 320px;
    background: var(--db-surface);
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 160px);
}

.channel-sidebar-header {
    padding: 0.75rem;
    border-bottom: 1px solid var(--db-border);
}

.channel-list { overflow-y: auto; flex: 1; }

.channel-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--db-border);
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--db-transition);
}

.channel-row:hover { background: var(--db-surface-hover); color: inherit; }
.channel-row.active { background: var(--db-accent-soft); box-shadow: inset 3px 0 0 var(--db-accent); }

.channel-row-logo {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: var(--db-radius-sm);
    background: var(--db-surface-raised);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.channel-row-logo img { width: 100%; height: 100%; object-fit: contain; }
.channel-row-logo span { font-weight: 700; font-size: 0.75rem; color: var(--db-accent); }
.channel-row-info { flex: 1; min-width: 0; }

.channel-row-name {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-row .current-program-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    font-size: 0.75rem;
}

.channel-row-number {
    color: var(--db-text-muted);
    font-weight: 600;
    font-size: 0.85rem;
}

.channel-sidebar-pagination {
    padding: 0.5rem;
    border-top: 1px solid var(--db-border);
}

.live-preview { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.live-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.live-preview-channel { font-size: 1.25rem; font-weight: 700; color: #2D70FF; margin-right: 0.5rem; }
.live-preview-program { font-size: 1rem; font-weight: 500; }
.live-preview-clock { font-size: 1.5rem; font-weight: 300; color: var(--db-text-muted); }
.live-preview-controls { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

.control-btn {
    flex: 1;
    background: var(--db-surface);
    border: 1px solid var(--db-border);
    color: var(--db-text);
    padding: 0.6rem 1rem;
    border-radius: var(--db-radius-sm);
    font-weight: 600;
    font-size: 0.8rem;
    transition: background var(--db-transition);
    text-decoration: none;
    text-align: center;
}

.control-btn:hover:not(:disabled) { background: var(--db-surface-hover); color: var(--db-text); }
.control-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.live-preview-filter-panel {
    margin-top: 0.75rem;
    padding: 0.875rem;
    background: var(--db-surface);
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius-sm);
}

.progress-thin { height: 3px; }

.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    background: #000;
    border-radius: var(--db-radius);
    border: 1px solid var(--db-border);
}

.video-container video,
.video-container iframe,
#video-player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
}

#loading-indicator {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
}

.player-controls {
    background: var(--db-surface);
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius-sm);
    padding: 0.75rem;
    margin-top: 0.75rem;
}

.epg-timeline-container {
    overflow: auto;
    max-height: calc(100vh - 220px);
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius);
}

.epg-timeline { position: relative; overflow-x: auto; }

.epg-timeline-hours {
    display: flex;
    border-bottom: 1px solid var(--db-border);
    position: sticky;
    top: 0;
    background: var(--db-bg-subtle);
    z-index: 2;
}

.epg-hour {
    min-width: 180px;
    padding: 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--db-text-muted);
    border-right: 1px solid var(--db-border);
}

.epg-channel {
    display: flex;
    border-bottom: 1px solid var(--db-border);
    min-height: 52px;
}

.epg-channel-info {
    width: 160px;
    padding: 0.5rem 0.75rem;
    background: var(--db-surface);
    position: sticky;
    left: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 500;
    border-right: 1px solid var(--db-border);
}

.epg-channel-programs { position: relative; flex-grow: 1; }

.epg-program {
    position: absolute;
    top: 2px;
    height: calc(100% - 4px);
    background: var(--db-surface-raised);
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    cursor: pointer;
    border: 1px solid var(--db-border);
    font-size: 0.75rem;
}

.epg-program.current {
    background: var(--db-accent-soft);
    border-color: var(--db-accent);
    color: #e9d5ff;
}

.date-picker {
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.date-item {
    flex: 0 0 auto;
    padding: 0.5rem 0.875rem;
    border-radius: var(--db-radius-sm);
    border: 1px solid var(--db-border);
    cursor: pointer;
    text-align: center;
    min-width: 64px;
}

.date-item.active { background: var(--db-accent); border-color: var(--db-accent); color: #fff; }
.date-item .day-name { font-size: 0.7rem; display: block; }
.date-item .date { font-weight: 700; display: block; }

.page-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
}

.device-item.current-device {
    background: var(--db-accent-soft) !important;
    border-left: 3px solid var(--db-accent) !important;
}

.stream-epg-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius);
    overflow: hidden;
}

.stream-epg-item {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--db-border);
}

.stream-epg-item.current {
    background: var(--db-accent-soft);
    border-left: 3px solid var(--db-accent);
}

.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(45, 112, 255, 0.18), transparent), var(--db-bg);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--db-surface);
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius-lg);
    padding: 2rem;
    box-shadow: var(--db-shadow);
}

.login-logo { text-align: center; margin-bottom: 1.75rem; }
.login-logo img { height: 32px; margin-bottom: 1rem; }
.login-logo h1 { font-size: 1.25rem; margin: 0; }
.login-logo p { color: var(--db-text-muted); font-size: 0.875rem; margin: 0.35rem 0 0; }

.content-refresh-banner {
    position: fixed;
    bottom: calc(var(--db-bottom-nav-height) + 1rem + env(safe-area-inset-bottom, 0));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1080;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--db-surface-raised);
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius);
    box-shadow: var(--db-shadow);
    font-size: 0.875rem;
}

.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.channel-card {
    background: var(--db-surface);
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius);
    overflow: hidden;
    transition: all var(--db-transition);
}

.fade-in { animation: fadeIn 0.35s ease; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 991px) {
    .live-tv-layout { flex-direction: column; }
    .channel-sidebar { width: 100%; flex-basis: auto; max-height: 280px; }
}

@media (min-width: 768px) {
    .app-bottom-nav { display: none; }
    .app-main { padding-bottom: 2rem; }
}
