/* ============================================================================
   LOADING & ERROR STATES
   ============================================================================ */

/* Loading spinner */
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent-blue);
    border-radius: var(--radius-circle);
    animation: spin 0.8s linear infinite;
}

/* Uses @keyframes spin defined earlier */

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Error state */
.error-message {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    background: rgba(229, 62, 62, 0.1);
    border: 1px solid rgba(229, 62, 62, 0.2);
    border-radius: var(--radius-md);
    color: var(--color-red-text);
    font-size: var(--font-size-sm);
}

.error-message svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Update banner — floating toast pill, anchored TOP-CENTRE.
 *
 * Position: it used to sit at `bottom: 32px`, which put it straight on top of
 * the bottom-anchored ritual surfaces (`.eod-sheet`, `.day-planner-panel`) —
 * and because the pill is `pointer-events: auto` while visible it did not
 * merely obscure their action rows, it SWALLOWED the clicks. The shared
 * snackbar avoids that collision by lifting (js/utils/snackbar-placement.js);
 * this banner is a SEPARATE implementation (`.update-banner`, built only by
 * js/modules/update-checker.js — it is not a `.snackbar`), so it was anchored
 * to the top instead. The shared snackbar deliberately stays at the bottom.
 *
 * That move was justified on the grounds that the top was empty. It is not:
 * `.archive-bulk-toolbar` (top 24px, z 100) and `.floating-recording-bar`
 * (top 12px, z 9998) are both fixed top-centre, and this pill at z 10000 sat
 * on them and swallowed their clicks — the original defect, one edge over.
 * The banner therefore YIELDS rather than picking another "empty" spot:
 * js/utils/top-surface-placement.js measures the top band and sets
 * `--update-banner-offset`, consumed by the transforms below. ANY new fixed
 * top-anchored surface must register there — see that file's contract.
 *
 * Theme: every colour here comes from a local custom property so the two dark
 * blocks below can re-point them. Previously the surface was a hardcoded
 * `rgba(255, 255, 255, 0.97)` with a themed `--text-primary` on top, so in
 * dark mode the banner stayed white while its label turned near-white.
 */
.update-banner {
    --update-banner-bg: rgba(255, 255, 255, 0.97);
    --update-banner-border: var(--border-medium, rgba(0, 0, 0, 0.12));
    --update-banner-shadow: 0 10px 30px rgba(26, 26, 46, 0.12), 0 2px 8px rgba(26, 26, 46, 0.06);
    --update-banner-dismiss-hover: var(--hover-light, rgba(0, 0, 0, 0.04));
    --update-banner-dismiss-active: var(--surface-active, rgba(0, 0, 0, 0.08));
    /* Solid blue fills whose #FFF label clears WCAG AA (4.5:1). The raw brand
       accent #4A90D9 is only 3.3:1 with white and the brand secondary #357ABD
       measures 4.497:1 — rounds to AA, isn't. These are the same AA-safe steps
       already used elsewhere in this sheet: #3276B8 (--text-completed, 4.75:1),
       #2d6ca8 (5.5:1) and #2d6aa3 (--primary-hover, 5.7:1). Pinned by
       tests/unit/update-banner.test.js. */
    --update-banner-action-bg: #3276B8;
    --update-banner-action-hover: #2d6ca8;
    --update-banner-action-active: #2d6aa3; /* matches --primary-hover */

    /* Vertical drop applied by js/utils/top-surface-placement.js so the banner
       clears whatever else occupies the top band — the Archive bulk toolbar,
       the floating recording pill, the support-mode strip. 0 when it is clear.
       The banner is the only surface up here that can move, so it is the one
       that yields. Composed into every transform state below, reduced-motion
       included, or the drop silently stops applying in that mode. */
    --update-banner-offset: 0px;

    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(calc(-24px + var(--update-banner-offset)));
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
    background: var(--update-banner-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--update-banner-border);
    border-radius: var(--radius-full);
    color: var(--text-primary, #1A1A2E);
    font-family: 'Avenir Next', -apple-system, sans-serif;
    font-size: var(--font-size-sm);
    font-weight: 500;
    letter-spacing: -0.01em;
    z-index: var(--z-layer-modal);
    opacity: 0;
    box-shadow: var(--update-banner-shadow);
    transition: opacity var(--duration-slow) var(--ease-in-out),
                transform var(--duration-slow) var(--ease-in-out);
    white-space: nowrap;
    pointer-events: none;
}

.update-banner.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(var(--update-banner-offset));
    pointer-events: auto;
}

/* Dark theme — explicit choice. */
[data-theme="dark"] .update-banner {
    --update-banner-bg: rgba(42, 42, 42, 0.97);
    --update-banner-border: var(--border-medium, rgba(255, 255, 255, 0.12));
    --update-banner-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Dark theme — system preference, when no explicit theme is set. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .update-banner {
        --update-banner-bg: rgba(42, 42, 42, 0.97);
        --update-banner-border: var(--border-medium, rgba(255, 255, 255, 0.12));
        --update-banner-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
    }
}

.update-banner-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-circle);
    /* Decorative 8px dot, not text — the raw accent is fine here. */
    background: var(--accent-blue, #4A90D9);
    flex-shrink: 0;
    box-shadow: 0 0 8px rgba(74, 144, 217, 0.5);
}

.update-banner-message {
    flex: 0 1 auto;
    color: var(--text-secondary, #495057);
    font-weight: 500;
}

.update-banner-action {
    background: var(--update-banner-action-bg);
    color: #fff;
    border: 1px solid var(--update-banner-action-bg);
    border-radius: var(--radius-full);
    padding: var(--space-2) var(--space-4);
    min-height: 44px;
    font-family: 'Avenir Next', -apple-system, sans-serif;
    font-size: var(--font-size-12);
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: background var(--transition-fast, var(--duration-fast) var(--ease-in-out)),
                border-color var(--transition-fast, var(--duration-fast) var(--ease-in-out));
    white-space: nowrap;
}

.update-banner-action:hover {
    background: var(--update-banner-action-hover);
    border-color: var(--update-banner-action-hover);
}

.update-banner-action:active {
    background: var(--update-banner-action-active);
    border-color: var(--update-banner-action-active);
}

.update-banner-dismiss {
    background: none;
    border: none;
    color: var(--text-tertiary, #868E96);
    cursor: pointer;
    padding: var(--space-3);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-circle);
    transition: color var(--duration-fast) var(--ease-in-out), background var(--duration-fast) var(--ease-in-out);
    flex-shrink: 0;
}

.update-banner-dismiss:hover {
    color: var(--text-secondary, #495057);
    background: var(--update-banner-dismiss-hover);
}

.update-banner-dismiss:active {
    background: var(--update-banner-dismiss-active);
}

@media (prefers-reduced-motion: reduce) {
    .update-banner {
        transition: opacity var(--duration-fast) var(--ease-in-out);
        /* No slide, but the collision drop is positioning rather than
           decoration — it must still apply or the banner lands back on the
           Archive toolbar for anyone who prefers reduced motion. */
        transform: translateX(-50%) translateY(var(--update-banner-offset));
    }
    .update-banner.visible {
        transform: translateX(-50%) translateY(var(--update-banner-offset));
    }
}

/* Preview environment indicator */
.preview-indicator {
    position: fixed;
    bottom: 12px;
    left: 12px;
    background: var(--color-amber-fill);
    color: var(--color-on-amber);
    font-size: var(--font-size-xs);
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    z-index: calc(var(--z-layer-modal) + 1);
    pointer-events: none;
    letter-spacing: 0.04em;
    font-family: 'SF Mono', 'Menlo', monospace;
}

/* Offline indicator */
.offline-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-amber-fill);
    color: var(--color-on-amber);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    box-shadow: var(--shadow-2);
    z-index: var(--z-layer-modal);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-slow) var(--ease-in-out);
}

.offline-indicator.visible {
    opacity: 1;
    pointer-events: auto;
}

.offline-indicator svg {
    width: 16px;
    height: 16px;
}

/* Button loading state */
.btn-loading {
    position: relative;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: var(--radius-circle);
    animation: spin 0.8s linear infinite;
}

/* Disabled state for dropdowns during loading */
.dropdown-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Loading overlay for workspace switching and major operations */
.loading-overlay {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading-overlay::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent-blue);
    border-radius: var(--radius-circle);
    animation: spin 0.8s linear infinite;
}

button.is-loading {
    cursor: wait;
    opacity: 0.7;
}

/* ============================================================================
   EVENT MODAL DELETE BUTTON
   ============================================================================ */

.event-modal-delete {
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.event-modal-delete:hover {
    background: rgba(229, 62, 62, 0.1);
    color: var(--color-red-text);
}

.event-modal-delete svg {
    width: 18px;
    height: 18px;
}
