/*!
 * Gutenberg Override Styles for Ludicity Front-End Editor
 * All selectors are prefixed with .ludicity to prevent theme override
 * This ensures Gutenberg styles are applied correctly in the front-end editor
 */

/* ══════════════════════════════════════════════════════════════════════════
   BLOCK DROPDOWN MENU - WHITELIST STRUCTUREL (global, hors .ludicity scope)
   Critère : les items autorisés (Copier, Couper, Coller, Dupliquer,
   Ajouter avant/après, Supprimer) ont TOUS un raccourci clavier affiché
   (.components-menu-item__shortcut). Les items interdits (Copier les styles,
   Coller les styles, Verrouiller, Renommer) n'en ont pas.
   → On cache les groupes entiers sans raccourci clavier.
   Indépendant de la langue et de la version WP.
   ══════════════════════════════════════════════════════════════════════════ */

.components-dropdown-menu__menu .components-menu-group:not(:has(.components-menu-item__shortcut)):not(.block-editor-block-alignment-control__menu-group) {
    display: none !important;
}

/* ══════════════════════════════════════════════════════════════════════════
   Neutraliser la règle `body { min-width:240px; overflow-x:hidden }` de
   wp-admin/css/common.css (@media max-width:782px) qui casse le layout
   mobile du front-end editor. On ne dequeue pas `common` en entier car il
   fournit des styles partagés par l'inserter Gutenberg.
   ══════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 782px) {
    body {
        min-width: 0;
        overflow-x: visible;
    }
}

/* ══════════════════════════════════════════════════════════════════════════
   FORCE SYSTEM FONT - HIGHEST PRIORITY
   ══════════════════════════════════════════════════════════════════════════ */

div#ludicity-frontend-editor,
div#ludicity-frontend-editor-dialog,
div#ludicity-frontend-editor *,
div#ludicity-frontend-editor-dialog * {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}


/* Block Editor Paragraphs */
div#ludicity-frontend-editor [data-type="core/paragraph"] p,
div#ludicity-frontend-editor-dialog [data-type="core/paragraph"] p,
div#ludicity-frontend-editor .block-editor-rich-text__editable p,
div#ludicity-frontend-editor-dialog .block-editor-rich-text__editable p {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 16px;
    line-height: 1.8;
    color: #1e1e1e;
}

/* Contenteditable elements */
div#ludicity-frontend-editor [contenteditable="true"],
div#ludicity-frontend-editor-dialog [contenteditable="true"] {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 16px;
    line-height: 1.8;
    color: #1e1e1e;
}

/* ══════════════════════════════════════════════════════════════════════════
   COMPONENTS - BUTTONS
   ══════════════════════════════════════════════════════════════════════════ */

div#ludicity-frontend-editor .components-button,
div#ludicity-frontend-editor-dialog .components-button {
    display: inline-flex;
    text-decoration: none;
    font-size: 13px;
    margin: 0;
    border: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background: none;
    transition: box-shadow 0.1s linear;
    height: 36px;
    align-items: center;
    box-sizing: border-box;
    padding: 6px 12px;
    border-radius: 2px;
    color: #1e1e1e;
}

div#ludicity-frontend-editor .block-editor-block-types-list__item,
div#ludicity-frontend-editor-dialog .block-editor-block-types-list__item {
    height: auto;
    min-height: 0;
    padding: 8px 4px;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow: visible;
}

div#ludicity-frontend-editor :not(#gutenberg-editor) .components-button.is-primary,
div#ludicity-frontend-editor-dialog :not(#gutenberg-editor) .components-button.is-primary {
    background-color: #2271b1 !important;
    color: #fff;
    text-decoration: none;
    text-shadow: none;
}

div#ludicity-frontend-editor .components-button.is-primary:hover,
div#ludicity-frontend-editor-dialog .components-button.is-primary:hover {
    background-color: #135e96;
}

div#ludicity-frontend-editor .components-button.is-secondary,
div#ludicity-frontend-editor-dialog .components-button.is-secondary {
    outline: 1px solid transparent;
    color: #2271b1;
    box-shadow: inset 0 0 0 1px #2271b1;
}

div#ludicity-frontend-editor .components-button.is-tertiary,
div#ludicity-frontend-editor-dialog .components-button.is-tertiary {
    color: #1e1e1e;
    padding: 6px 8px;
}

div#ludicity-frontend-editor .components-button.is-tertiary:hover,
div#ludicity-frontend-editor-dialog .components-button.is-tertiary:hover {
    color: #2271b1;
}

div#ludicity-frontend-editor .components-button.has-icon,
div#ludicity-frontend-editor-dialog .components-button.has-icon {
    padding: 6px;
    min-width: 36px;
}

div#ludicity-frontend-editor .block-editor-block-contextual-toolbar,
div#ludicity-frontend-editor-dialog .block-editor-block-contextual-toolbar {
    padding: 1px;
}

div#ludicity-frontend-editor .block-editor-block-toolbar .components-button:not(.block-editor-block-mover-button),
div#ludicity-frontend-editor-dialog .block-editor-block-toolbar .components-button:not(.block-editor-block-mover-button),
div#ludicity-frontend-editor .block-editor-block-contextual-toolbar .components-button:not(.block-editor-block-mover-button),
div#ludicity-frontend-editor-dialog .block-editor-block-contextual-toolbar .components-button:not(.block-editor-block-mover-button) {
    height: 100%;
    align-self: stretch;
}

div#ludicity-frontend-editor .block-editor-block-mover-button,
div#ludicity-frontend-editor-dialog .block-editor-block-mover-button {
    padding: 0;
    height: 16px;
    width: 16px;
    min-height: 16px;
    min-width: 16px;
    border-radius: 2px;
}

div#ludicity-frontend-editor .block-editor-block-mover__move-button-container,
div#ludicity-frontend-editor-dialog .block-editor-block-mover__move-button-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ══════════════════════════════════════════════════════════════════════════
   COMPONENTS - PANELS & CONTROLS
   ══════════════════════════════════════════════════════════════════════════ */

div#ludicity-frontend-editor .components-panel,
div#ludicity-frontend-editor-dialog .components-panel {
    background: #fff;
    border: 1px solid #dcdcde;
}

div#ludicity-frontend-editor .components-panel__header,
div#ludicity-frontend-editor-dialog .components-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    height: 50px;
    border-bottom: 1px solid #dcdcde;
}

div#ludicity-frontend-editor .components-panel__body,
div#ludicity-frontend-editor-dialog .components-panel__body {
    border-top: 1px solid #dcdcde;
}

div#ludicity-frontend-editor .components-panel__body-title,
div#ludicity-frontend-editor-dialog .components-panel__body-title {
    display: block;
    padding: 0;
    margin: 0;
}

div#ludicity-frontend-editor .components-panel__body-toggle,
div#ludicity-frontend-editor-dialog .components-panel__body-toggle {
    padding: 15px;
    outline: none;
    width: 100%;
    font-size: 13px;
    color: #1e1e1e;
    border: none;
    box-shadow: none;
    transition: background 0.1s ease-in-out;
    height: auto;
    background: transparent;
    text-align: left;
}

div#ludicity-frontend-editor .components-panel__body-toggle:hover,
div#ludicity-frontend-editor-dialog .components-panel__body-toggle:hover {
    background: #f0f0f1;
}

/* ══════════════════════════════════════════════════════════════════════════
   COMPONENTS - TEXT CONTROLS
   ══════════════════════════════════════════════════════════════════════════ */

div#ludicity-frontend-editor .components-text-control__input,
div#ludicity-frontend-editor-dialog .components-text-control__input,
div#ludicity-frontend-editor .components-textarea-control__input,
div#ludicity-frontend-editor-dialog .components-textarea-control__input {
    width: 100%;
    padding: 6px 8px;
    box-shadow: 0 0 0 transparent;
    transition: box-shadow 0.1s linear;
    border-radius: 2px;
    border: 1px solid #757575;
    background-color: #fff;
    color: #1e1e1e;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 13px;
}

div#ludicity-frontend-editor .components-text-control__input:focus,
div#ludicity-frontend-editor-dialog .components-text-control__input:focus,
div#ludicity-frontend-editor .components-textarea-control__input:focus,
div#ludicity-frontend-editor-dialog .components-textarea-control__input:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
    outline: 2px solid transparent;
}

/* ══════════════════════════════════════════════════════════════════════════
   COMPONENTS - SELECT CONTROLS
   ══════════════════════════════════════════════════════════════════════════ */

div#ludicity-frontend-editor select,
div#ludicity-frontend-editor-dialog select,
div#ludicity-frontend-editor input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
div#ludicity-frontend-editor-dialog input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]) {
    height: auto;
    min-height: 0;
    padding: 4px 8px;
    line-height: 1.5;
    font-size: 14px;
    box-sizing: border-box;
}

div#ludicity-frontend-editor select,
div#ludicity-frontend-editor-dialog select,
div#ludicity-frontend-editor .components-select-control__input,
div#ludicity-frontend-editor-dialog .components-select-control__input {
    -webkit-appearance: auto;
    appearance: auto;
}

div#ludicity-frontend-editor .components-select-control__input,
div#ludicity-frontend-editor-dialog .components-select-control__input {
    padding: 6px 8px;
    min-height: 36px;
    box-shadow: 0 0 0 transparent;
    transition: box-shadow 0.1s linear;
    border-radius: 2px;
    border: 1px solid #757575;
    background-color: #fff;
    color: #1e1e1e;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 13px;
}

div#ludicity-frontend-editor .components-select-control__input:focus,
div#ludicity-frontend-editor-dialog .components-select-control__input:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
    outline: 2px solid transparent;
}

/* ══════════════════════════════════════════════════════════════════════════
   COMPONENTS - TOGGLE CONTROL
   ══════════════════════════════════════════════════════════════════════════ */

div#ludicity-frontend-editor .components-form-toggle,
div#ludicity-frontend-editor-dialog .components-form-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 18px;
    border-radius: 9px;
    background-color: #fff;
    border: 1px solid #1e1e1e;
    transition: background 0.2s ease;
}

div#ludicity-frontend-editor .components-form-toggle.is-checked,
div#ludicity-frontend-editor-dialog .components-form-toggle.is-checked {
    background-color: #2271b1;
    border-color: #2271b1;
}

div#ludicity-frontend-editor .components-form-toggle__track,
div#ludicity-frontend-editor-dialog .components-form-toggle__track {
    height: 100%;
    border-radius: 9px;
}

div#ludicity-frontend-editor .components-form-toggle__thumb,
div#ludicity-frontend-editor-dialog .components-form-toggle__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #1e1e1e;
    transition: transform 0.1s ease;
}

div#ludicity-frontend-editor .components-form-toggle.is-checked .components-form-toggle__thumb,
div#ludicity-frontend-editor-dialog .components-form-toggle.is-checked .components-form-toggle__thumb {
    background-color: #fff;
    transform: translateX(18px);
}

/* ══════════════════════════════════════════════════════════════════════════
   BLOCK EDITOR - RICH TEXT
   ══════════════════════════════════════════════════════════════════════════ */

div#ludicity-frontend-editor .block-editor-rich-text__editable,
div#ludicity-frontend-editor-dialog .block-editor-rich-text__editable {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 16px;
    line-height: 1.8;
    color: #1e1e1e;
}

div#ludicity-frontend-editor .block-editor-rich-text__editable:focus,
div#ludicity-frontend-editor-dialog .block-editor-rich-text__editable:focus {
    outline: none;
}

div#ludicity-frontend-editor .block-editor-rich-text__editable[data-is-placeholder-visible="true"] + .block-editor-rich-text__editable,
div#ludicity-frontend-editor-dialog .block-editor-rich-text__editable[data-is-placeholder-visible="true"] + .block-editor-rich-text__editable {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
}

/* ══════════════════════════════════════════════════════════════════════════
   BLOCK EDITOR - BLOCK LIST
   ══════════════════════════════════════════════════════════════════════════ */

div#ludicity-frontend-editor .block-editor-block-list__layout,
div#ludicity-frontend-editor-dialog .block-editor-block-list__layout {
    position: relative;
}

div#ludicity-frontend-editor .block-editor-block-list__block,
div#ludicity-frontend-editor-dialog .block-editor-block-list__block {
    position: relative;
    margin-top: 28px;
    margin-bottom: 28px;
}

div#ludicity-frontend-editor .block-editor-block-list__block:first-child,
div#ludicity-frontend-editor-dialog .block-editor-block-list__block:first-child {
    margin-top: 0;
}

div#ludicity-frontend-editor .block-editor-block-list__block:last-child,
div#ludicity-frontend-editor-dialog .block-editor-block-list__block:last-child {
    margin-bottom: 0;
}

div#ludicity-frontend-editor [data-type="core/list"] .block-editor-block-list__block,
div#ludicity-frontend-editor-dialog [data-type="core/list"] .block-editor-block-list__block {
    margin-top: 0;
    margin-bottom: 0;
}

/* ══════════════════════════════════════════════════════════════════════════
   BLOCK EDITOR - INSERTER
   ══════════════════════════════════════════════════════════════════════════ */

div#ludicity-frontend-editor .block-editor-inserter__menu,
div#ludicity-frontend-editor-dialog .block-editor-inserter__menu {
    background: #fff;
    border: 1px solid #dcdcde;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

div#ludicity-frontend-editor .block-editor-inserter__search,
div#ludicity-frontend-editor-dialog .block-editor-inserter__search {
    padding: 16px;
    border-bottom: 1px solid #dcdcde;
}

div#ludicity-frontend-editor .block-editor-inserter__search input,
div#ludicity-frontend-editor-dialog .block-editor-inserter__search input {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 13px;
    padding: 8px 12px;
    border: 1px solid #757575;
    border-radius: 2px;
    width: 100%;
}

/* ══════════════════════════════════════════════════════════════════════════
   DASHICONS FONT
   ══════════════════════════════════════════════════════════════════════════ */

@font-face {
    font-family: dashicons;
    src: url("../../../fonts/dashicons.woff2") format("woff2"),
         url("../../../fonts/dashicons.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
}

div#ludicity-frontend-editor .dashicons,
div#ludicity-frontend-editor-dialog .dashicons,
div#ludicity-frontend-editor .dashicons-before:before,
div#ludicity-frontend-editor-dialog .dashicons-before:before {
    font-family: dashicons;
    display: inline-block;
    line-height: 1;
    font-weight: 400;
    font-style: normal;
    speak: never;
    text-decoration: inherit;
    text-transform: none;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    width: 20px;
    height: 20px;
    font-size: 20px;
    vertical-align: top;
    text-align: center;
}

/* ══════════════════════════════════════════════════════════════════════════
   WORDPRESS CORE RESETS
   ══════════════════════════════════════════════════════════════════════════ */

div#ludicity-frontend-editor .wp-block,
div#ludicity-frontend-editor-dialog .wp-block {
    max-width: 100%;
}

div#ludicity-frontend-editor .wp-block[data-align="wide"],
div#ludicity-frontend-editor-dialog .wp-block[data-align="wide"] {
    max-width: 100%;
}

div#ludicity-frontend-editor .wp-block[data-align="full"],
div#ludicity-frontend-editor-dialog .wp-block[data-align="full"] {
    max-width: none;
}

/* ══════════════════════════════════════════════════════════════════════════
   INTERFACE SKELETON
   ══════════════════════════════════════════════════════════════════════════ */

div#ludicity-frontend-editor .interface-interface-skeleton,
div#ludicity-frontend-editor-dialog .interface-interface-skeleton {
    display: flex;
    flex-direction: column;
    height: 100%;
}

div#ludicity-frontend-editor .interface-interface-skeleton__header,
div#ludicity-frontend-editor-dialog .interface-interface-skeleton__header {
    flex-shrink: 0;
}

div#ludicity-frontend-editor .interface-interface-skeleton__body,
div#ludicity-frontend-editor-dialog .interface-interface-skeleton__body {
    flex-grow: 1;
    display: flex;
    overflow: hidden;
}

div#ludicity-frontend-editor .interface-interface-skeleton__content,
div#ludicity-frontend-editor-dialog .interface-interface-skeleton__content {
    flex-grow: 1;
    overflow: auto;
}

div#ludicity-frontend-editor .interface-interface-skeleton__sidebar,
div#ludicity-frontend-editor-dialog .interface-interface-skeleton__sidebar {
    flex-shrink: 0;
    overflow: auto;
}

/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE ADJUSTMENTS
   ══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 782px) {
    div#ludicity-frontend-editor .components-button,
    div#ludicity-frontend-editor-dialog .components-button {
        height: 36px;
        padding: 6px 12px;
    }
    
    div#ludicity-frontend-editor .components-panel__header,
    div#ludicity-frontend-editor-dialog .components-panel__header {
        height: 50px;
    }
}
