:root {
    --pad: 12px;
    --border: #eaeaea;
    --muted: #666;
    --bg: #fff;
    --now: #ff3b30;
    --nowBlockBg: #f0f6ff;
    --nowBlockBorder: #007cff;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
    background: #fafafa;
    color: #222;
}

#epg,
.epg,
[data-epg] {
    height: 100vh;
    overflow: auto;
}

.app {
    width: 100%;
    max-width: none;
    /* full width */
    margin: 0;
    padding: 8px;
    /* λίγο breathing space στα άκρα */
}

/* ===== Tabs (ημέρες) ===== */
.tabs {
    display: flex;
    align-items: flex-end;
    gap: 8px;

    /* να μη σπάνε σε 2η γραμμή */
    flex-wrap: nowrap;
    white-space: nowrap;

    /* οριζόντιο scroll αν είναι πολλές ημέρες */
    overflow-x: auto;
    overflow-y: hidden;

    position: sticky;
    /* sticky επάνω */
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 8px 8px 0;
}

.tab {
    flex: 0 0 auto;
    padding: 8px 12px;
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    user-select: none;
    color: #333;
}

.tab.active {
    border-color: var(--border);
    background: #f8f8f8
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.top-bar-left {
    display: flex;
    gap: 8px;
    align-items: center;
}

.top-bar-right {
    display: flex;
    gap: 16px;
    align-items: center;
    font-size: 13px;
    color: var(--muted);
}

body.dark-mode .top-bar {
    background: var(--bg);
    border-bottom-color: var(--border);
}

body.dark-mode .top-bar-right {
    color: var(--muted);
}

/* ===== EPG layout ===== */
.epg-wrapper {
    border: none;
    /* full-bleed αισθητική */
    border-radius: 0;
    background: var(--bg);
}

.epg-scroll {
    display: grid;
    grid-template-columns: 150px 1fr;
    /* αριστερά κανάλια, δεξιά timeline */
    max-height: 85vh;

    /* Κάθετο scroll ΕΔΩ για να κατεβαίνουν ΜΑΖΙ κανάλια & γραμμές */
    overflow-y: auto;
    overflow-x: hidden;
}

.epg-channels {
    position: sticky;
    left: 0;
    z-index: 5;
    background: var(--bg);
    border-right: 1px solid #eee;
}

.epg-grid {
    /* Οριζόντιο scroll ΜΟΝΟ εδώ */
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
}

.epg-time-header {
    position: sticky;
    top: 0;
    z-index: 6;
    background: var(--bg);
    border-bottom: 1px solid #eee;
}

.time-scale {
    position: relative;
    height: 40px;
    white-space: nowrap;
}

.time-label {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    font-size: 12px;
    padding: 2px 4px;
    color: #333;
}

.grid-content {
    position: relative;
}

.channel-row {
    position: relative;
    height: 64px;
    border-bottom: 1px solid #f2f2f2;
}

.channel-cell {
    position: relative;
    /* Required for positioning the ID */
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 var(--pad);
    gap: 6px;
    border-bottom: 1px solid #f2f2f2;
    overflow: hidden;
}

.channel-cell span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    font-weight: 500;
}

.channel-id {
    display: none;
}

.channel-logo {
    width: 30px;
    height: 30px;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
}

.channel-cell .pin {
    font-size: 12px;
    color: #999
}

.program-block {
    position: absolute;
    top: 6px;
    height: 52px;
    border-radius: 6px;
    padding: 6px 8px;
    box-sizing: border-box;
    border: 1px solid #e6e6e6;
    background: #fafafa;
    overflow: hidden;
    cursor: pointer;
}

.program-block:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08)
}

.program-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 4px;
    color: #222
}

.program-time {
    font-size: 12px;
    color: var(--muted)
}

.program-block.now {
    border-color: var(--nowBlockBorder);
    background: var(--nowBlockBg)
}

.now-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--now);
    z-index: 4;
    pointer-events: none;
    opacity: .9;
    display: none;
}

/* ===== Modal ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: #fff;
    width: min(560px, 90vw);
    border-radius: 10px;
    padding: 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.modal h3 {
    margin: 0 0 6px;
    font-size: 18px
}

.modal .meta {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 8px
}

.modal .desc {
    font-size: 14px;
    color: #333;
    white-space: pre-wrap
}

.modal .actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px
}

.modal button {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: #f6f6f6;
    cursor: pointer
}

.channel-header {
    position: sticky;
    top: 0;
    z-index: 7;
    /* πιο πάνω από τις γραμμές */
    height: 40px;
    /* ίδιο με το .time-scale */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    background: var(--bg);
    border-bottom: 1px solid #eee;
}

.epg-grid {
    cursor: grab;
}

.epg-grid.grabbing {
    cursor: grabbing;
    user-select: none;
}

body.dark-mode {
    --border: #333;
    --muted: #999;
    --bg: #1a1a1a;
    color: #eee;
    background: #121212;

    --nowBlockBg: #2a3a57;
    --nowBlockBorder: #007cff;
}

body.dark-mode .tab {
    color: #ccc;
}

body.dark-mode .tab.active {
    border-color: var(--border);
    background: #2a2a2a;
}

body.dark-mode .epg-channels {
    background: var(--bg);
    border-right-color: #333;
}

body.dark-mode .epg-time-header {
    background: var(--bg);
    border-bottom-color: #333;
}

body.dark-mode .time-label {
    color: #ccc;
}

body.dark-mode .channel-cell {
    border-bottom-color: #222;
}

body.dark-mode .channel-row {
    border-bottom-color: #222;
}

body.dark-mode .program-block {
    border-color: #444;
    background: #2c2c2c;
}

body.dark-mode .program-block.now {
    border-color: var(--nowBlockBorder);
    background: var(--nowBlockBg);
}

body.dark-mode .program-title {
    color: #eee;
}

body.dark-mode .modal {
    background: #2c2c2c;
}

body.dark-mode .modal h3 {
    color: #eee;
}

body.dark-mode .modal .desc {
    color: #ccc;
}

body.dark-mode .modal button {
    background: #444;
    border-color: #555;
    color: #eee;
}

body.dark-mode .channel-header {
    background: var(--bg);
    border-bottom-color: #333;
}

body.dark-mode #updateStatus {
    color: #999;
}

/* Icon Buttons */
.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    color: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
}

.icon-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    /* Light hover */
}

body.dark-mode .icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    /* Dark hover */
}

.icon-btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Toggle Sun/Moon icons based on mode */
.icon-sun {
    display: none;
}

.icon-moon {
    display: block;
}

body.dark-mode .icon-sun {
    display: block;
}

body.dark-mode .icon-moon {
    display: none;
}

/* Spin animation for update */
@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 1s linear infinite;
}

/* Like Button */
.like-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: #ddd;
    /* Default unliked color */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, color 0.2s;
    flex-shrink: 0;
}

.like-btn:hover {
    transform: scale(1.1);
    color: #aaa;
}

.like-btn.liked {
    color: #ff4081;
    /* Liked color */
}

.like-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

body.dark-mode .like-btn {
    color: #555;
}

body.dark-mode .like-btn:hover {
    color: #777;
}

body.dark-mode .like-btn.liked {
    color: #ff4081;
}