/**
 * Styles pour le système de modal générique
 * Design: noir/blanc/gris, rouge pour actions critiques
 * Style Windows: titre à gauche, bouton fermer à droite
 */

/* ============================================ */
/* BACKDROP */
/* ============================================ */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: all;
}

/* ============================================ */
/* MODAL BASE */
/* ============================================ */

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
}

.modal.active {
    opacity: 1;
    pointer-events: all;
    transform: translate(-50%, -50%) scale(1);
}

/* Tailles des modals */
.modal-small .modal-container {
    width: 400px;
    max-height: 80vh;
}

.modal-medium .modal-container {
    width: 600px;
    max-height: 85vh;
}

.modal-large .modal-container {
    width: 800px;
    max-height: 90vh;
}

.modal-xlarge .modal-container {
    width: min(var(--modal-max-width, 1400px), 95vw);
    height: min(var(--modal-max-height, 900px), 90vh);
}

/* ============================================ */
/* MODAL CONTAINER */
/* ============================================ */

.modal-container {
    background: #FFFFFF;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ============================================ */
/* MODAL HEADER (style Windows) */
/* ============================================ */

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #F8F9FA;
    border-bottom: 1px solid #E0E0E0;
    min-height: 56px;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #000000;
    margin: 0;
    user-select: none;
}

.modal-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    color: #666666;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.modal-close-btn:hover {
    background: #DC3545;
    color: #FFFFFF;
}

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

/* ============================================ */
/* MODAL BODY */
/* ============================================ */

.modal-body {
    flex: 1;
    overflow: hidden;
    background: #FFFFFF;
}

.modal-content-wrapper {
    height: 100%;
}

/* ============================================ */
/* PROJECT MODAL LAYOUT */
/* ============================================ */

.project-modal-layout {
    display: flex;
    height: 100%;
    gap: 0;
}

/* Colonne gauche: Canvas - Carré basé sur la hauteur */
.project-modal-left {
    flex: 0 0 auto;
    aspect-ratio: 1 / 1;
    height: 100%;
    background: #FAFAFA;
    border-right: 1px solid #E0E0E0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.preview-canvas-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#project-preview-canvas {
    width: 100%;
    height: 100%;
    touch-action: none; /* Permettre les interactions tactiles pour les resize handles */
}

/* Colonne droite: Paramètres */
.project-modal-right {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.project-params-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ============================================ */
/* SECTIONS DE PARAMÈTRES */
/* ============================================ */

.param-section {
    margin-bottom: 32px;
}

.param-section:last-child {
    margin-bottom: 0;
}

.param-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #000000;
    margin: 0 0 16px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.param-group {
    margin-bottom: 16px;
}

.param-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #333333;
    margin-bottom: 6px;
}

.param-group input[type="text"],
.param-group input[type="number"],
.param-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #CCCCCC;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    color: #000000;
    background: #FFFFFF;
    transition: border-color 0.15s ease;
}

.param-group input[type="text"]:focus,
.param-group input[type="number"]:focus,
.param-group textarea:focus {
    outline: none;
    border-color: #000000;
}

.param-group input[type="text"]:disabled,
.param-group input[type="number"]:disabled,
.param-group textarea:disabled {
    background: #F5F5F5;
    color: #999999;
    cursor: not-allowed;
}

.param-group textarea {
    resize: vertical;
    min-height: 80px;
}

.param-group small {
    display: block;
    font-size: 12px;
    color: #666666;
    margin-top: 4px;
}

.param-row {
    display: flex;
    gap: 16px;
}

.param-row .param-group {
    flex: 1;
}

/* ============================================ */
/* INPUTS DE COULEUR */
/* ============================================ */

.color-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.color-input-wrapper input[type="color"] {
    width: 48px;
    height: 36px;
    border: 1px solid #CCCCCC;
    border-radius: 4px;
    cursor: pointer;
    padding: 2px;
}

.color-input-wrapper input[type="text"] {
    flex: 1;
}

/* ============================================ */
/* INPUT DE FICHIER */
/* ============================================ */

.param-group input[type="file"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #CCCCCC;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    background: #FFFFFF;
}

.param-group input[type="file"]::-webkit-file-upload-button {
    padding: 6px 12px;
    border: 1px solid #CCCCCC;
    border-radius: 3px;
    background: #F8F9FA;
    color: #333333;
    font-size: 13px;
    cursor: pointer;
    margin-right: 8px;
}

.param-group input[type="file"]::-webkit-file-upload-button:hover {
    background: #E9ECEF;
}

/* ============================================ */
/* AUTEURS */
/* ============================================ */

.authors-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.author-input-wrapper {
    position: relative;
    display: flex;
    gap: 4px;
}

.author-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #CCCCCC;
    border-radius: 4px;
    font-size: 14px;
    color: #000000;
    background: #FFFFFF;
}

.author-input:focus {
    outline: none;
    border-color: #000000;
}

.author-remove-btn {
    width: 32px;
    height: 36px;
    border: 1px solid #CCCCCC;
    border-radius: 4px;
    background: #F8F9FA;
    color: #666666;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
}

.author-remove-btn:hover {
    background: #DC3545;
    border-color: #DC3545;
    color: #FFFFFF;
}

.author-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 36px;
    background: #FFFFFF;
    border: 1px solid #CCCCCC;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    display: none;
}

.author-suggestions.active {
    display: block;
}

.author-suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #333333;
}

.author-suggestion-item:hover,
.author-suggestion-item.selected {
    background: #F8F9FA;
}

.btn-add-author {
    padding: 8px 16px;
    border: 1px dashed #CCCCCC;
    border-radius: 4px;
    background: transparent;
    color: #666666;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-add-author:hover {
    border-color: #000000;
    color: #000000;
    background: #F8F9FA;
}

/* ============================================ */
/* WORD COUNT */
/* ============================================ */

.word-count {
    display: block;
    text-align: right;
    font-size: 12px;
    color: #666666;
    margin-top: 4px;
}

/* ============================================ */
/* BOUTONS D'ACTION */
/* ============================================ */

.project-modal-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid #E0E0E0;
    background: #F8F9FA;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

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

.btn-primary {
    background: #000000;
    color: #FFFFFF;
    margin-left: auto;
}

.btn-primary:hover {
    background: #333333;
}

.btn-primary:disabled {
    background: #CCCCCC;
    cursor: not-allowed;
}

.btn-secondary {
    background: #E9ECEF;
    color: #333333;
    border: 1px solid #CCCCCC;
}

.btn-secondary:hover {
    background: #DEE2E6;
}

.btn-danger {
    background: transparent;
    color: #DC3545;
    border: 1px solid #DC3545;
}

.btn-danger:hover {
    background: #DC3545;
    color: #FFFFFF;
}

/* ============================================ */
/* UPLOAD PROGRESS */
/* ============================================ */

.upload-progress {
    padding: 16px 24px;
    background: #F8F9FA;
    border-top: 1px solid #E0E0E0;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
    color: #333333;
}

#upload-status {
    font-weight: 500;
}

#upload-percentage {
    font-weight: 600;
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background: #E9ECEF;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    background: #000000;
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.upload-size {
    font-size: 12px;
    color: #666666;
    text-align: right;
}

/* ============================================ */
/* SCROLLBAR (personnalisé) */
/* ============================================ */

.project-params-scroll::-webkit-scrollbar {
    width: 8px;
}

.project-params-scroll::-webkit-scrollbar-track {
    background: #F5F5F5;
}

.project-params-scroll::-webkit-scrollbar-thumb {
    background: #CCCCCC;
    border-radius: 4px;
}

.project-params-scroll::-webkit-scrollbar-thumb:hover {
    background: #999999;
}

/* ============================================ */
/* RESPONSIVE */
/* ============================================ */

@media (max-width: 1200px) {
    .modal-xlarge .modal-container {
        width: 95vw;
    }

    .project-modal-left {
        flex: 0 0 45%;
    }
}

@media (max-width: 900px) {
    .project-modal-layout {
        flex-direction: column;
    }

    .project-modal-left {
        flex: 0 0 300px;
        border-right: none;
        border-bottom: 1px solid #E0E0E0;
    }

    .preview-canvas-container {
        max-height: 300px;
    }
}
