/**
 * 🎨 Constelly Design System - Shared Components CSS
 * Version: 1.0.0
 * Date: 21 janvier 2026
 * 
 * Ce fichier centralise tous les styles CSS partagés entre les outils Constelly.
 * Il doit être importé APRÈS Tailwind CSS et après tailwind-constelly.js
 * 
 * Usage:
 * <link rel="stylesheet" href="_shared/css/components.css">
 */

/* ============================================
   📜 CUSTOM SCROLLBARS
   ============================================ */

/* Scrollbar fine et moderne */
.scrollbar-thin::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.scrollbar-thin::-webkit-scrollbar-track {
    background: transparent;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Scrollbar cachée mais scrollable */
.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Usage badge hidden globally on tool pages: quotas still apply in logic, but are no
   longer surfaced as persistent counters in the UI. */
#usage-badge {
    display: none !important;
}


/* ============================================
   🎞️ ANIMATIONS
   ============================================ */

/* Rotation infinie (loaders) */
.animate-spin-smooth {
    animation: spin-smooth 1s linear infinite;
    display: inline-flex;
    transform-origin: center;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
    transform: translateZ(0);
}

.constelly-symbol-spinner {
    animation: spin-smooth 1s linear infinite;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    line-height: 1;
    transform-origin: 50% 50%;
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
    contain: layout paint style;
    font-feature-settings: "liga";
    font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 20;
    -webkit-font-smoothing: antialiased;
}

.constelly-spinner {
    display: inline-block;
    border-style: solid;
    border-radius: 9999px;
    border-color: rgba(43, 124, 238, 0.18);
    border-top-color: #2b7cee;
    animation: spin-smooth 0.85s linear infinite;
    transform-origin: center;
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
    flex-shrink: 0;
}

@keyframes spin-smooth {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Fade in */
.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0.3;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Fade out */
.animate-fade-out {
    animation: fadeOut 0.3s ease-in forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* Fade in up (SEO content) */
.animate-fade-in-up {
    animation: fadeInUp 0.4s ease-out forwards;
    opacity: 0;
    transform: translateY(20px);
}

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

/* Fade out down */
.animate-fade-out-down {
    animation: fadeOutDown 0.4s ease-in forwards;
}

@keyframes fadeOutDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(20px);
    }
}


/* ============================================
   🗂️ FILE CARDS
   ============================================ */

.file-card {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.file-card:hover {
    transform: translateY(-2px);
}


/* ============================================
   ☑️ CUSTOM CHECKBOXES
   ============================================ */

/* Checkbox style moderne et cohérent */
[type='checkbox'].custom-check {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding: 0;
    display: inline-block;
    vertical-align: middle;
    background-origin: border-box;
    user-select: none;
    flex-shrink: 0;
    color: #2b7cee;
    background-color: #fff;
    border-color: #cbd5e1;
    border-width: 1px;
    border-radius: 0.25rem;
    width: 1rem;
    height: 1rem;
}

[type='checkbox'].custom-check:checked {
    border-color: transparent;
    background-color: currentColor;
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e");
}

/* Variante ronde (pour certains outils) */
[type='checkbox'].custom-check-round {
    border-radius: 9999px;
    width: 1.25rem;
    height: 1.25rem;
}


/* ============================================
   🎚️ CUSTOM RANGE SLIDERS
   ============================================ */

/* Slider moderne */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    width: 100%;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    background: #475569;
    border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #2b7cee;
    border-radius: 50%;
    margin-top: -6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

input[type="range"]::-moz-range-track {
    height: 6px;
    background: #475569;
    border-radius: 3px;
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #2b7cee;
    border-radius: 50%;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}


/* ============================================
   🪟 VIEW TOGGLE (Grid/List)
   ============================================ */

.view-toggle-container {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 9px;
    gap: 2px;
}

.view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    border-radius: 6px;
    color: #64748b;
    transition: all 0.2s;
}

.view-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.6);
    color: #334155;
}

.view-btn.active {
    background: white;
    color: #2b7cee;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}


/* ============================================
   🎴 MODE CARDS (Sélection de modes)
   ============================================ */

.mode-card {
    transition: all 0.2s ease;
}

.mode-card.active {
    border-color: #2b7cee !important;
    background-color: rgba(43, 124, 238, 0.05);
}

.mode-card.active .mode-icon {
    color: #2b7cee;
}

.mode-card-text {
    font-size: 0.875rem;
    line-height: 1.25rem;
    font-weight: 500;
    color: #334155;
}


/* ============================================
   ⌛ LOADING OVERLAYS
   ============================================ */

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Spinner */
.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #2b7cee;
    border-radius: 50%;
    animation: spin-smooth 1s linear infinite;
}


/* ============================================
   🍞 TOAST NOTIFICATIONS
   Style unifié inspiré du Badge Hero
   ============================================ */

.toast,
.constelly-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    left: auto;
    transform: translateX(100px);
    padding: 0.75rem 1rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    font-family: var(--font-display);
}

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

/* Style par défaut (info) - Bleu comme le primaire */
.toast,
.constelly-toast {
    background: rgba(43, 124, 238, 0.1);
    border: 1px solid rgba(43, 124, 238, 0.3);
    color: #2563eb;
}

.toast .material-symbols-outlined,
.constelly-toast .material-symbols-outlined {
    font-size: 1rem;
}

/* Success - Style Badge Vert */
.toast.success,
.constelly-toast.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #16a34a;
}

/* Error - Rouge */
.toast.error,
.constelly-toast.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
}

/* Warning - Orange/Amber */
.toast.warning,
.constelly-toast.warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #d97706;
}

/* Dark Mode support */
.dark .toast,
.dark .constelly-toast {
    background: rgba(43, 124, 238, 0.2);
    border-color: rgba(43, 124, 238, 0.4);
    color: #60a5fa;
}

.dark .toast.success,
.dark .constelly-toast.success {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.4);
    color: #4ade80;
}

.dark .toast.error,
.dark .constelly-toast.error {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

.dark .toast.warning,
.dark .constelly-toast.warning {
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fbbf24;
}


/* ============================================
   🎯 MODALS
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 400px;
    width: 90%;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}


/* ============================================
   📍 VIEWER CONTAINERS & PLACEHOLDERS
   ============================================ */

.viewer-container {
    background: white;
    position: relative;
}

.viewer-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.viewer-placeholder {
    position: absolute;
    inset: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    border: 2px dashed #cbd5e1;
    border-radius: 0.75rem;
    transition: all 0.2s;
}

.viewer-placeholder:hover {
    border-color: #2b7cee;
    background: rgba(43, 124, 238, 0.05);
}


/* ============================================
   🏷️ SECTION LABELS
   ============================================ */

.section-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.75rem;
}

.section-label .material-symbols-outlined {
    font-size: 1.125rem;
    color: #2b7cee;
}


/* ============================================
   📝 SETTINGS INPUTS
   ============================================ */

.settings-input {
    width: 100%;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid #475569;
    color: #e2e8f0;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.settings-input:focus {
    outline: none;
    border-color: #2b7cee;
}

.settings-input::placeholder {
    color: #64748b;
}


/* ============================================
   🔘 SETTINGS BUTTONS
   ============================================ */

.settings-btn {
    width: 100%;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid #475569;
    color: #cbd5e1;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
    cursor: pointer;
}

.settings-btn:hover {
    background: rgba(51, 65, 85, 0.7);
    border-color: #64748b;
}

.settings-btn.primary {
    background: #2b7cee;
    border-color: #2b7cee;
    color: white;
}

.settings-btn.primary:hover {
    background: #1d6ad6;
}


/* ============================================
   🎚️ SLIDER COMPONENTS
   ============================================ */

.slider-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.slider-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    min-width: 2.5rem;
}

.slider-value {
    font-size: 0.75rem;
    font-weight: 700;
    color: #2b7cee;
    min-width: 2.5rem;
    text-align: right;
}


/* ============================================
   🎨 GRADIENT TEXT
   ============================================ */

.text-gradient {
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-image: linear-gradient(to right, #2b7cee, #8b5cf6);
}


/* ============================================
   🚫 FOUC PREVENTION
   ============================================ */

/* 
 * ⚠️ IMPORTANT: La prévention FOUC (Flash of Unstyled Content) 
 * doit être gérée individuellement par chaque outil car elle
 * dépend du script qui ajoute la classe 'fonts-loaded'.
 * 
 * Ne pas mettre de règle html { visibility: hidden } ici car
 * cela casserait les pages qui n'ont pas le script correspondant.
 * 
 * Pattern à utiliser dans chaque outil qui le nécessite:
 * 
 * <style>
 *   html { visibility: hidden; }
 *   html.fonts-loaded { visibility: visible; }
 * </style>
 * 
 * <script>
 *   document.fonts.ready.then(() => {
 *     document.documentElement.classList.add('fonts-loaded');
 *   });
 * </script>
 */

.pre-hidden {
    display: none;
}


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

/* Container avec min-height préservé */
.tool-container {
    min-height: 400px;
}

@media (min-width: 768px) {
    .tool-container {
        height: 700px;
    }
}
