/* ── Snackbar / Toast notification system ── */

#snackbar-container {
    position: fixed;
    bottom: 80px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: 360px;
    max-width: calc(100vw - 32px);
}

.snackbar {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.10),
        0 1px 6px rgba(0, 0, 0, 0.06);
    padding: 14px 14px 16px 16px;
    pointer-events: all;
    position: relative;
    overflow: hidden;
    border-left: 4px solid;
    animation: snackbar-slide-in 0.38s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
    will-change: transform, opacity;
}

.snackbar.snackbar--removing {
    animation: snackbar-slide-out 0.28s ease-in forwards;
}

/* type colors */
.snackbar--success { border-color: #22c55e; }
.snackbar--info    { border-color: #3b82f6; }
.snackbar--warning { border-color: #f59e0b; }
.snackbar--danger  { border-color: #ef4444; }

/* icon wrapper */
.snackbar-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

/* text block */
.snackbar-content {
    flex: 1;
    min-width: 0;
}

.snackbar-title {
    font-size: 13px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 2px;
    line-height: 1.3;
}

.snackbar-message {
    font-size: 13px;
    color: #555;
    line-height: 1.45;
    word-break: break-word;
}

/* close button */
.snackbar-close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: #b0b0b0;
    padding: 1px 2px;
    border-radius: 5px;
    line-height: 1;
    transition: color 0.15s, background-color 0.15s;
    margin-top: 1px;
}

.snackbar-close:hover {
    color: #444;
    background-color: #f0f0f0;
}

/* progress bar */
.snackbar-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    border-radius: 0 0 0 8px;
    animation: snackbar-progress linear forwards;
    transform-origin: left center;
}

.snackbar--success .snackbar-progress { background: #22c55e; }
.snackbar--info    .snackbar-progress { background: #3b82f6; }
.snackbar--warning .snackbar-progress { background: #f59e0b; }
.snackbar--danger  .snackbar-progress { background: #ef4444; }

/* animations */
@keyframes snackbar-slide-in {
    from {
        transform: translateX(calc(100% + 32px));
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes snackbar-slide-out {
    from {
        transform: translateX(0);
        opacity: 1;
        max-height: 160px;
    }
    to {
        transform: translateX(calc(100% + 32px));
        opacity: 0;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        margin-bottom: -10px;
    }
}

@keyframes snackbar-progress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* ── History button ── */

#snackbar-history-btn {
    position: fixed;
    bottom: 24px;
    right: 80px;
    z-index: 100000;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: box-shadow 0.15s, background 0.15s, color 0.15s;
    padding: 0;
}

#snackbar-history-btn:hover {
    background: #f9fafb;
    color: #374151;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
}

#snackbar-history-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 17px;
    height: 17px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
    pointer-events: none;
    border: 2px solid #fff;
}

#snackbar-history-badge.hidden { display: none; }

#snackbar-history-dismiss {
    position: absolute;
    top: -5px;
    left: -5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #9ca3af;
    color: #fff;
    border: 2px solid #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background 0.15s;
    z-index: 1;
}

#snackbar-history-dismiss:hover { background: #6b7280; }

/* ── History panel ── */

#snackbar-history-panel {
    position: fixed;
    bottom: 74px;
    right: 80px;
    z-index: 99999;
    width: 360px;
    max-width: calc(100vw - 32px);
    max-height: 420px;
    background: #fff;
    border-radius: 14px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.13),
        0 1px 6px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    visibility: hidden;
    opacity: 0;
    transform: scale(0.9) translateY(8px);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s cubic-bezier(0.21, 1.02, 0.73, 1),
                visibility 0s linear 0.2s;
}

#snackbar-history-panel.open {
    visibility: visible;
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
    transition: opacity 0.2s, transform 0.2s cubic-bezier(0.21, 1.02, 0.73, 1),
                visibility 0s linear 0s;
}

.snackbar-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 10px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.snackbar-history-header > span {
    font-size: 13px;
    font-weight: 700;
    color: #1a1a1a;
}

#snackbar-history-clear {
    font-size: 11px;
    color: #9ca3af;
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px 7px;
    border-radius: 5px;
    transition: color 0.15s, background 0.15s;
}

#snackbar-history-clear:hover {
    color: #ef4444;
    background: #fef2f2;
}

#snackbar-history-list {
    overflow-y: auto;
    flex: 1;
}

#snackbar-history-empty {
    padding: 28px 16px;
    text-align: center;
    font-size: 12px;
    color: #c0c0c0;
}

/* ── History items ── */

.snackbar-hist-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 14px;
    border-bottom: 1px solid #f5f5f5;
}

.snackbar-hist-item:last-child { border-bottom: none; }

.snackbar-hist--unread { background: #f8faff; }

.snackbar-hist-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}

.snackbar-hist--success .snackbar-hist-dot { background: #22c55e; }
.snackbar-hist--info    .snackbar-hist-dot { background: #3b82f6; }
.snackbar-hist--warning .snackbar-hist-dot { background: #f59e0b; }
.snackbar-hist--danger  .snackbar-hist-dot { background: #ef4444; }

.snackbar-hist-body {
    flex: 1;
    min-width: 0;
}

.snackbar-hist-title {
    font-size: 11px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.3;
    margin-bottom: 2px;
}

.snackbar-hist-msg {
    font-size: 11px;
    color: #6b7280;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.snackbar-hist-msg a {
    color: inherit;
    text-decoration: underline;
}

.snackbar-hist-time {
    font-size: 10px;
    color: #b0b0b0;
    flex-shrink: 0;
    margin-top: 3px;
    white-space: nowrap;
}

/* mobile */
@media (max-width: 480px) {
    #snackbar-container {
        right: 12px;
        left: 12px;
        bottom: 80px;
        width: auto;
    }

    #snackbar-history-btn { bottom: 16px; right: 16px; }
    #snackbar-history-panel { bottom: 66px; right: 12px; left: 12px; width: auto; }
}
