/* Tesla/Apple Inspired Toast System
 * Extraído de View/Elements/layout_messages.ctp (issue #539 — design system Croma).
 * Colores tokenizados contra webroot/css/colors.css. Iconos migrados de
 * caracteres unicode/emoji a Glyphicons Halflings (font ya cargada por Bootstrap 3).
 */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1060;
    max-width: 420px;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.toast {
    background: color-mix(in srgb, var(--color-white) 95%, transparent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid color-mix(in srgb, var(--color-white) 20%, transparent);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 12px;
    max-width: 420px;
    min-width: 320px;
    pointer-events: auto;
    position: relative;
    opacity: 0;
    transform: translateX(100%) scale(0.95);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

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

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

.toast-content {
    display: flex;
    align-items: flex-start;
    padding: 20px;
    gap: 16px;
}

.toast-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.toast-icon {
    width: 20px;
    height: 20px;
    position: relative;
}

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

.toast-title {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--color-black);
    margin: 0 0 4px 0;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.toast-body {
    font-size: var(--text-sm);
    color: var(--color-muted);
    line-height: 1.4;
    margin: 0;
}

.toast-body .alert {
    margin: 0;
    border: none;
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.toast-close {
    width: 32px;
    height: 32px;
    border: none;
    background: color-mix(in srgb, var(--color-black) 4%, transparent);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-muted);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.toast-close:hover {
    background: color-mix(in srgb, var(--color-black) 8%, transparent);
    color: var(--color-black);
    transform: scale(1.05);
}

.toast-close:active {
    transform: scale(0.95);
}

/* Progress Bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--color-white) 30%, transparent) 0%, currentColor 100%);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    transform-origin: left;
    animation: toast-progress 6s linear forwards;
}

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

/* Success Toast - Green Theme */
.toast-success {
    background: linear-gradient(135deg, var(--color-green-8) 0%, var(--color-green-9) 100%);
    border-color: var(--color-green-3);
}

.toast-success .toast-icon-wrapper {
    background: color-mix(in srgb, var(--color-white) 20%, transparent);
}

.toast-success .toast-icon::before {
    content: "\e084"; /* glyphicon-ok-sign */
    font-family: 'Glyphicons Halflings';
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--color-white);
}

.toast-success .toast-title,
.toast-success .toast-body {
    color: var(--color-white);
}

.toast-success .toast-body {
    color: var(--color-white-9);
}

.toast-success .toast-close {
    background: color-mix(in srgb, var(--color-white) 15%, transparent);
    color: var(--color-white);
}

.toast-success .toast-close:hover {
    background: color-mix(in srgb, var(--color-white) 25%, transparent);
}

.toast-success .toast-progress {
    background: color-mix(in srgb, var(--color-white) 40%, transparent);
}

/* Error Toast - Red Theme */
.toast-error,
.toast-danger {
    background: linear-gradient(135deg, var(--color-red-8) 0%, var(--color-red-9) 100%);
    border-color: var(--color-red-3);
}

.toast-error .toast-icon-wrapper,
.toast-danger .toast-icon-wrapper {
    background: color-mix(in srgb, var(--color-white) 20%, transparent);
}

.toast-error .toast-icon::before,
.toast-danger .toast-icon::before {
    content: "\e083"; /* glyphicon-remove-sign */
    font-family: 'Glyphicons Halflings';
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--color-white);
}

.toast-error .toast-title,
.toast-error .toast-body,
.toast-danger .toast-title,
.toast-danger .toast-body {
    color: var(--color-white);
}

.toast-error .toast-body,
.toast-danger .toast-body {
    color: var(--color-white-9);
}

.toast-error .toast-close,
.toast-danger .toast-close {
    background: color-mix(in srgb, var(--color-white) 15%, transparent);
    color: var(--color-white);
}

.toast-error .toast-close:hover,
.toast-danger .toast-close:hover {
    background: color-mix(in srgb, var(--color-white) 25%, transparent);
}

.toast-error .toast-progress,
.toast-danger .toast-progress {
    background: color-mix(in srgb, var(--color-white) 40%, transparent);
}

/* Warning Toast - Orange Theme */
.toast-warning {
    background: linear-gradient(135deg, var(--color-yellow-8) 0%, var(--color-yellow-9) 100%);
    border-color: var(--color-yellow-3);
}

.toast-warning .toast-icon-wrapper {
    background: color-mix(in srgb, var(--color-white) 20%, transparent);
}

.toast-warning .toast-icon::before {
    content: "\e107"; /* glyphicon-warning-sign */
    font-family: 'Glyphicons Halflings';
    font-size: var(--text-base);
    color: var(--color-white);
}

.toast-warning .toast-title,
.toast-warning .toast-body {
    color: var(--color-white);
}

.toast-warning .toast-body {
    color: var(--color-white-9);
}

.toast-warning .toast-close {
    background: color-mix(in srgb, var(--color-white) 15%, transparent);
    color: var(--color-white);
}

.toast-warning .toast-close:hover {
    background: color-mix(in srgb, var(--color-white) 25%, transparent);
}

.toast-warning .toast-progress {
    background: color-mix(in srgb, var(--color-white) 40%, transparent);
}

/* Info Toast - Blue Theme */
.toast-info {
    background: linear-gradient(135deg, var(--color-blue-8) 0%, var(--color-blue-9) 100%);
    border-color: var(--color-blue-3);
}

.toast-info .toast-icon-wrapper {
    background: color-mix(in srgb, var(--color-white) 20%, transparent);
}

.toast-info .toast-icon::before {
    content: "\e086"; /* glyphicon-info-sign */
    font-family: 'Glyphicons Halflings';
    font-size: var(--text-base);
    font-weight: normal;
    color: var(--color-white);
    font-style: normal;
}

.toast-info .toast-title,
.toast-info .toast-body {
    color: var(--color-white);
}

.toast-info .toast-body {
    color: var(--color-white-9);
}

.toast-info .toast-close {
    background: color-mix(in srgb, var(--color-white) 15%, transparent);
    color: var(--color-white);
}

.toast-info .toast-close:hover {
    background: color-mix(in srgb, var(--color-white) 25%, transparent);
}

.toast-info .toast-progress {
    background: color-mix(in srgb, var(--color-white) 40%, transparent);
}

/* Auth Toast */
.toast-auth {
    background: linear-gradient(135deg, color-mix(in srgb, var(--color-purple-light) 95%, transparent) 0%, color-mix(in srgb, var(--color-purple) 95%, transparent) 100%);
    border-color: color-mix(in srgb, var(--color-purple-light) 30%, transparent);
}

.toast-auth .toast-icon-wrapper {
    background: color-mix(in srgb, var(--color-white) 20%, transparent);
}

.toast-auth .toast-icon::before {
    content: "\e033"; /* glyphicon-lock */
    font-family: 'Glyphicons Halflings';
    font-size: var(--text-sm);
    color: var(--color-white);
}

.toast-auth .toast-title,
.toast-auth .toast-body {
    color: var(--color-white);
}

.toast-auth .toast-body {
    color: var(--color-white-9);
}

.toast-auth .toast-close {
    background: color-mix(in srgb, var(--color-white) 15%, transparent);
    color: var(--color-white);
}

.toast-auth .toast-close:hover {
    background: color-mix(in srgb, var(--color-white) 25%, transparent);
}

.toast-auth .toast-progress {
    background: color-mix(in srgb, var(--color-white) 40%, transparent);
}

/* Responsive Design */
@media (max-width: 768px) {
    .toast-container {
        top: 16px;
        right: 16px;
        left: 16px;
        max-width: none;
    }

    .toast {
        min-width: auto;
        width: 100%;
        border-radius: var(--radius-xl);
    }

    .toast-content {
        padding: 16px;
        gap: 12px;
    }

    .toast-icon-wrapper {
        width: 36px;
        height: 36px;
    }

    .toast-title {
        font-size: var(--text-sm);
    }

    .toast-body {
        font-size: var(--text-xs);
    }
}

/* Hover Effects */
.toast:hover {
    transform: translateX(0) scale(1.02);
    box-shadow: 0 12px 40px color-mix(in srgb, var(--color-black) 16%, transparent), 0 4px 12px color-mix(in srgb, var(--color-black) 12%, transparent);
}

.toast:hover .toast-progress {
    animation-play-state: paused;
}

/* Animation Improvements */
.toast.slide-in {
    animation: toast-slide-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.slide-out {
    animation: toast-slide-out 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes toast-slide-in {
    from {
        opacity: 0;
        transform: translateX(100%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toast-slide-out {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(100%) scale(0.95);
    }
}

