/* =============================================================================
   TOAST - Universal persistent toast component

   A flexible toast that can be launched from any page with configurable content,
   buttons, and collapse/expand behavior.

   Usage: window.PalomarrToast.show({ ... })
============================================================================= */

/* -----------------------------------------------------------------------------
   Base Container
----------------------------------------------------------------------------- */
.palomarr-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #fff;
    border-radius: var(--border-radius-p-2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0.5rem 0.5rem 0.5rem 1.5rem;
    z-index: 100;
    font-family: 'Satoshi', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Initial hidden state */
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;

    /* Smooth transitions */
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.palomarr-toast.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* -----------------------------------------------------------------------------
   Expanded State - Content Layout
----------------------------------------------------------------------------- */
.palomarr-toast-content {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

/* Text + Count container */
.palomarr-toast-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.palomarr-toast-icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.palomarr-toast-icon svg {
    width: 1rem;
    height: 1rem;
}

.palomarr-toast-text {
    font-size: 0.9rem;
    line-height: 1.3;
    white-space: nowrap;
}

.palomarr-toast-count {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem;
    color: var(--color-primary, #24433a);
    white-space: nowrap;
    background: #2f93761a;
    padding: 0.1rem 0.25rem;
    border-radius: var(--border-radius-p-med);
}

.palomarr-toast-count-label {
    opacity: 0.8;
}

/* -----------------------------------------------------------------------------
   Button Containers
----------------------------------------------------------------------------- */

/* Wrapper for all action elements (buttons + circular icons) */
.palomarr-toast-actions {
    display: flex;
    align-items: center;
    gap: 1.4rem;
}

/* Mode 1: Action buttons (x-small text buttons) */
.palomarr-toast-buttons {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.palomarr-toast-primary {
    background: color-mix(in srgb, var(--color-primary) 30%, transparent);
    color: var(--color-black);
}

.palomarr-toast-primary:hover {
    background: color-mix(in srgb, var(--color-primary) 40%, transparent);
    color: var(--color-black);
}

.palomarr-toast-secondary {
    background: color-mix(in srgb, var(--color-black) 6%, transparent);
    color: var(--color-black);
}

.palomarr-toast-secondary:hover {
    background: color-mix(in srgb, var(--color-black) 12%, transparent);
    color: var(--color-black);
}

.palomarr-toast-buttons .nectar-button.button-x-small {
    margin: 0;
}

/* Mode 2: Icon buttons (circular) */
.palomarr-toast-icons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* -----------------------------------------------------------------------------
   Circular Buttons (Close, Action Icon, Collapse Icon)
----------------------------------------------------------------------------- */
.palomarr-toast-btn-circular {
    background: var(--color-primary, #24433a);
    border: none;
    border-radius: 50%;
    width: 2.6rem;
    height: 2.6rem;
    min-width: 2.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    flex-shrink: 0;
}

.palomarr-toast-btn-circular:hover {
    background: var(--color-primary-hover, #2e5349);
    transform: scale(1.05);
}

.palomarr-toast-btn-circular img,
.palomarr-toast-btn-circular svg {
    width: 0.8rem;
    height: 0.8rem;
}

/* Close button - slightly muted */
.palomarr-toast-close {
    background: var(--color-gray, #6b7280);
}

.palomarr-toast-close:hover {
    background: var(--color-gray-dark, #4b5563);
}

/* Action icon button */
.palomarr-toast-action-icon {
    background: var(--color-primary, #24433a);
}

/* -----------------------------------------------------------------------------
   Collapsed State
----------------------------------------------------------------------------- */
.palomarr-toast.collapsed .palomarr-toast-content {
    display: none;
}

.palomarr-toast.collapsed {
    padding: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 50%;
}

/* Expand button (shown when collapsed) */
.palomarr-toast-expand {
    display: none;
    background: var(--color-primary, #24433a);
    border: none;
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    min-width: 3rem;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    margin: 0 0.3rem 0.2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.palomarr-toast-expand:hover {
    background: var(--color-primary-hover, #2e5349);
    transform: scale(1.05);
}

.palomarr-toast-expand img,
.palomarr-toast-expand svg {
    width: 18px;
    height: 18px;
}

.palomarr-toast.collapsed .palomarr-toast-expand {
    display: flex;
}

/* -----------------------------------------------------------------------------
   Animations
----------------------------------------------------------------------------- */

/* Collapse animation */
.palomarr-toast.collapsing {
    animation: toastCollapse 0.3s ease forwards;
}

@keyframes toastCollapse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0;
        transform: translateY(0) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Expand animation */
.palomarr-toast.expanding {
    animation: toastExpand 0.3s ease forwards;
}

@keyframes toastExpand {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0;
        transform: translateY(0) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* -----------------------------------------------------------------------------
   Mobile Responsiveness
----------------------------------------------------------------------------- */
@media (max-width: 640px) {
    .palomarr-toast {
        bottom: 1rem;
        right: 1rem;
        padding: 0.625rem 0.875rem;
    }

    .palomarr-toast-content {
        gap: 0.75rem;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .palomarr-toast-info {
        flex: 1;
        min-width: 0;
    }

    .palomarr-toast-text {
        font-size: 0.8rem;
        white-space: normal;
    }

    .palomarr-toast-count {
        font-size: 0.8rem;
    }

    .palomarr-toast-buttons {
        gap: 0.375rem;
    }

    .palomarr-toast-btn-circular {
        width: 1.5rem;
        height: 1.5rem;
        min-width: 1.5rem;
    }

    .palomarr-toast-btn-circular img,
    .palomarr-toast-btn-circular svg {
        width: 12px;
        height: 12px;
    }

    /* Collapsed state on mobile - stays in corner */
    .palomarr-toast.collapsed {
        left: auto;
        right: 1rem;
    }

    .palomarr-toast-expand {
        width: 2.25rem;
        height: 2.25rem;
        min-width: 2.25rem;
    }

    .palomarr-toast-expand img,
    .palomarr-toast-expand svg {
        width: 16px;
        height: 16px;
    }

    .palomarr-toast.collapsed {
        right: 0.75rem;
    }
}
