/**
 * MindScaler UI Components Styles - Phase 1
 * Styles pour toasts, modals, loaders, breadcrumbs
 */

/* ============================================
   TOAST SYSTEM
   ============================================ */
#ms-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
    pointer-events: none;
}

.ms-toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    pointer-events: auto;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 300px;
}

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

.ms-toast-removing {
    opacity: 0;
    transform: translateX(100%);
}

.ms-toast-icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    border-radius: 50%;
}

.ms-toast-success .ms-toast-icon {
    background: #dcfce7;
    color: #166534;
}

.ms-toast-error .ms-toast-icon {
    background: #fee2e2;
    color: #991b1b;
}

.ms-toast-warning .ms-toast-icon {
    background: #fef3c7;
    color: #92400e;
}

.ms-toast-info .ms-toast-icon {
    background: hsl(var(--primary) / 0.1);
    color: var(--color-primary);
}

.ms-toast-message {
    flex: 1;
    font-size: 0.875rem;
    line-height: 1.5;
    color: hsl(var(--foreground));
}

.ms-toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: hsl(var(--muted-foreground));
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.ms-toast-close:hover {
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
}

.ms-toast-close:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Mobile */
@media (max-width: 768px) {
    #ms-toast-container {
        top: 0.5rem;
        right: 0.5rem;
        left: 0.5rem;
        max-width: none;
    }
    
    .ms-toast {
        min-width: auto;
        width: 100%;
    }
}

/* ============================================
   MODAL SYSTEM
   ============================================ */
.ms-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ms-modal-overlay.ms-modal-visible {
    opacity: 1;
}

.ms-modal-overlay.ms-modal-removing {
    opacity: 0;
}

.ms-modal {
    background: var(--color-background);
    border-radius: var(--radius);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ms-modal-overlay.ms-modal-visible .ms-modal {
    transform: scale(1);
}

.ms-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.ms-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: hsl(var(--foreground));
}

.ms-modal-body {
    padding: 1.5rem;
    color: hsl(var(--muted-foreground));
    line-height: 1.6;
    overflow-y: auto;
    flex: 1;
}

.ms-modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.ms-btn-destructive {
    background: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

.ms-btn-destructive:hover {
    background: hsl(var(--destructive) / 0.9);
}

/* Mobile */
@media (max-width: 768px) {
    .ms-modal {
        max-width: 100%;
        margin: 1rem;
    }
    
    .ms-modal-footer {
        flex-direction: column-reverse;
    }
    
    .ms-modal-footer .ms-btn {
        width: 100%;
    }
}

/* ============================================
   LOADING SYSTEM
   ============================================ */
.ms-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid hsl(var(--muted));
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: ms-spin 0.8s linear infinite;
}

.ms-spinner-small {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
}

.ms-spinner-large {
    width: 3rem;
    height: 3rem;
    border-width: 4px;
}

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

.ms-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ms-loading-overlay.ms-loading-visible {
    opacity: 1;
}

.ms-loading-overlay.ms-loading-removing {
    opacity: 0;
}

.ms-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.ms-loading-text {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
}

/* Skeleton screens */
.ms-skeleton-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ms-skeleton {
    background: linear-gradient(
        90deg,
        hsl(var(--muted)) 0%,
        hsl(var(--muted) / 0.5) 50%,
        hsl(var(--muted)) 100%
    );
    background-size: 200% 100%;
    animation: ms-skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius);
}

.ms-skeleton-line {
    height: 1rem;
}

.ms-skeleton-card {
    height: 200px;
}

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

/* ============================================
   BREADCRUMB SYSTEM
   ============================================ */
.ms-breadcrumb {
    padding: 1rem 0;
    margin-bottom: 1rem;
}

.ms-breadcrumb-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.ms-breadcrumb-item {
    display: flex;
    align-items: center;
}

.ms-breadcrumb-item:not(:last-child)::after {
    content: '›';
    margin-left: 0.5rem;
    color: hsl(var(--muted-foreground));
    font-size: 1.25rem;
    line-height: 1;
}

.ms-breadcrumb-link {
    color: hsl(var(--muted-foreground));
    text-decoration: none;
    transition: color 0.2s;
}

.ms-breadcrumb-link:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.ms-breadcrumb-link:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

.ms-breadcrumb-current {
    color: hsl(var(--foreground));
    font-weight: 500;
}

/* Mobile */
@media (max-width: 768px) {
    .ms-breadcrumb {
        padding: 0.75rem 0;
    }
    
    .ms-breadcrumb-list {
        font-size: 0.8125rem;
    }
}

/* ============================================
   AUTO-SAVE INDICATOR
   ============================================ */
#ms-autosave-indicator {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    padding: 0.5rem 1rem;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 9998;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

#ms-autosave-indicator.ms-autosave-visible {
    opacity: 1;
    transform: translateY(0);
}

#ms-autosave-indicator.ms-autosave-saving {
    color: hsl(var(--muted-foreground));
}

#ms-autosave-indicator.ms-autosave-saved {
    color: #166534;
    background: #dcfce7;
    border-color: #86efac;
}

#ms-autosave-indicator.ms-autosave-error {
    color: #991b1b;
    background: #fee2e2;
    border-color: #fca5a5;
}

/* Mobile */
@media (max-width: 768px) {
    #ms-autosave-indicator {
        bottom: 0.5rem;
        right: 0.5rem;
        left: 0.5rem;
        text-align: center;
    }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */
/* Focus visible amélioré */
*:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Skip link pour navigation clavier */
.ms-skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-primary);
    color: var(--color-primary-foreground);
    padding: 0.5rem 1rem;
    text-decoration: none;
    z-index: 10002;
    border-radius: 0 0 var(--radius) 0;
}

.ms-skip-link:focus {
    top: 0;
}

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

/* Amélioration du contraste pour les liens */
a {
    color: var(--color-primary);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

a:hover {
    text-decoration-thickness: 2px;
}

/* Zones de clic minimales (44x44px pour mobile) */
button,
.ms-btn,
a.ms-btn {
    min-height: 44px;
    min-width: 44px;
}

@media (min-width: 769px) {
    button.ms-btn-sm,
    .ms-btn-sm {
        min-height: 36px;
        min-width: 36px;
    }
}

