/**
 * CSS-ShareHub — Toasts, Confetti & Animations
 */

/* ═══ TOAST CONTAINER ═══════════════════════════════════════ */
.cssh-toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    max-width: 420px;
    width: calc(100% - 48px);
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

@media (max-width: 600px) {
    .cssh-toast-container {
        top: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
        width: auto;
    }
}

/* ═══ TOAST INDIVIDUAL ══════════════════════════════════════ */
.cssh-toast {
    pointer-events: auto;
    background: white;
    border-radius: 12px;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 320px;
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.3s ease;
    position: relative;
    overflow: hidden;
    border-left: 4px solid #1B4332;
}

.cssh-toast-show {
    transform: translateX(0);
    opacity: 1;
}

.cssh-toast-hide {
    transform: translateX(120%) scale(0.95);
    opacity: 0;
}

/* Type-specific colors */
.cssh-toast-success { border-left-color: #10B981; }
.cssh-toast-error   { border-left-color: #EF4444; }
.cssh-toast-info    { border-left-color: #3B82F6; }
.cssh-toast-warning { border-left-color: #F59E0B; }

.cssh-toast-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: white;
}

.cssh-toast-success .cssh-toast-icon { background: #10B981; }
.cssh-toast-error   .cssh-toast-icon { background: #EF4444; }
.cssh-toast-info    .cssh-toast-icon { background: #3B82F6; }
.cssh-toast-warning .cssh-toast-icon { background: #F59E0B; }

.cssh-toast-body {
    flex: 1;
    min-width: 0;
}

.cssh-toast-title {
    font-weight: 700;
    font-size: 14px;
    color: #1A1A1A;
    margin-bottom: 2px;
}

.cssh-toast-msg {
    font-size: 13px;
    color: #4B5563;
    line-height: 1.4;
    word-wrap: break-word;
}

.cssh-toast-action {
    background: transparent;
    border: 1px solid #1B4332;
    color: #1B4332;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    align-self: center;
    font-family: inherit;
    transition: all 0.15s;
}
.cssh-toast-action:hover {
    background: #1B4332;
    color: white;
}

.cssh-toast-close {
    background: transparent;
    border: none;
    color: #9CA3AF;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 0 0 4px;
    align-self: flex-start;
    transition: color 0.15s;
}
.cssh-toast-close:hover {
    color: #1A1A1A;
}

/* Progress bar */
.cssh-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: rgba(27, 67, 50, 0.15);
    transform-origin: left;
    animation: csshToastProgress linear forwards;
}

.cssh-toast-success .cssh-toast-progress { background: rgba(16, 185, 129, 0.3); }
.cssh-toast-error   .cssh-toast-progress { background: rgba(239, 68, 68, 0.3); }
.cssh-toast-warning .cssh-toast-progress { background: rgba(245, 158, 11, 0.3); }
.cssh-toast-info    .cssh-toast-progress { background: rgba(59, 130, 246, 0.3); }

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

/* ═══ CONFETTI ══════════════════════════════════════════════ */
.cssh-confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999998;
    overflow: hidden;
}

.cssh-confetti-piece {
    position: absolute;
    pointer-events: none;
    will-change: transform, opacity;
    animation: csshConfettiFall ease-out forwards;
}

@keyframes csshConfettiFall {
    0% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 1;
    }
    20% {
        opacity: 1;
    }
    100% {
        transform:
            translate(var(--cssh-dx), calc(var(--cssh-dy) + 600px))
            rotate(var(--cssh-rot));
        opacity: 0;
    }
}

/* ═══ ANIMATIONS UTILITAIRES ════════════════════════════════ */

/* Fade in up — for cards appearing */
@keyframes csshFadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cssh-fade-in {
    animation: csshFadeInUp 0.4s ease-out backwards;
}

.cssh-fade-in:nth-child(1) { animation-delay: 0ms; }
.cssh-fade-in:nth-child(2) { animation-delay: 50ms; }
.cssh-fade-in:nth-child(3) { animation-delay: 100ms; }
.cssh-fade-in:nth-child(4) { animation-delay: 150ms; }
.cssh-fade-in:nth-child(5) { animation-delay: 200ms; }
.cssh-fade-in:nth-child(6) { animation-delay: 250ms; }

/* Pulse on update */
@keyframes csshPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

.cssh-pulse {
    animation: csshPulse 0.5s ease-in-out;
}

/* Skeleton loading */
@keyframes csshSkeleton {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.cssh-skeleton {
    background: linear-gradient(
        90deg,
        rgba(229, 231, 235, 0.5) 0%,
        rgba(229, 231, 235, 0.9) 50%,
        rgba(229, 231, 235, 0.5) 100%
    );
    background-size: 200% 100%;
    animation: csshSkeleton 1.5s ease-in-out infinite;
    border-radius: 6px;
}

/* Modal animations */
.cssh-modal-dialog {
    animation: csshModalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes csshModalIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.cssh-modal-backdrop {
    animation: csshFadeIn 0.25s ease-out;
}

@keyframes csshFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Step transitions in wizard */
.cssh-step-content {
    animation: csshStepIn 0.3s ease-out;
}

@keyframes csshStepIn {
    from {
        opacity: 0;
        transform: translateX(8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Button hover lift (already in main CSS but reinforced) */
.cssh-btn {
    transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.15s ease;
}

.cssh-btn:active {
    transform: translateY(1px) scale(0.98);
}

/* Card hover lift */
.cssh-send-item,
.cssh-bundle-card,
.cssh-list-row {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.15s ease;
}

.cssh-send-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* Drill-down card looks clickable */
.cssh-send-item.cssh-clickable {
    cursor: pointer;
}

.cssh-send-item.cssh-clickable::after {
    content: '→';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #9CA3AF;
    font-size: 18px;
    transition: transform 0.2s, color 0.15s;
    opacity: 0;
}

.cssh-send-item.cssh-clickable {
    position: relative;
}

.cssh-send-item.cssh-clickable:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(4px);
    color: #1B4332;
}

/* Spinner */
.cssh-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: csshSpin 0.6s linear infinite;
    vertical-align: middle;
}

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

/* Number counter animation hint */
.cssh-stat strong[data-animated="true"],
.cssh-send-stat strong[data-animated="true"] {
    transition: color 0.3s;
}

/* Progress bar in cards */
.cssh-progress-bar {
    height: 6px;
    background: rgba(229, 231, 235, 0.6);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.cssh-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #40916C, #1B4332);
    border-radius: 3px;
    transition: width 0.8s cubic-bezier(0.65, 0, 0.35, 1);
    width: 0%;
}

/* Status pills inline */
.cssh-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cssh-status-sent     { background: #DBEAFE; color: #1E40AF; }
.cssh-status-clicked  { background: #FEF3C7; color: #92400E; }
.cssh-status-completed{ background: #D1FAE5; color: #065F46; }
.cssh-status-pending  { background: #F3F4F6; color: #6B7280; }
.cssh-status-expired  { background: #FEE2E2; color: #991B1B; }

/* Empty state with illustration */
.cssh-empty-rich {
    text-align: center;
    padding: 40px 20px;
    color: #9CA3AF;
}
.cssh-empty-rich-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}
.cssh-empty-rich-title {
    font-size: 16px;
    font-weight: 600;
    color: #6B7280;
    margin-bottom: 4px;
}
.cssh-empty-rich-msg {
    font-size: 13px;
    color: #9CA3AF;
}
