/* ============================================================
   Shared Interactive Components
   Merged: bulk-toolbar, command-palette, toasts
   ============================================================ */


/* ============================================================
   Bulk Actions Toolbar
   Shared component for zone list, zone detail, and record list
   ============================================================ */

/* ── Toolbar Container ── */
.zl-bulk-toolbar {
    position: sticky;
    bottom: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--primary);
    background: var(--primary-subtle);
    font-size: var(--text-base);
    margin-top: 0.5rem;
}

/* ── Count Label ── */
.zl-bulk-count {
    font-weight: 600;
}

/* ── Button Group ── */
.zl-bulk-actions {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
}

/* ── Shared Button Base ── */
.zl-bulk-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1875rem 0.5rem;
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    line-height: 1.5;
}

.zl-bulk-btn svg {
    flex-shrink: 0;
}

/* ── Primary (Edit) ── */
.zl-bulk-btn--primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.zl-bulk-btn--primary:hover {
    opacity: 0.9;
}

/* ── Success (Enable) ── */
.zl-bulk-btn--success {
    background: transparent;
    color: var(--success);
    border-color: var(--success);
}

.zl-bulk-btn--success:hover {
    background: rgba(58, 138, 92, 0.08);
}

/* ── Warning (Disable) ── */
.zl-bulk-btn--warning {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.zl-bulk-btn--warning:hover {
    border-color: var(--text-secondary);
    background: var(--surface-alt);
}

/* ── Secondary (Template, Export, Move) ── */
.zl-bulk-btn--secondary {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border);
}

.zl-bulk-btn--secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-subtle);
}

/* ── Danger (Delete) ── */
.zl-bulk-btn--danger {
    background: transparent;
    color: var(--danger);
    border-color: rgba(190, 75, 68, 0.3);
}

.zl-bulk-btn--danger:hover {
    border-color: var(--danger);
    background: rgba(190, 75, 68, 0.08);
}

/* ── Separator ── */
.zl-bulk-sep {
    width: 1px;
    height: 1.25rem;
    background: var(--border);
    margin: 0 0.125rem;
}

/* ── Dark Theme ── */
[data-bs-theme="dark"] .zl-bulk-btn--success:hover {
    background: rgba(106, 184, 130, 0.12);
}

[data-bs-theme="dark"] .zl-bulk-btn--danger:hover {
    background: rgba(212, 118, 110, 0.12);
}

/* ── Responsive ── */
@media (max-width: 767.98px) {
    .zl-bulk-toolbar {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
        text-align: center;
    }

    .zl-bulk-actions {
        justify-content: center;
    }
}


/* ============================================================
   Command Palette (Ctrl+K)
   ============================================================ */

.cmd-palette-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1060;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.cmd-palette-backdrop.open {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}

.cmd-palette-dialog {
    width: 560px;
    max-width: calc(100vw - 2rem);
    max-height: 480px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Search input area */
.cmd-palette-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.cmd-palette-header .bi {
    flex-shrink: 0;
    color: var(--text-secondary);
    width: 16px;
    height: 16px;
}

.cmd-palette-header .cmd-palette-spinner {
    display: none;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: var(--radius-full);
    animation: cmd-spin 0.6s linear infinite;
}

.cmd-palette-header .cmd-palette-spinner.active {
    display: block;
}

.cmd-palette-header .cmd-palette-spinner.active + .bi {
    display: none;
}

@keyframes cmd-spin {
    to { transform: rotate(360deg); }
}

.cmd-palette-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.9375rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
}

.cmd-palette-input::placeholder {
    color: var(--text-secondary);
}

.cmd-palette-esc {
    flex-shrink: 0;
    font-size: var(--text-xs);
    padding: 0.125rem 0.375rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    background: var(--surface-alt);
    line-height: 1.4;
    font-family: var(--font-sans);
}

/* Results area */
.cmd-palette-results {
    overflow-y: auto;
    flex: 1;
    padding: 0.25rem 0;
}

.cmd-palette-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: var(--text-base);
}

.cmd-palette-section-label {
    padding: 0.375rem 1rem 0.25rem;
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.cmd-palette-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
    font-size: var(--text-base);
    border: 2px solid transparent;
}

.cmd-palette-item:hover,
.cmd-palette-item[aria-selected="true"] {
    background: var(--primary-subtle);
}

.cmd-palette-item:focus-visible {
    outline: none;
    border-color: var(--primary);
    border-radius: var(--radius-sm);
}

.cmd-palette-item .bi {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.cmd-palette-item-text {
    flex: 1;
    min-width: 0;
}

.cmd-palette-item-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cmd-palette-item-detail {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Footer with keyboard hints */
.cmd-palette-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border);
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.cmd-palette-footer kbd {
    font-size: var(--text-xs);
    padding: 0.125rem 0.375rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    line-height: 1.4;
    margin-right: 0.25rem;
}

/* ── Command Palette Dark Theme ── */
[data-bs-theme="dark"] .cmd-palette-backdrop {
    background: rgba(0, 0, 0, 0.7);
}

[data-bs-theme="dark"] .cmd-palette-dialog {
    box-shadow: var(--shadow-lg);
}


/* ============================================================
   Toast Notification System
   ============================================================ */

/* ── Container ── */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 400px;
    pointer-events: none;
}

/* ── Toast Card ── */
.toast-notification {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--info);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    animation: toast-slide-in 0.3s ease-out;
}

/* ── Type Variants (colored left border + icon color) ── */
.toast-notification--success {
    border-left-color: var(--success);
}

.toast-notification--success .toast-icon {
    color: var(--success);
}

.toast-notification--error {
    border-left-color: var(--danger);
}

.toast-notification--error .toast-icon {
    color: var(--danger);
}

.toast-notification--warning {
    border-left-color: var(--warning);
}

.toast-notification--warning .toast-icon {
    color: var(--warning);
}

.toast-notification--info {
    border-left-color: var(--info);
}

.toast-notification--info .toast-icon {
    color: var(--info);
}

/* ── Icon ── */
.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 1px;
}

/* ── Message ── */
.toast-message {
    flex: 1;
    color: var(--text-primary);
    font-size: var(--text-md);
    line-height: 1.4;
    word-break: break-word;
}

/* ── Close Button ── */
.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--text-secondary);
    opacity: 0.7;
    transition: opacity 0.15s;
    line-height: 1;
}

.toast-close:hover {
    opacity: 1;
}

.toast-close svg {
    width: 16px;
    height: 16px;
}

/* ── Progress Bar ── */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border);
}

.toast-progress-bar {
    height: 100%;
    transform-origin: left;
    transition: transform linear;
}

.toast-notification--success .toast-progress-bar {
    background: var(--success);
}

.toast-notification--error .toast-progress-bar {
    background: var(--danger);
}

.toast-notification--warning .toast-progress-bar {
    background: var(--warning);
}

.toast-notification--info .toast-progress-bar {
    background: var(--info);
}

/* ── Animations ── */
@keyframes toast-slide-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast-notification--exiting {
    animation: toast-slide-out 0.3s ease-in forwards;
}

@keyframes toast-slide-out {
    from {
        opacity: 1;
        transform: translateX(0);
        max-height: 200px;
        margin-bottom: 0;
    }
    50% {
        opacity: 0;
        transform: translateX(100%);
        max-height: 200px;
    }
    to {
        opacity: 0;
        transform: translateX(100%);
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        margin-bottom: -0.5rem;
        overflow: hidden;
    }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
    .toast-notification {
        animation: none;
    }

    .toast-notification--exiting {
        animation: none;
        display: none;
    }

    .toast-progress-bar {
        transition: none;
    }
}

/* ── Responsive: full-width on small screens ── */
@media (max-width: 480px) {
    .toast-container {
        left: 0.5rem;
        right: 0.5rem;
        max-width: none;
    }
}


/* ============================================================
   Keyboard Shortcuts
   ============================================================ */

/* ── Row Focus Indicator (j/k navigation) ── */
.kb-focused {
    outline: 2px solid var(--primary) !important;
    outline-offset: -2px;
    background-color: var(--primary-subtle) !important;
}

/* ── Shortcut Hint (kbd badge on buttons) ── */
.shortcut-hint {
    display: inline-block;
    font-family: var(--font-sans);
    font-size: var(--text-2xs);
    font-weight: 600;
    padding: 0.0625rem 0.3125rem;
    margin-left: 0.375rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
    color: var(--text-secondary);
    line-height: 1.3;
    vertical-align: middle;
    opacity: 0.7;
}

/* ── Cheat Sheet Modal ── */
.kb-shortcut-section {
    margin-bottom: 1rem;
}

.kb-shortcut-section:last-child {
    margin-bottom: 0;
}

.kb-shortcut-heading {
    font-size: var(--text-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}

.kb-shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3125rem 0;
    font-size: var(--text-base);
}

.kb-shortcut-keys {
    flex-shrink: 0;
    min-width: 100px;
}

.kb-shortcut-keys kbd {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
    color: var(--text-primary);
}

.kb-shortcut-desc {
    color: var(--text-secondary);
    font-size: var(--text-base);
    text-align: right;
}
