/**
 * Styles spécifiques au champ ImageField
 *
 * Les styles de base sont définis dans pib-acf-gutenberg.css (styles partagés)
 * Ce fichier contient uniquement les ajustements spécifiques au champ ImageField.
 */

.image-field-wrapper {
    /* Hérite des styles de .pib-acf-field-wrapper */
}

.image-field-image-section,
.image-field-options-section,
.image-field-developer-section {
    /* Hérite des styles de .pib-acf-section */
}

.image-field-image-section .acf-field {
    margin-bottom: 0;
}

.image-field-options-section .acf-field {
    margin-bottom: 1rem;
}

.image-field-options-section .acf-field:last-child {
    margin-bottom: 0;
}

.image-field-developer-section {
    border-top: 1px solid #ddd;
    padding-top: 1rem;
    margin-top: 1rem;
}

.image-field-developer-section .acf-field {
    margin-bottom: 0;
}

.image-field-format-info {
    /* Hérite des styles de .pib-acf-info-section */
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #ddd;
}

/* ==========================================================================
   Focus Section
   ========================================================================== */

.image-field-focus-section {
    display: none;
}

/* ==========================================================================
   Preview Focus avec point bleu (scopé à ImageField)
   ========================================================================== */

.image-field-wrapper .acf-image-uploader.has-focus-button .show-if-value.image-wrap {
    position: relative;
}

.image-field-wrapper .image-field-focus-preview-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

.image-field-wrapper .image-field-focus-dot-preview {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #2271b1;
    border: 2px solid #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    z-index: 5;
    transition: left 0.15s ease, top 0.15s ease;
}

/* ==========================================================================
   Bouton Focus (scopé à ImageField uniquement)
   ========================================================================== */

.image-field-wrapper .image-field-focus-button {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    color: #1e1e1e;
    pointer-events: auto;
}

.image-field-wrapper .image-field-focus-button:hover {
    background: #fff;
    color: #2271b1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.image-field-wrapper .image-field-focus-button:focus {
    outline: 2px solid #2271b1;
    outline-offset: 1px;
}

.image-field-wrapper .image-field-focus-button svg {
    width: 18px;
    height: 18px;
}

/* ==========================================================================
   Modale Focus
   ========================================================================== */

.image-field-focus-modal {
    position: fixed;
    inset: 0;
    z-index: 100100;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
}

.image-field-focus-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
}

.image-field-focus-modal-content {
    position: relative;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.image-field-focus-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #dcdcde;
}

.image-field-focus-modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1d2327;
}

.image-field-focus-modal-close {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: #646970;
    transition: all 0.15s ease;
}

.image-field-focus-modal-close:hover {
    background: #f0f0f1;
    color: #1d2327;
}

.image-field-focus-modal-close:focus {
    outline: 2px solid #2271b1;
    outline-offset: -2px;
}

.image-field-focus-modal-close .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

.image-field-focus-modal-body {
    padding: 20px;
    overflow: auto;
}

.image-field-focus-description {
    margin: 12px 0 0;
    font-size: 13px;
    color: #646970;
    text-align: center;
}

.image-field-focus-actions {
    margin-top: 16px;
    text-align: center;
}

.image-field-focus-reset:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================================================
   Focus Wrapper (image avec points)
   ========================================================================== */

.image-field-focus-wrapper {
    position: relative;
    width: fit-content;
    max-width: 800px;
    max-height: 60vh;
    margin: 0 auto;
    border-radius: 4px;
    overflow: hidden;
    cursor: crosshair;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: #f0f0f1;
}

.image-field-focus-wrapper img {
    display: block;
    max-width: 100%;
    max-height: 60vh;
    width: auto;
    height: auto;
    user-select: none;
    pointer-events: none;
}

/* Point de focus local (override) */
.image-field-focus-dot {
    position: absolute;
    width: 20px;
    height: 20px;
    background: #2271b1;
    border: 3px solid #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    z-index: 10;
    transition: left 0.1s ease, top 0.1s ease;
}

/* Point de focus global (référence) */
.image-field-focus-dot-global {
    position: absolute;
    width: 16px;
    height: 16px;
    background: transparent;
    border: 2px dashed rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 5;
    opacity: 0.7;
}

.image-field-focus-dot-global::after {
    content: '';
    position: absolute;
    inset: 2px;
    border: 2px dashed rgba(0, 0, 0, 0.5);
    border-radius: 50%;
}

/* Grille de composition (rule of thirds) */
.image-field-focus-wrapper::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to right, rgba(255, 255, 255, 0.3) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.3) 1px, transparent 1px);
    background-size: 33.33% 33.33%;
    pointer-events: none;
}
