@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

:root {
    --bg-dark: #0a0a0a;
    --bg-card: #141414;
    --bg-card-hover: #1f1f1f;
    --border-color: #2a2a2a;
    --accent-red: #e50914;
    --text-primary: #ffffff;
    --text-muted: #a0a0a0;
    --live-green: #22c55e;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Roboto', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 14px;
    /* Reduced base font size */
}

#hepbet-app {
    max-width: 1000px;
    /* Reduced width for compactness */
    margin: 0 auto;
    padding: 15px;
}

/* Player Wrapper */
.player-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: var(--shadow-md);
}

.player-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Multi-screen grid */
.player-wrapper.multi-screen-active {
    aspect-ratio: auto;
    min-height: 500px;
    display: grid;
    gap: 8px;
    padding: 8px;
}

.player-wrapper.grid-1 {
    grid-template-columns: 1fr;
}

.player-wrapper.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.player-wrapper.grid-3 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.player-wrapper.grid-3 .multi-screen-player-item:first-child {
    grid-column: span 2;
}

.player-wrapper.grid-4 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.multi-screen-player-item {
    position: relative;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
    min-height: 200px;
}

.multi-screen-player-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.85);
    padding: 6px 10px;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    z-index: 10;
}

/* Tabs */
.tabs-container {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.tab-btn {
    flex: 1;
    min-width: 100px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.tab-btn.active {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.tab-btn i {
    font-size: 0.9rem;
}

/* Search Bar */
.search-bar,
.multi-screen-search-bar {
    position: relative;
    margin-bottom: 12px;
}

.search-bar i,
.multi-screen-search-bar i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.search-bar input,
.multi-screen-search-bar input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 12px 10px 38px;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.search-bar input:focus,
.multi-screen-search-bar input:focus {
    outline: none;
    border-color: var(--accent-red);
}

/* Multi-screen Controls */
.multi-screen-controls {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
}

.multi-screen-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.multi-screen-buttons span {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.multi-screen-btn {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

.multi-screen-btn.apply {
    background: #15803d;
    border-color: #15803d;
}

.multi-screen-btn.apply:hover {
    background: #166534;
}

.multi-screen-btn.clear {
    background: #b91c1c;
    border-color: #b91c1c;
}

.multi-screen-btn.clear:hover {
    background: #991b1b;
}

/* Match List */
.match-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* Tighter gap */
}

/* Channel/Match Item */
.channel-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 3px solid transparent;
    /* Subtle indicator */
    border-radius: 6px;
    padding: 10px 12px;
    /* More compact padding */
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
}

.channel-item:hover {
    background: var(--bg-card-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    border-color: #444;
}

.channel-item.active {
    border-left-color: var(--live-green);
    /* Green active indicator */
    background: #1a1a1a;
}

.channel-item.selected {
    background: rgba(229, 9, 20, 0.1);
    border-color: var(--accent-red);
}

/* Multi-screen Checkbox */
.multi-screen-checkbox {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    z-index: 5;
}

.channel-item.selected .multi-screen-checkbox {
    background: var(--accent-red);
    border-color: var(--accent-red);
}

.channel-item.selected .multi-screen-checkbox i {
    display: block;
    font-size: 0.7rem;
    color: #fff;
}

/* Match Card Structure - Fixed Alignment */
.match-card-container {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: space-between;
}

.team-box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

/* Align Home Team to the Left (Fixed gap from corner) */
.team-box.home {
    justify-content: flex-start;
    text-align: left;
}

/* Align Away Team to the Right (Fixed gap from corner) */
.team-box.away {
    justify-content: flex-end;
    text-align: right;
    
}
.match-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex-shrink: 0;
}

.team-name {
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
    color: #ffffff;
    /* Explicitly white */
}

.match-center-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 80px;
    /* Fixed width for center */
    flex-shrink: 0;
}

.match-time {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.match-separator {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-weight: 300;
    line-height: 1;
}

.live-blink-badge {
    background: var(--accent-red);
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 700;
    animation: blink 1.5s infinite;
    text-transform: uppercase;
}

.league-row {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.league-text {
    max-width: 70px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Channel Row Structure */
.channel-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

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

.tv-icon-box {
    width: 32px;
    height: 32px;
    background: #222;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.tv-icon-box::before {
    content: '📺';
}

.channel-name-text {
    font-weight: 500;
    font-size: 0.9rem;
}

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

.channel-live-badge {
    background: var(--accent-red);
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}

.channel-logo-right {
    width: 60px;
    height: 30px;
    object-fit: contain;
    background: #fff;
    /* White background for logos if transparent */
    border-radius: 2px;
    padding: 2px;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Modal Overlay Styles */
.stream-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100000;
    /* Extra high z-index */
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.stream-modal.active {
    display: flex;
}

.stream-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    z-index: 1;
}

.stream-modal-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 850px;
    /* Reduced modal width */
    background: #111;
    border: 1px solid #333;
    border-radius: 8px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.stream-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #0a0a0a;
    border-bottom: 1px solid #222;
}

#modalTitle {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
}

.close-modal-btn {
    background: transparent;
    border: none;
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.close-modal-btn:hover {
    background: #333;
}

.stream-modal-body {
    width: 100%;
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 */
    background: #000;
}

.stream-modal-body iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #hepbet-app {
        padding: 10px;
    }

    .match-card-container {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Wrap on very small screens */
    .team-box {
        min-width: 120px;
    }

    .team-box.home {
        justify-content: center;
        text-align: center;
        flex-direction: column-reverse;
        gap: 4px;
    }

    .team-box.away {
        justify-content: center;
        text-align: center;
        flex-direction: column;
        gap: 4px;
    }

    .match-logo {
        width: 32px;
        height: 32px;
    }

    .team-name {
        max-width: none;
        font-size: 0.85rem;
    }

    .channel-left {
        gap: 8px;
    }

    .tv-icon-box {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }

    .channel-logo-right {
        width: 50px;
        height: 25px;
    }
}

@media (max-width: 768px) {

    /* Same horizontal layout rakho */
    .match-card-container {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    .team-box {
        flex: 1;
        flex-direction: row !important;
        justify-content: flex-start;
        gap: 6px;
        min-width: 0;
    }

    .team-box.away {
        justify-content: flex-end !important;
    }

    .team-name {
        font-size: 0.8rem;
        max-width: 90px;
    }

    .match-logo {
        width: 26px;
        height: 26px;
    }

    .match-center-info {
        width: 60px;
    }

    .match-time {
        font-size: 0.8rem;
    }
}