/**
 * Enhanced Styles
 * ===============
 *
 * Toast Notifications, Skeleton Loaders, Animations,
 * Better Focus States, Micro-Interactions
 */

/* ============================================================================
   TOAST NOTIFICATIONS
   ============================================================================ */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    min-width: 300px;
    max-width: 500px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: all;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

.toast.toast-hide {
    opacity: 0;
    transform: translateX(400px);
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 15px;
    line-height: 1.4;
    color: #2c3e50;
}

.toast-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #95a5a6;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s;
}

.toast-close:hover {
    color: #7f8c8d;
}

.toast-success {
    border-left: 4px solid #27ae60;
}

.toast-error {
    border-left: 4px solid #e74c3c;
}

.toast-warning {
    border-left: 4px solid #f39c12;
}

.toast-info {
    border-left: 4px solid #3498db;
}

/* Mobile Toast Positioning */
@media (max-width: 768px) {
    .toast-container {
        top: auto;
        bottom: 20px;
        right: 12px;
        left: 12px;
    }

    .toast {
        min-width: auto;
        transform: translateY(200px);
    }

    .toast.toast-show {
        transform: translateY(0);
    }

    .toast.toast-hide {
        transform: translateY(200px);
    }
}


/* ============================================================================
   SKELETON LOADERS
   ============================================================================ */

.skeleton-loader {
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.skeleton-fade-out {
    animation: skeleton-fade 0.3s ease-out forwards;
}

@keyframes skeleton-fade {
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

.skeleton-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    border: 2px solid #e1e8ed;
}

.skeleton-header {
    height: 24px;
    background: linear-gradient(90deg, #ecf0f1 25%, #f8f9fa 50%, #ecf0f1 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 6px;
    margin-bottom: 15px;
}

.skeleton-text {
    height: 16px;
    background: linear-gradient(90deg, #ecf0f1 25%, #f8f9fa 50%, #ecf0f1 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
    margin-bottom: 10px;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-button {
    height: 44px;
    background: linear-gradient(90deg, #ecf0f1 25%, #f8f9fa 50%, #ecf0f1 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 8px;
    margin-top: 20px;
}

.skeleton-input {
    height: 48px;
    background: linear-gradient(90deg, #ecf0f1 25%, #f8f9fa 50%, #ecf0f1 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 8px;
    margin-bottom: 15px;
}

.skeleton-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(90deg, #ecf0f1 25%, #f8f9fa 50%, #ecf0f1 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    margin: 0 auto 20px;
}

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 20px;
}

.skeleton-stat {
    height: 80px;
    background: linear-gradient(90deg, #ecf0f1 25%, #f8f9fa 50%, #ecf0f1 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* ============================================================================
   INPUT VALIDATION STYLES
   ============================================================================ */

.input-error {
    color: #e74c3c;
    font-size: 13px;
    margin-top: 6px;
    display: none;
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

input.input-invalid,
select.input-invalid,
textarea.input-invalid {
    border-color: #e74c3c !important;
    animation: input-invalid-pulse 0.5s ease-in-out;
}

@keyframes input-invalid-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
    50% { box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.2); }
}

input.input-valid,
select.input-valid,
textarea.input-valid {
    border-color: #27ae60 !important;
}

input.input-valid::after,
select.input-valid::after {
    content: '✓';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #27ae60;
    font-weight: bold;
}


/* ============================================================================
   LOADING OVERLAY
   ============================================================================ */

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: inherit;
    animation: fade-in 0.3s ease-out;
}

.loading-fade-out {
    animation: fade-out 0.3s ease-out forwards;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e1e8ed;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

.loading-message {
    color: #7f8c8d;
    font-size: 14px;
    font-weight: 600;
}

.loading-active {
    position: relative;
}


/* ============================================================================
   IMPROVED FOCUS STATES
   ============================================================================ */

*:focus {
    outline: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.scenario-card:focus-visible,
.event-card:focus-visible,
.alternative-card:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}


/* ============================================================================
   SMOOTH ANIMATIONS
   ============================================================================ */

.animated {
    animation-duration: 0.6s;
    animation-fill-mode: both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fadeInUp {
    animation-name: fadeInUp;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slideIn {
    animation-name: slideIn;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.scaleIn {
    animation-name: scaleIn;
}

/* Stagger animation delays for children */
.stagger-animation > * {
    opacity: 0;
    animation: fadeInUp 0.6s forwards;
}

.stagger-animation > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-animation > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-animation > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-animation > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-animation > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-animation > *:nth-child(6) { animation-delay: 0.6s; }


/* ============================================================================
   MICRO-INTERACTIONS
   ============================================================================ */

/* Button Press Effect */
button:active,
.btn:active {
    transform: scale(0.98);
}

/* Card Lift on Hover */
.scenario-card,
.event-card,
.alternative-card,
.trade-off-card {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease;
}

.scenario-card:hover,
.event-card:hover,
.alternative-card:hover,
.trade-off-card:hover {
    transform: translateY(-4px);
}

/* Input Focus Glow */
input:focus,
select:focus,
textarea:focus {
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    transition: box-shadow 0.3s ease;
}

/* Star Rating Bounce */
.star:active {
    animation: star-bounce 0.3s ease;
}

@keyframes star-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* Checkbox Check Animation */
input[type="checkbox"]:checked {
    animation: checkbox-pop 0.3s ease;
}

@keyframes checkbox-pop {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Success Pulse */
.success-pulse {
    animation: success-pulse 0.6s ease-out;
}

@keyframes success-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.7);
    }
    70% {
        box-shadow: 0 0 0 20px rgba(39, 174, 96, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(39, 174, 96, 0);
    }
}


/* ============================================================================
   PROGRESS INDICATORS
   ============================================================================ */

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring-circle {
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 0.6s ease-out;
}

.progress-ring-circle.active {
    stroke-dashoffset: calc(283 - (283 * var(--progress)) / 100);
}


/* ============================================================================
   SHIMMER EFFECT
   ============================================================================ */

.shimmer {
    position: relative;
    overflow: hidden;
}

.shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    to {
        left: 100%;
    }
}


/* ============================================================================
   TOOLTIPS
   ============================================================================ */

[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::before,
[data-tooltip]::after {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

[data-tooltip]::before {
    content: attr(data-tooltip);
    background: #2c3e50;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    margin-bottom: 8px;
    z-index: 1000;
}

[data-tooltip]::after {
    content: '';
    border: 6px solid transparent;
    border-top-color: #2c3e50;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    z-index: 1000;
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


/* ============================================================================
   BADGE ANIMATIONS
   ============================================================================ */

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    animation: badge-appear 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes badge-appear {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}


/* ============================================================================
   RIPPLE EFFECT
   ============================================================================ */

.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    width: 100px;
    height: 100px;
    margin-left: -50px;
    margin-top: -50px;
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
}

.ripple:active::after {
    animation: ripple-effect 0.6s ease-out;
}

@keyframes ripple-effect {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}


/* ============================================================================
   RESPONSIVE UTILITIES
   ============================================================================ */

@media (max-width: 768px) {
    .skeleton-grid {
        grid-template-columns: 1fr;
    }

    [data-tooltip]::before {
        white-space: normal;
        max-width: 200px;
    }
}


/* ============================================================================
   REDUCED MOTION SUPPORT
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
