/* All interactive modals: ZIP viewer, Confirmations, and PWA install. */
/* ─── ZIP Modal Styles ─── */
.zip-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.zip-modal-content {
    background-color: var(--bg-about);
    color: var(--text-primary);
    width: 90%;
    max-width: 600px;
    max-height: 80%;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    overflow: hidden;
    animation: modal-appear 0.3s ease-out;
}

@keyframes modal-appear {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.zip-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-input);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.zip-modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.close-zip-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    opacity: 0.7;
}

.close-zip-modal:hover { opacity: 1; }

.zip-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
}

.zip-entry-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.zip-entry-list li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.entry-name {
    word-break: break-all;
    margin-right: 10px;
}

.entry-size {
    font-size: 0.8rem;
    opacity: 0.7;
    white-space: nowrap;
}

.open-zip-btn {
    display: inline-block;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
    margin-right: 8px;
    border: none;
    background-color: #ff9800;
    color: white;
    cursor: pointer;
}

.open-zip-btn:hover {
    background-color: #f57c00;
    transform: translateY(-2px);
}

/* ─── Download Confirmation Modal ─── */
.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 4000;
}

.confirm-modal-content {
    background-color: var(--bg-about);
    color: var(--text-primary);
    width: 90%;
    max-width: 500px;
    max-height: 85%;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    overflow: hidden;
    animation: modal-appear 0.3s ease-out;
}

.confirm-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-input);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.confirm-modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.close-confirm-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    opacity: 0.7;
}

.confirm-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
}

.confirm-item-list-container {
    background: rgba(0,0,0,0.03);
    border-radius: 8px;
    padding: 10px;
    margin: 15px 0;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-input);
}

.confirm-item-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.confirm-item-list li {
    padding: 6px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.confirm-summary {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid var(--border-input);
    text-align: right;
    font-size: 1.1rem;
}

.confirm-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-input);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-cancel, .btn-confirm {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-cancel {
    background: #e0e0e0;
    color: #333;
}

.btn-confirm {
    background: #1e88e5;
    color: white;
}

.btn-cancel:hover { background: #d5d5d5; }

.btn-confirm:hover {
    background: #1565c0;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* ─── PWA Installation Modal ─── */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.modal.hidden { display: none; }

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 20px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    animation: modalSlideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalSlideUp {
    from { transform: translateY(100px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.modal-logo {
    width: 80px;
    height: 80px;
    border-radius: 15px;
    margin-bottom: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.modal-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.modal-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-primary {
    background-color: #2563eb;
    color: white;
}

.btn-secondary {
    background-color: #e2e8f0;
    color: #475569;
}

/* ─── Offline pill ─── */
.offline-banner {
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    padding: 6px 12px;
    box-sizing: border-box;
    background: transparent;
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    pointer-events: none;
}

.offline-banner span {
    background-color: #d97706;
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.4;
    padding: 3px 16px;
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.3s ease, opacity 0.3s ease;
}

.offline-banner.back-online span {
    background-color: #16a34a;
}

.offline-banner.hidden {
    display: none !important;
}

/* ─── Update Notification Toast (Top Floating Banner) ─── */
.update-toast {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 480px;
    background: #0f172a;
    color: #f8fafc;
    border: 2px solid #3b82f6;
    border-radius: 14px;
    padding: 12px 18px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5), 0 0 20px rgba(59, 130, 246, 0.25);
    z-index: 2500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    animation: toast-slide-down 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.update-toast.hidden {
    display: none !important;
}

.update-toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.update-toast .update-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.update-toast .update-text {
    display: flex;
    flex-direction: column;
}

.update-toast .update-text strong {
    font-size: 0.95rem;
    color: #ffffff;
}

.update-toast .update-text span {
    font-size: 0.8rem;
    color: #93c5fd;
}

.btn-update-now {
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn-update-now:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.btn-update-dismiss {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.2s ease;
}

.btn-update-dismiss:hover {
    color: #cbd5e1;
}

/* ─── Update Success Handshake Toast (Top Floating Pill) ─── */
.update-success-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #15803d;
    color: #ffffff;
    font-size: 0.92rem;
    font-weight: 600;
    padding: 10px 22px;
    border-radius: 30px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    z-index: 2600;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toast-fade-in-out-top 3.5s forwards ease-in-out;
}

@keyframes toast-slide-down {
    from {
        opacity: 0;
        transform: translate(-50%, -25px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

@keyframes toast-fade-in-out-top {
    0% {
        opacity: 0;
        transform: translate(-50%, -25px);
    }
    15% {
        opacity: 1;
        transform: translate(-50%, 0);
    }
    80% {
        opacity: 1;
        transform: translate(-50%, 0);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -25px);
    }
}

/* ─── Level picker bottom sheet ─── */
.level-sheet {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 10001;
}
.level-sheet[hidden] { display: none; }

.level-sheet-scrim {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.level-sheet-panel {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    max-width: 520px;
    margin: 0 auto;
    padding: 10px 16px calc(24px + env(safe-area-inset-bottom, 0px));
    border-radius: 22px 22px 0 0;
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.3);
    transform: translateY(100%);
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.level-sheet.is-open .level-sheet-scrim { opacity: 1; }
.level-sheet.is-open .level-sheet-panel { transform: translateY(0); }

.level-sheet-handle {
    width: 40px;
    height: 5px;
    margin: 0 auto 14px;
    border-radius: 99px;
    background: #bbb;
}
.level-sheet-panel h2 { margin: 0 0 4px; font-size: 1.2rem; background: none; color: inherit; }
.level-sheet-panel p { margin: 0 0 6px; font-size: 0.9rem; color: var(--text-secondary); }

.level-opt {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    min-height: 60px;
    margin-top: 8px;
    padding: 8px 14px;
    border: 2px solid var(--border-input);
    border-radius: 16px;
    background: var(--bg-folder);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.level-opt-icon { font-size: 1.6rem; }
.level-opt-text b { display: block; font-size: 1.05rem; }
.level-opt-text small { font-size: 0.82rem; color: var(--text-secondary); }
.level-opt-check { display: none; margin-left: auto; font-weight: 800; color: #8a5a00; }
.level-opt.is-selected { border-color: #ffc107; background: rgba(255, 193, 7, 0.18); }
.level-opt.is-selected .level-opt-check { display: inline; }
html.dark .level-opt-check { color: #ffc107; }

.level-sheet-note {
    margin: 14px 4px 2px;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--text-secondary);
    text-align: center;
    opacity: 0.9;
}
.level-sheet-note b {
    color: var(--text-primary);
}

body.level-sheet-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
    .level-sheet-scrim, .level-sheet-panel { transition: none; }
}
