/* Offline mode: the Save sheet (home page and player) and the home page's
   "On this device" row. The player does not load index.css, so nothing here
   relies on its variables without a fallback. */

/* ── Save sheet ── */
.offline-sheet {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
    font-family: 'Inter', sans-serif;
}

.offline-sheet.show { display: flex; }

.offline-sheet-card {
    position: relative;
    width: 92%;
    max-width: 420px;
    background: #181818;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 14px;
    padding: 1.4rem 1.4rem 1.2rem;
    color: #f0f0f0;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    text-align: left;
    line-height: 1.45;
}

.offline-sheet-close {
    position: absolute;
    top: 0.7rem;
    right: 0.7rem;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    cursor: pointer;
}

.offline-sheet-close:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }

.offline-sheet-head {
    display: flex;
    gap: 0.85rem;
    align-items: center;
    padding-right: 2rem;
}

.offline-sheet-poster {
    width: 52px;
    height: 76px;
    object-fit: cover;
    border-radius: 6px;
    background: #2a2a2a;
    flex-shrink: 0;
}

.offline-sheet-names { min-width: 0; }

.offline-sheet-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
}

.offline-sheet-sub {
    font-size: 0.8rem;
    color: #9a9a9a;
    margin-top: 0.15rem;
}

.offline-sheet-status {
    font-size: 0.86rem;
    font-weight: 600;
    color: #f0f0f0;
}

.offline-sheet-status:empty { display: none; }
.offline-sheet-status.done { color: #4ade80; }
.offline-sheet-status.failed { color: #f87171; }
.offline-sheet-status.waiting,
.offline-sheet-status.paused { color: #fbbf24; }

.offline-sheet-bar {
    height: 4px;
    background: #333;
    border-radius: 4px;
    overflow: hidden;
    margin-top: -0.4rem;
}

.offline-sheet-fill {
    height: 100%;
    width: 0;
    background: #e50914;
    transition: width 0.4s;
}

.offline-sheet-note {
    font-size: 0.8rem;
    color: #a8a8a8;
    margin: 0;
}

.offline-sheet-note:empty { display: none; }

.offline-sheet-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.offline-btn {
    flex: 1 1 auto;
    padding: 0.65rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.85);
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
}

.offline-btn:hover { background: rgba(255, 255, 255, 0.13); color: #fff; }
.offline-btn.main { background: #e50914; border-color: #e50914; color: #fff; }
.offline-btn.main:hover { background: #c1070f; }
.offline-btn:disabled { opacity: 0.5; cursor: default; }

.offline-sheet-file {
    font-size: 0.76rem;
    color: #8a8a8a;
    text-align: center;
}

.offline-sheet-file:hover { color: #cfcfcf; }

@media (max-width: 600px) {
    .offline-sheet { align-items: flex-end; }
    .offline-sheet-card {
        width: 100%;
        max-width: none;
        border-radius: 16px 16px 0 0;
        padding-bottom: calc(1.3rem + env(safe-area-inset-bottom, 0px));
    }
}

/* ── Home page: no connection ── */
.offline-banner {
    display: none;
    margin: 0 0 1.5rem;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fbbf24;
    font-size: 0.88rem;
    font-weight: 500;
}

body.is-offline .offline-banner { display: block; }
body.is-offline .request-bar-wrap,
body.is-offline #continue-watching,
body.is-offline #shows-view,
body.is-offline #episodes-view,
body.is-offline .history-btn,
body.is-offline .logout-btn { display: none !important; }

/* ── Home page: what is saved on this device ── */
.offline-section { display: none; margin-bottom: 2.5rem; }
.offline-section.has-items { display: block; }

.offline-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.offline-usage { font-size: 0.75rem; color: var(--text-secondary, #888); }

.offline-card { flex-basis: 250px; }
.offline-card .continue-time { color: var(--text-secondary, #888); }
.offline-card .continue-time.done { color: #4ade80; }
.offline-card .continue-time.failed { color: #f87171; }
.offline-card .continue-time.waiting,
.offline-card .continue-time.paused { color: #fbbf24; }

.offline-card-actions { display: flex; flex-direction: column; gap: 0.35rem; flex-shrink: 0; }

.offline-empty {
    color: var(--text-secondary, #888);
    font-size: 0.88rem;
    padding: 0.5rem 0 1rem;
}

/* ── Episode list: saved / saving marks ── */
.offline-mark {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    white-space: nowrap;
}

.offline-mark:empty { display: none; }
.offline-mark.done { color: #4ade80; background: rgba(74, 222, 128, 0.1); }
.offline-mark.saving,
.offline-mark.waiting { color: #f0f0f0; background: rgba(229, 9, 20, 0.25); }
.offline-mark.paused,
.offline-mark.failed { color: #fbbf24; background: rgba(245, 158, 11, 0.1); }
