/* Styles pour les modales modernes */

/* Overlay de la modale */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease-out;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Contenu de la modale */
.modal-content {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    border: 1px solid var(--glass-border);
    box-shadow: var(--box-shadow-hard);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    animation: slideInUp 0.3s ease-out;
    position: relative;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header de la modale */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 30px;
    border-bottom: 2px solid var(--border-color);
    background: var(--bg-secondary);
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--danger-color);
    transform: scale(1.1);
}

/* Body de la modale */
.modal-body {
    padding: 30px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* Formulaires dans les modales */
.modal-body .form-group {
    margin-bottom: 24px;
}

.modal-body .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.modal-body .form-group input,
.modal-body .form-group textarea,
.modal-body .form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
}

.modal-body .form-group input:focus,
.modal-body .form-group textarea:focus,
.modal-body .form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.1);
}

.modal-body .form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.modal-body .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Actions de la modale */
.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

.form-actions .btn {
    padding: 12px 24px;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-actions .btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

.form-actions .btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.form-actions .btn-primary {
    background: var(--gradient-primary);
    color: white;
    border: none;
    box-shadow: var(--shadow-md);
}

.form-actions .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Modales spécialisées */
.story-modal {
    max-width: 500px;
}

.marketplace-modal {
    max-width: 600px;
}

.group-modal {
    max-width: 600px;
}

.item-viewer {
    max-width: 800px;
}

.story-viewer {
    max-width: 400px;
    margin: 5% auto;
}

/* Modale de confirmation */
.confirmation-modal .modal-content {
    max-width: 400px;
    text-align: center;
}

.confirmation-modal .modal-body {
    padding: 40px 30px;
}

.confirmation-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.confirmation-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.confirmation-message {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 30px;
}

.confirmation-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Modale de chargement */
.loading-modal .modal-content {
    max-width: 300px;
    text-align: center;
}

.loading-modal .modal-body {
    padding: 40px 30px;
}

.loading-spinner-large {
    width: 60px;
    height: 60px;
    border: 6px solid var(--border-color);
    border-top: 6px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.loading-text {
    color: var(--text-secondary);
    font-size: 16px;
}

/* Modale d'image */
.image-modal .modal-content {
    max-width: 90vw;
    max-height: 90vh;
    background: transparent;
    border: none;
    box-shadow: none;
}

.image-modal .modal-body {
    padding: 0;
    text-align: center;
}

.image-modal img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius-lg);
    box-shadow: var(--box-shadow-hard);
}

/* Modale de notification */
.notification-modal .modal-content {
    max-width: 400px;
    border-left: 4px solid var(--primary-color);
}

.notification-modal.success .modal-content {
    border-left-color: var(--success-color);
}

.notification-modal.error .modal-content {
    border-left-color: var(--danger-color);
}

.notification-modal.warning .modal-content {
    border-left-color: var(--warning-color);
}

.notification-modal.info .modal-content {
    border-left-color: var(--info-color);
}

/* Animations d'entrée et de sortie */
.modal.fade-out {
    animation: fadeOut 0.3s ease-in forwards;
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.modal-content.slide-out {
    animation: slideOutDown 0.3s ease-in forwards;
}

@keyframes slideOutDown {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .modal-content {
        max-width: 95vw;
        max-height: 95vh;
        margin: 20px;
    }
    
    .modal-header {
        padding: 20px;
    }
    
    .modal-header h2 {
        font-size: 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    .story-viewer {
        max-width: 100%;
        margin: 0;
        height: 100vh;
    }
    
    .item-viewer {
        max-width: 100%;
    }
}

/* Mode sombre */
@media (prefers-color-scheme: dark) {
    .modal {
        background: rgba(0, 0, 0, 0.9);
    }
    
    .modal-content {
        background: rgba(36, 37, 38, 0.95);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .modal-header {
        background: rgba(58, 59, 60, 0.8);
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }
    
    .modal-body .form-group input,
    .modal-body .form-group textarea,
    .modal-body .form-group select {
        background: rgba(58, 59, 60, 0.8);
        border-color: rgba(255, 255, 255, 0.1);
        color: #e4e6ea;
    }
    
    .modal-body .form-group input:focus,
    .modal-body .form-group textarea:focus,
    .modal-body .form-group select:focus {
        background: rgba(36, 37, 38, 0.9);
        border-color: var(--primary-color);
    }
    
    .form-actions .btn-secondary {
        background: rgba(58, 59, 60, 0.8);
        border-color: rgba(255, 255, 255, 0.1);
        color: #b0b3b8;
    }
    
    .form-actions .btn-secondary:hover {
        background: rgba(74, 75, 76, 0.8);
        color: #e4e6ea;
    }
}

/* Effets de focus et d'accessibilité */
.modal:focus-within {
    outline: none;
}

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

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
}

/* Animation de chargement pour les boutons */
.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.btn.loading.btn-primary::after {
    border-top-color: white;
}

.btn.loading.btn-secondary::after {
    border-top-color: var(--text-secondary);
}
