/**
 * SparkleCharge UX Design System (Phase 3 & Phase 11 Unified)
 * Includes:
 * - Toast Notifications (Deep navy, auto-dismiss 4s, semantic indicators)
 * - Accessible Confirmation Modals (Deep graphite panels, strict "DELETE" typing)
 * - Skeleton Loaders & Dark Shimmer Animations
 * - Button Loading Spinners & Double-Submit Prevention
 * - Sticky Floating Bulk Actions Bar
 * - Global Search (Ctrl+K) Dropdown in Command Center
 */

/* ── 1. Toast Notifications ── */
.sparkle-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 420px;
    width: 100%;
}

@media (max-width: 600px) {
    .sparkle-toast-container {
        top: 14px;
        right: 12px;
        left: 12px;
        width: auto;
        max-width: none;
        align-items: center;
    }
}

.sparkle-toast-item {
    pointer-events: auto;
    background: #0B1325;
    color: #F8FAFC;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    font-size: 0.88rem;
    position: relative;
    overflow: hidden;
    border-left: 4px solid var(--color-brand-primary, #2563EB);
    animation: toastSlideIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    transition: transform 0.25s ease, opacity 0.25s ease;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(110%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@media (max-width: 600px) {
    @keyframes toastSlideIn {
        from {
            transform: translateY(-50px);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
}

.sparkle-toast-item.toast-leaving {
    transform: translateX(110%);
    opacity: 0;
}

@media (max-width: 600px) {
    .sparkle-toast-item.toast-leaving {
        transform: translateY(-40px);
        opacity: 0;
    }
}

.sparkle-toast-item.toast-success { border-left-color: #10B981; }
.sparkle-toast-item.toast-error   { border-left-color: #EF4444; }
.sparkle-toast-item.toast-warning { border-left-color: #F59E0B; }
.sparkle-toast-item.toast-info    { border-left-color: #38BDF8; }

.sparkle-toast-icon {
    font-size: 1.15rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 1px;
}

.sparkle-toast-content {
    flex: 1;
    min-width: 0;
}

.sparkle-toast-title {
    font-weight: 700;
    color: #FFFFFF;
    margin-bottom: 2px;
    font-size: 0.9rem;
}

.sparkle-toast-message {
    color: #94A3B8;
    line-height: 1.4;
    word-break: break-word;
}

.sparkle-toast-close {
    background: none;
    border: none;
    color: #64748B;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.15s ease;
    flex-shrink: 0;
}
.sparkle-toast-close:hover {
    color: #FFFFFF;
}

.sparkle-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(37, 99, 235, 0.4);
    width: 100%;
    transform-origin: left;
    animation: toastProgress 4s linear forwards;
}

@keyframes toastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* ── 2. Confirmation Modals ── */
.sparkle-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 18, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 999998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.sparkle-modal-backdrop.is-active {
    opacity: 1;
    pointer-events: auto;
}

.sparkle-modal-dialog {
    background: var(--color-bg-surface, #0D1527);
    color: var(--color-text-primary, #F8FAFC);
    border: 1px solid var(--color-border-subtle, rgba(255, 255, 255, 0.08));
    border-radius: 16px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.05);
    transform: scale(0.95);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.sparkle-modal-backdrop.is-active .sparkle-modal-dialog {
    transform: scale(1);
}

.sparkle-modal-header {
    padding: 1.35rem 1.5rem 0.5rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.sparkle-modal-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.sparkle-modal-icon.icon-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #F87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.sparkle-modal-icon.icon-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #FBBF24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.sparkle-modal-icon.icon-info {
    background: rgba(37, 99, 235, 0.15);
    color: #60A5FA;
    border: 1px solid rgba(37, 99, 235, 0.3);
}

.sparkle-modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #FFFFFF;
    margin: 0;
}

.sparkle-modal-body {
    padding: 0.75rem 1.5rem 1.35rem 1.5rem;
    font-size: 0.92rem;
    color: var(--color-text-secondary, #94A3B8);
    line-height: 1.55;
}

.sparkle-modal-input-wrap {
    margin-top: 1rem;
    background: #080E1B;
    border: 1px solid #1E293B;
    border-radius: 8px;
    padding: 0.85rem;
}

.sparkle-modal-input-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #CBD5E1;
    margin-bottom: 0.45rem;
    display: block;
}

.sparkle-modal-input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid #2A3A59;
    border-radius: 6px;
    font-size: 0.92rem;
    background: #0D1527;
    color: #FFFFFF;
    outline: none;
    box-sizing: border-box;
}
.sparkle-modal-input:focus {
    border-color: #3B82F6;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

.sparkle-modal-footer {
    padding: 0.85rem 1.5rem 1.35rem 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ── 3. Skeleton Loaders & Shimmer Animations ── */
.sparkle-skeleton {
    background: #111A2E;
    position: relative;
    overflow: hidden;
    border-radius: 6px;
}

.sparkle-skeleton::after {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.04) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: sparkleShimmer 1.8s infinite;
    content: '';
}

@keyframes sparkleShimmer {
    100% {
        transform: translateX(100%);
    }
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    border-radius: 4px;
}
.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 70%; }
.skeleton-text.long { width: 95%; }

.skeleton-title {
    height: 22px;
    width: 50%;
    margin-bottom: 14px;
    border-radius: 6px;
}

.skeleton-circle {
    border-radius: 50%;
}

.skeleton-card {
    height: 120px;
    border-radius: 12px;
    margin-bottom: 1rem;
}

/* ── 4. Button Loading Spinners & Double-Submit Prevention ── */
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #FFFFFF;
    animation: btnSpin 0.7s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}

@keyframes btnSpin {
    to { transform: rotate(360deg); }
}

.btn.is-submitting {
    pointer-events: none !important;
    opacity: 0.82 !important;
    cursor: not-allowed !important;
}

/* ── 5. Sticky Floating Bulk Action Bar ── */
.sticky-bulk-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 1000;
    background: #0B1325;
    color: #FFFFFF;
    border-radius: 14px;
    padding: 0.75rem 1.35rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 90vw;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
    opacity: 0;
    pointer-events: none;
}

.sticky-bulk-bar.is-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.sticky-bulk-badge {
    background: var(--color-brand-primary, #2563EB);
    color: #FFFFFF;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    white-space: nowrap;
}

/* ── 6. Global Search Dropdown Styling ── */
.topbar-search-wrapper {
    position: relative;
    max-width: 380px;
    width: 100%;
}
@media (max-width: 768px) {
    .topbar-search-wrapper {
        display: none;
    }
}

.topbar-search-input {
    width: 100%;
    padding: 0.5rem 4.5rem 0.5rem 2.2rem;
    border-radius: 9999px;
    border: 1px solid var(--color-border-muted, #1E293B);
    background: #080E1B;
    font-size: 0.85rem;
    color: #F8FAFC;
    outline: none;
    transition: all 0.15s ease;
    box-sizing: border-box;
}

.topbar-search-input::placeholder {
    color: #475569;
}

.topbar-search-input:focus {
    background: #0B1324;
    border-color: #3B82F6;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.topbar-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    color: #64748B;
    pointer-events: none;
}

.topbar-search-kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.08);
    color: #94A3B8;
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    pointer-events: none;
}

.search-results-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #0D1527;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6);
    z-index: 1060;
    max-height: 420px;
    overflow-y: auto;
    display: none;
}

.search-result-group-title {
    padding: 0.5rem 0.85rem 0.25rem 0.85rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748B;
    background: #080E1B;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.search-result-group-title:first-child {
    border-top: none;
}

.search-result-item {
    padding: 0.65rem 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: #F8FAFC;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.1s ease;
}
.search-result-item:hover,
.search-result-item.is-selected {
    background: rgba(37, 99, 235, 0.12);
    color: #60A5FA;
}

.search-result-title {
    font-weight: 600;
    font-size: 0.88rem;
}
.search-result-meta {
    font-size: 0.75rem;
    color: #94A3B8;
}