/**
 * SPA Enhancement Styles
 * - Toast Notifications
 * - Page Transitions
 * - Loading Indicators
 */

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

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

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 500px;
    padding: 16px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 4px solid #3b82f6;
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 18px;
    font-weight: bold;
    flex-shrink: 0;
}

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

.toast-message {
    font-size: 14px;
    line-height: 1.5;
    color: #1f2937;
    word-wrap: break-word;
}

.toast-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 4px;
    font-size: 20px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

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

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

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

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

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

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

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

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

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

/* Loading Toast */
.toast-loading .toast-icon::before {
    content: '⏳';
    animation: spin 1s linear infinite;
}

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

/* Toast Animations */
.toast-enter {
    opacity: 0;
    transform: translateX(100%) scale(0.8);
}

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

.toast-exit {
    opacity: 0;
    transform: translateX(100%) scale(0.8);
    pointer-events: none;
}

/* Mobile Responsive */
@media (max-width: 640px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: auto;
        max-width: none;
    }
}

/* ==================== PAGE TRANSITIONS ==================== */

/* Container for page content */
#app-content,
#main-content,
.page-content {
    animation: fadeIn 0.3s ease-in-out;
}

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

/* Fade out animation for page exit */
.page-exit {
    animation: fadeOut 0.2s ease-in-out forwards;
}

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

/* Slide transitions (optional) */
.page-slide-enter {
    animation: slideInRight 0.3s ease-out;
}

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

.page-slide-exit {
    animation: slideOutLeft 0.2s ease-in forwards;
}

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

/* ==================== LOADING INDICATOR ==================== */

.spa-loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
    z-index: 9999;
    pointer-events: none;
}

.spa-loading-bar {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
    background-size: 200% 100%;
    animation: loading-progress 1s ease-in-out infinite, loading-gradient 2s linear infinite;
    transform-origin: left;
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

@keyframes loading-progress {
    0% {
        transform: scaleX(0);
    }
    50% {
        transform: scaleX(0.6);
    }
    100% {
        transform: scaleX(0.9);
    }
}

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

.spa-loading-indicator.loading-complete {
    animation: loading-complete 0.3s ease-out forwards;
}

@keyframes loading-complete {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(-3px);
    }
}

/* ==================== SMOOTH SCROLL ==================== */

html {
    scroll-behavior: smooth;
}

/* ==================== LINK HOVER EFFECTS ==================== */

a {
    transition: color 0.2s ease, background-color 0.2s ease;
}

/* ==================== BUTTON TRANSITIONS ==================== */

button, .btn {
    transition: all 0.2s ease;
}

button:active, .btn:active {
    transform: scale(0.98);
}

/* ==================== SKELETON LOADING (Optional) ==================== */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

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

/* ==================== OFFLINE INDICATOR ==================== */

.offline-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: #ef4444;
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    font-weight: 500;
    z-index: 9998;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.offline-indicator.online {
    background: #10b981;
    animation: slideUp 0.3s ease-out;
}

/* ==================== PERFORMANCE OPTIMIZATIONS ==================== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* GPU acceleration for animations */
.toast,
.spa-loading-bar,
#app-content,
#main-content {
    will-change: transform, opacity;
}

/* ==================== NOTIFICATION PERMISSION DIALOG ==================== */

.notification-permission-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.dialog-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.notification-permission-dialog.dialog-visible .dialog-overlay {
    opacity: 1;
}

.dialog-content {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.notification-permission-dialog.dialog-visible .dialog-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.dialog-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    color: white;
}

.dialog-icon svg {
    width: 48px;
    height: 48px;
}

.dialog-title {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    text-align: center;
    margin: 0 0 16px;
}

.dialog-description {
    font-size: 16px;
    line-height: 1.6;
    color: #6b7280;
    text-align: center;
    margin: 0 0 24px;
}

.dialog-features {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
}

.dialog-features li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f3f4f6;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 15px;
    color: #374151;
}

.dialog-features li:last-child {
    margin-bottom: 0;
}

.dialog-features svg {
    flex-shrink: 0;
    color: #10b981;
}

.dialog-note {
    font-size: 14px;
    line-height: 1.5;
    color: #9ca3af;
    text-align: center;
    margin: 0 0 32px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 8px;
}

.dialog-actions {
    display: flex;
    gap: 12px;
    flex-direction: column-reverse;
}

.dialog-actions button {
    flex: 1;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: white;
    color: #6b7280;
    border: 2px solid #e5e7eb;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

/* Desktop layout */
@media (min-width: 640px) {
    .dialog-actions {
        flex-direction: row;
    }
}

/* Mobile responsive */
@media (max-width: 640px) {
    .dialog-content {
        padding: 24px;
    }

    .dialog-title {
        font-size: 20px;
    }

    .dialog-icon {
        width: 64px;
        height: 64px;
    }

    .dialog-icon svg {
        width: 36px;
        height: 36px;
    }
}

/* Hide when hidden */
.notification-permission-dialog.hidden {
    display: none;
}
