/**
 * Modern UI/UX Enhancements for Pregnancy AI Tracker
 * Toast notifications, animations, skeleton loaders, and micro-interactions
 */

/* ===== TOAST NOTIFICATION SYSTEM ===== */
.toast-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
    pointer-events: none;
}

.toast {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 16px;
    pointer-events: all;
    transform: translateX(calc(-100% - 20px));
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55), opacity 0.3s ease;
    border-right: 4px solid;
    animation: slideInRight 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes slideInRight {
    to {
        transform: translateX(0);
    }
}

.toast.fade-out {
    animation: slideOutRight 0.3s ease forwards;
    opacity: 0;
}

@keyframes slideOutRight {
    to {
        transform: translateX(calc(-100% - 40px));
        opacity: 0;
    }
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.toast-message {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
    color: #666;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.toast-close:hover {
    color: #333;
}

/* Toast Types */
.toast-success {
    border-right-color: #10b981;
}

.toast-success .toast-icon {
    color: #10b981;
}

.toast-error {
    border-right-color: #ef4444;
}

.toast-error .toast-icon {
    color: #ef4444;
}

.toast-warning {
    border-right-color: #f59e0b;
}

.toast-warning .toast-icon {
    color: #f59e0b;
}

.toast-info {
    border-right-color: #3b82f6;
}

.toast-info .toast-icon {
    color: #3b82f6;
}

/* ===== SKELETON LOADERS ===== */
.skeleton-loader {
    width: 100%;
    padding: 20px;
}

.skeleton-line {
    height: 16px;
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 50%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 12px;
}

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

.skeleton-line.medium {
    width: 80%;
}

.skeleton-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 50%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

/* ===== MODERN ANIMATIONS ===== */
.fade-in {
    animation: fadeIn 0.4s ease-in;
}

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

.slide-in-left {
    animation: slideInLeft 0.5s ease-out;
}

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

.slide-in-right {
    animation: slideInRight 0.5s ease-out;
}

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

.scale-in {
    animation: scaleIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

/* Intersection Observer Animation */
[data-animate] {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

[data-animate].animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* ===== MICRO-INTERACTIONS ===== */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

/* Smooth focus indicators */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-600);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    transition: all 0.2s ease;
}

/* Enhanced hover states */
.nav-link {
    position: relative;
    transition: color 0.3s ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0;
    height: 2px;
    background: var(--primary-600);
    transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* ===== LOADING STATES ===== */
.spinner-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.loading {
    pointer-events: none;
    opacity: 0.6;
}

/* ===== ENHANCED SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ===== SMOOTH SCROLL ===== */
html {
    scroll-behavior: smooth;
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
.skip-to-content {
    position: absolute;
    top: -100px;
    right: 0;
    background: var(--primary-600);
    color: white;
    padding: 10px 20px;
    border-radius: 0 0 8px 8px;
    z-index: 10000;
    transition: top 0.3s ease;
}

.skip-to-content:focus {
    top: 0;
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 3px solid var(--primary-600);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Remove focus outline for mouse users */
*:focus:not(:focus-visible) {
    outline: none;
}

/* ===== RESPONSIVE TOUCH INTERACTIONS ===== */
@media (hover: none) and (pointer: coarse) {
    .card:active {
        transform: scale(0.98);
    }

    .btn:active {
        transform: scale(0.95);
    }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
/* GPU acceleration for animations */
.card,
.btn,
.nav-link,
[data-animate] {
    will-change: transform;
    backface-visibility: hidden;
    perspective: 1000px;
}

/* ===== IMAGE LOADING STATES ===== */
img[data-src] {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 50%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

img.loaded {
    animation: fadeIn 0.4s ease-in;
}

/* ===== PROGRESS INDICATORS ===== */
.progress-ring {
    transition: stroke-dashoffset 0.5s ease;
}

/* ===== MODAL ENHANCEMENTS ===== */
.modal.show {
    animation: fadeIn 0.3s ease;
}

.modal-content {
    animation: scaleIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ===== BADGE ENHANCEMENTS ===== */
.badge {
    transition: all 0.2s ease;
}

.badge:hover {
    transform: scale(1.05);
}

/* ===== RESPONSIVE UTILITIES ===== */
@media (max-width: 768px) {
    .toast-container {
        right: 10px;
        left: 10px;
        max-width: calc(100% - 20px);
    }

    .toast {
        animation: slideInBottom 0.3s ease forwards;
    }

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

/* ===== PRINT STYLES ===== */
@media print {
    .navbar,
    .toast-container,
    .btn,
    footer {
        display: none !important;
    }

    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    .toast {
        background: #1f2937;
        border-right-color: var(--primary-400);
    }

    .toast-message {
        color: #f3f4f6;
    }

    .toast-close {
        color: #9ca3af;
    }

    .toast-close:hover {
        color: #f3f4f6;
    }

    .skeleton-line,
    img[data-src] {
        background: linear-gradient(
            90deg,
            #374151 0%,
            #4b5563 50%,
            #374151 100%
        );
    }

    ::-webkit-scrollbar-track {
        background: #1f2937;
    }

    ::-webkit-scrollbar-thumb {
        background: #4b5563;
    }

    ::-webkit-scrollbar-thumb:hover {
        background: #6b7280;
    }
}

/* ===== PERFORMANCE HINTS ===== */
/* Optimize animations for mobile */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== CUSTOM PROPERTIES FOR THEMING ===== */
:root {
    --toast-success: #10b981;
    --toast-error: #ef4444;
    --toast-warning: #f59e0b;
    --toast-info: #3b82f6;
    --animation-duration: 0.3s;
    --animation-timing: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
