/* ==========================================================================
   app-actions.css - install and notification controls
   --------------------------------------------------------------------------
   Purpose:     Top-bar icons, notification choices, iPhone banner and pop-up message.
   Used by:     index.html only.
   ========================================================================== */

/* ---------- Install and Notifications buttons ---------- */
.app-action-btn {
    display: flex;
    align-items: center;
    color: var(--text-primary);
    font-family: var(--font-body);
    text-align: left;
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease, background-color .2s ease;
}

.app-action-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.app-action-icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 50%;
}

.app-action-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
}

.app-action-label {
    font-weight: 600;
    font-size: .98rem;
}

.app-action-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-action-status > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-dot {
    flex: 0 0 auto;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #B8B8B8;
}

#installAppBtn[data-state="installed"],
#installAppBtn[data-state="running"] {
    background: var(--row-highlight-bg);
    border-color: rgba(38, 79, 39, 0.25);
}

#notifyBtn[data-state="enabled"] {
    border-color: rgba(38, 79, 39, 0.25);
}

#notifyBtn[data-state="enabled"] .status-dot {
    background: #2E9E46;
}

#notifyBtn[data-state="enabled"] .app-action-status {
    color: var(--text-secondary);
    font-weight: 600;
}

#notifyBtn[data-state="blocked"] .status-dot {
    background: #C0392B;
}

#notifyBtn[data-state="blocked"] .app-action-status {
    color: #A93226;
}

#notifyBtn[data-state="off"] .status-dot {
    background: #D9A400;
}

#notifyBtn[data-state="unsupported"] {
    opacity: .75;
}

#notifyBtn[data-state="checking"] .status-dot {
    background: #B8B8B8;
}

.nav-app-actions {
    margin: 0 0 0 auto;
    position: static;
}

.nav-app-actions .app-actions {
    display: flex;
    gap: 6px;
}

.nav-app-actions .app-action-btn {
    position: relative;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    gap: 0;
    border-radius: 50%;
    background: transparent;
    border: 1px solid transparent;
    box-shadow: none;
}

.nav-app-actions .app-action-btn:hover {
    transform: none;
    box-shadow: none;
    background: #EAF0DF;
    border-color: rgba(38, 79, 39, 0.25);
}

.nav-app-actions .app-action-icon {
    width: 36px;
    height: 36px;
    background: #EAF0DF;
    color: #264F27;
    border: 1px solid rgba(38, 79, 39, 0.35);
}

.nav-app-actions .app-action-icon svg {
    width: 19px;
    height: 19px;
}

/* The words stay for screen readers; only the icon is shown */
.nav-app-actions .app-action-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Always the bell / download icon, never the tick */
.nav-app-actions .app-action-btn .icon-default {
    display: block;
}

.nav-app-actions .app-action-btn .icon-done {
    display: none;
}

.nav-app-actions #notifyBtn[data-state="enabled"] {
    background: transparent;
}

.nav-app-actions #notifyBtn[data-state="enabled"] .app-action-icon {
    background: #264F27;
    color: #F2E8D7;
    border-color: #264F27;
}

/* Coloured dot on the bell: shows the notification status */
.nav-app-actions #notifyBtn::after {
    content: "";
    position: absolute;
    top: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-card, #fff);
    background: #B8B8B8;
}

.nav-app-actions #notifyBtn[data-state="enabled"]::after {
    background: #2E9E46;
}

.nav-app-actions #notifyBtn[data-state="off"]::after {
    background: #D9A400;
}

.nav-app-actions #notifyBtn[data-state="blocked"]::after {
    background: #C0392B;
}

.nav-app-actions #notifyBtn[data-state="unsupported"]::after {
    display: none;
}

/* Already installed, or still checking: no download icon */
.nav-app-actions #installAppBtn[data-state="installed"],
.nav-app-actions #installAppBtn[data-state="running"],
.nav-app-actions #installAppBtn[data-state="checking"] {
    display: none;
}

@media (max-width: 400px) {
    .nav-app-actions .app-actions {
        gap: 2px;
    }
}

/* ---------- Notification choices ---------- */
.notify-prefs {
    padding: 14px 16px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    animation: fadeInUp .25s ease-out;
}

.notify-prefs-title {
    margin: 0;
    font-weight: 600;
    color: var(--text-primary);
    font-size: .98rem;
}

.notify-prefs-hint {
    margin: 2px 0 10px;
    font-size: .8rem;
    color: var(--text-muted);
}

.notify-prefs-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.notify-topic {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid rgba(38, 79, 39, 0.2);
    border-radius: 999px;
    font-size: .88rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.notify-topic input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.notify-topic span::before {
    content: "+";
    display: inline-block;
    width: 1em;
    font-weight: 700;
}

.notify-topic:has(input:checked) {
    background: var(--accent);
    border-color: var(--accent);
    color: #F2E8D7;
}

.notify-topic:has(input:checked) span::before {
    content: "\2713";
}

.notify-topic:has(input:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.notify-prefs-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    gap: 10px;
}

.notify-off-btn {
    font-family: var(--font-body);
    font-size: .85rem;
    cursor: pointer;
    border-radius: 999px;
    padding: 6px 14px;
    background: none;
    border: none;
    padding-left: 0;
    color: #A93226;
    text-decoration: underline;
}

.notify-done-btn {
    font-family: var(--font-body);
    font-size: .85rem;
    cursor: pointer;
    border-radius: 999px;
    padding: 6px 14px;
    background: var(--accent);
    border: 1px solid var(--accent);
    color: #F2E8D7;
    font-weight: 600;
}

/* Panel that drops down from the top bar */
.nav-app-actions .notify-prefs {
    position: absolute;
    top: 100%;
    right: max(12px, env(safe-area-inset-right, 0px));
    z-index: 310;
    width: min(360px, calc(100vw - 24px));
    margin-top: 6px;
    box-shadow: var(--shadow-md);
}

/* ---------- iPhone and iPad install banner ---------- */
/* Added by assets/js/pwa.js on the home page */
.ios-install-banner {
    position: relative;
    margin: 12px 16px;
    padding: 14px 48px 14px 16px;
    background: var(--row-highlight-bg);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.ios-install-title {
    margin: 0 0 6px;
    font-weight: 600;
}

.ios-install-banner ol {
    margin: 0;
    padding-left: 1.3em;
}

.ios-install-note {
    margin: 6px 0 0;
    font-size: .9rem;
}

.ios-install-close {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 44px;
    height: 44px;
    border: 0;
    background: none;
    color: inherit;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

/* ---------- Pop-up message (toast) ---------- */
.app-toast {
    position: fixed;
    bottom: 85px;
    left: 50%;
    transform: translateX(-50%) translateY(30px);
    opacity: 0;
    background: rgba(28, 58, 31, 0.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #F2E8D7;
    border: 1px solid rgba(186, 222, 173, 0.25);
    padding: 10px 22px;
    border-radius: 30px;
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 1000;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.app-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
