/**
 * Améliorations du modal d'événements CDClient Calendrier
 * Amélioration du CSS existant sans restructuration
 */

/* Modal plus large pour le contenu */
.modal-card.modal-card-calendier-single-event {
    width: 95vw;
    max-width: 1400px;
    max-height: 95vh;
}

/* Réorganisation des colonnes existantes */
.modal-card-calendier-single-event .columns {
    margin: 0 -0.5rem;
}

.modal-card-calendier-single-event .column {
    padding: 0.5rem;
}

/* Ajustement des colonnes pour qu'elles soient plus larges */
.modal-card-calendier-single-event .column.is-one-quarter {
    flex: none;
    width: 33.3333%;
}

.modal-card-calendier-single-event .column.is-one-third {
    flex: none;
    width: 50%;
}

/* Organisation en 2 colonnes sur écrans moyens */
@media (max-width: 1200px) {
    .modal-card-calendier-single-event .column.is-one-quarter,
    .modal-card-calendier-single-event .column.is-one-third {
        width: 50%;
    }
}

/* Pleine largeur sur mobile */
@media (max-width: 768px) {
    .modal-card.modal-card-calendier-single-event {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
    }
    
    .modal-card-calendier-single-event .column.is-one-quarter,
    .modal-card-calendier-single-event .column.is-one-third {
        width: 100%;
    }
}

/* Header du modal amélioré */
.modal-card-calendier-single-event .modal-card-head {
    background-color: #f5f5f5;
    border-bottom: 2px solid #e0e0e0;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#cdclient-calendrier-modal-event-title {
    font-size: 1.25rem;
    font-weight: 600;
    flex: 1;
    margin-right: 1rem;
    width: calc(100% - 150px) !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Body du modal avec scrolling */
.modal-card-calendier-single-event .modal-card-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(95vh - 140px);
}

/* Amélioration des box dans le modal */
.modal-card-calendier-single-event .box {
    height: auto !important; /* Pas de hauteur forcée */
    min-height: auto;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    background: #ffffff;
    border: 1px solid #e8e8e8;
    padding: 1.25rem;
}

.modal-card-calendier-single-event .box:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    border-color: #d0d0d0;
}

/* Différents types de boxes */
/* Box compacte pour les champs simples */
.modal-card-calendier-single-event .column:has(.field:only-child) .box,
.modal-card-calendier-single-event .column:has(.field:nth-last-child(2)) .box {
    padding: 1rem;
}

/* Box avec titre/header */
.modal-card-calendier-single-event .box-header {
    font-weight: 600;
    font-size: 0.95rem;
    color: #363636;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #f0f0f0;
}

/* Box pour les tables - sans padding interne */
.modal-card-calendier-single-event .box:has(.table) {
    padding: 0;
    overflow: hidden;
}

/* Header pour les boxes avec tables */
.modal-card-calendier-single-event .box:has(.table) .label {
    padding: 1rem 1rem 0.75rem;
    margin: 0;
    border-bottom: 1px solid #e8e8e8;
    background: #f8f9fa;
}

/* Tables dans le modal */
.modal-card-calendier-single-event .table {
    font-size: 0.875rem;
}

.modal-card-calendier-single-event .table.is-fullwidth {
    width: 100%;
}

/* Conteneur scrollable pour les tables d'utilisateurs */
.modal-card-calendier-single-event .table-container {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

/* Tables avec scroll */
.modal-card-calendier-single-event .control:has(.table) {
    max-height: 300px;
    overflow-y: auto;
    padding: 0;
}

.modal-card-calendier-single-event .control .table {
    margin-bottom: 0;
}

/* Regroupement visuel des champs connexes */
.modal-card-calendier-single-event .field-group {
    background: #f9fafb;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

/* Box spécifique pour les couleurs - plus compacte */
.modal-card-calendier-single-event .box:has(input[type="color"]) {
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
    align-items: center;
    padding: 1rem;
}

.modal-card-calendier-single-event .box:has(input[type="color"]) .field {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-card-calendier-single-event .box:has(input[type="color"]) .label {
    margin-bottom: 0;
    font-size: 0.875rem;
}

/* Header fixe pour les tables */
.modal-card-calendier-single-event .table thead {
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Amélioration des labels */
.modal-card-calendier-single-event .label {
    font-weight: 600;
    color: #363636;
    margin-bottom: 0.5rem;
    display: block;
}

.modal-card-calendier-single-event .label sub {
    font-weight: 400;
    color: #757575;
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
}

/* Champs de formulaire */
.modal-card-calendier-single-event .field {
    margin-bottom: 1rem;
}

.modal-card-calendier-single-event .field:last-child {
    margin-bottom: 0;
}

.modal-card-calendier-single-event .input,
.modal-card-calendier-single-event select {
    width: 100%;
    font-size: 0.95rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.modal-card-calendier-single-event .input:focus,
.modal-card-calendier-single-event select:focus {
    border-color: var(--cdcal-primary, #ff6b35);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
    outline: none;
}

/* Organisation visuelle par type de contenu */
/* Box info principale (titre, dates) */
.modal-card-calendier-single-event .box:has(input[name="title_event"]) {
    background: linear-gradient(135deg, #fff 0%, #fafafa 100%);
    border-left: 3px solid var(--cdcal-primary, #ff6b35);
}

/* Box récurrence - design plus compact */
.modal-card-calendier-single-event .box:has(select[name="recurrence_type"]) {
    background: #f8fbff;
    border: 1px solid #d1e3ff;
    padding: 1rem;
}

.modal-card-calendier-single-event .box:has(select[name="recurrence_type"]) .field {
    margin-bottom: 0.75rem;
}

.modal-card-calendier-single-event .box:has(select[name="recurrence_type"]) .field:last-child {
    margin-bottom: 0;
}

/* Select de récurrence avec style amélioré */
.modal-card-calendier-single-event select[name="recurrence_type"] {
    background-color: white;
    font-weight: 500;
}

/* Box de sélection des jours de récurrence */
.cdcalendarlememejourdelasemaine {
    margin-top: 0.75rem !important;
    padding: 0.75rem !important;
    background: #ffffff !important;
    border-radius: 6px !important;
    border: 1px solid #e3ecf6 !important;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

.cdcalendarlememejourdelasemaine .label {
    font-size: 0.875rem;
    color: #5a6c7d;
    margin-bottom: 0.5rem;
}

/* Style spécifique pour l'éditeur de contenu */
.modal-card-calendier-single-event .box:has(.wp-editor-wrap) {
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

/* Amélioration de la lisibilité des tables */
.modal-card-calendier-single-event .table tbody tr {
    transition: background-color 0.2s ease;
}

.modal-card-calendier-single-event .table tbody tr:hover {
    background-color: #f8f9fa;
}

/* Checkbox dans les tables plus visible */
.modal-card-calendier-single-event .table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Couleurs */
.modal-card-calendier-single-event input[type="color"] {
    width: 70px !important;
    height: 40px;
    cursor: pointer;
    border: 2px solid #dbdbdb;
    border-radius: 4px;
}

/* Footer du modal */
.modal-card-calendier-single-event .modal-card-foot {
    background: #f5f5f5;
    padding: 1rem 1.5rem;
    border-top: 2px solid #e0e0e0;
}

/* Boutons dans le header */
#cdclient-calendrier-delete-event {
    margin-right: 0.5rem;
}

/* Éditeur WordPress dans le modal */
.modal-card-calendier-single-event #wp-content_event-wrap {
    max-width: 100%;
}

.modal-card-calendier-single-event .wp-editor-area {
    min-height: 200px !important;
    height: 300px !important;
}

/* Select multiple de récurrence avec hauteur optimisée */
#cdcalendarlememejourdelasemaineid {
    width: 100%;
    min-height: 120px !important;
    max-height: 150px !important;
    padding: 0.5rem;
    border: 1px solid #d1e3ff;
    border-radius: 4px;
    background: white;
}

#cdcalendarlememejourdelasemaineid option {
    padding: 0.5rem;
    margin: 0.125rem 0;
}

#cdcalendarlememejourdelasemaineid option:checked {
    background: linear-gradient(0deg, #e8f2ff 0%, #d1e3ff 100%);
    color: #0066cc;
}

/* Amélioration visuelle des checkboxes dans les tables */
.modal-card-calendier-single-event .table input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--cdcal-primary, #ff6b35);
    margin: 0 auto;
    display: block;
}

/* Style unifié pour toutes les boxes de type info */
.modal-card-calendier-single-event .box .label + .control input[type="text"],
.modal-card-calendier-single-event .box .label + .control input[type="url"],
.modal-card-calendier-single-event .box .label + .control input[type="datetime-local"] {
    background: #fafbfc;
}

/* Amélioration des scrollbars */
.modal-card-calendier-single-event ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.modal-card-calendier-single-event ::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.modal-card-calendier-single-event ::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.modal-card-calendier-single-event ::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Animation d'ouverture */
.modal.is-active .modal-card-calendier-single-event {
    animation: modalSlideIn 0.3s ease-out;
}

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

/* Groupement visuel pour les champs de date/heure */
.modal-card-calendier-single-event .box:has(input[type="datetime-local"]) {
    background: linear-gradient(to bottom, #ffffff 0%, #fafbfc 100%);
    border: 1px solid #e1e8ed;
    position: relative;
    overflow: visible;
}

.modal-card-calendier-single-event .box:has(input[type="datetime-local"])::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--cdcal-secondary, #0066cc);
    border-radius: 4px 0 0 4px;
}

/* Amélioration des textarea */
.modal-card-calendier-single-event textarea {
    min-height: 80px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}

/* Box avec description - hauteur optimisée */
.modal-card-calendier-single-event .box:has(textarea) {
    padding: 1rem;
}

.modal-card-calendier-single-event .box:has(textarea) textarea {
    background: #fafbfc;
    border: 1px solid #e1e8ed;
    padding: 0.75rem;
}

/* Amélioration de l'éditeur WordPress */
.modal-card-calendier-single-event .wp-editor-container {
    border: 1px solid #e1e8ed;
    border-radius: 4px;
    overflow: hidden;
}

.modal-card-calendier-single-event .mce-content-body {
    padding: 1rem;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Boutons d'action avec icônes */
.modal-card-calendier-single-event .button i {
    margin-right: 0.25rem;
}

/* Style pour les messages d'information dans les boxes */
.modal-card-calendier-single-event .box .help {
    display: block;
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* Amélioration du contraste pour l'accessibilité */
.modal-card-calendier-single-event .label {
    color: #1f2937;
}

.modal-card-calendier-single-event .input:disabled,
.modal-card-calendier-single-event select:disabled {
    background-color: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

/* Responsive pour très petits écrans */
@media (max-width: 480px) {
    .modal-card-calendier-single-event .modal-card-body {
        padding: 1rem;
    }
    
    .modal-card-calendier-single-event .columns {
        margin: 0;
    }
    
    .modal-card-calendier-single-event .column {
        padding: 0.5rem 0;
    }
    
    #cdclient-calendrier-modal-event-title {
        font-size: 1.1rem;
    }
    
    .modal-card-calendier-single-event .box {
        padding: 1rem;
    }
    
    /* Tables responsives sur mobile */
    .modal-card-calendier-single-event .table-container,
    .modal-card-calendier-single-event .control:has(.table) {
        max-height: 200px;
    }
    
    /* Réduire l'espacement sur mobile */
    .modal-card-calendier-single-event .field {
        margin-bottom: 0.75rem;
    }
}