/**
 * Styles pour la visualisation et modification des annonces
 * 
 * @package OVR_Annonces
 * @since 2.0.6
 */

/* ==================== MODALE ==================== */

.ovr-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ovr-modal-overlay.ovr-modal-show,
.ovr-modal-overlay.open {
    opacity: 1;
    display: flex !important;
}

.ovr-modal-container {
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.ovr-modal-show .ovr-modal-container {
    transform: scale(1);
}

.ovr-modal-content {
    padding: 30px;
    overflow-y: auto;
    max-height: calc(90vh - 60px);
}

body.ovr-modal-open {
    overflow: hidden;
}

/* Loader modale */
.ovr-modal-loader {
    text-align: center;
    padding: 60px 20px;
}

.ovr-modal-loader .spinner {
    float: none;
    margin: 0 auto 20px;
}

.ovr-modal-loader p {
    font-size: 16px;
    color: #666;
}

/* ==================== VUE DÉTAIL ==================== */

.ovr-annonce-detail-view {
    font-size: 14px;
}

.ovr-detail-header {
    border-bottom: 2px solid #0073aa;
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.ovr-detail-header h2 {
    margin: 0 0 15px 0;
    font-size: 28px;
    color: #23282d;
}

.ovr-detail-meta {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.ovr-meta-item {
    padding: 5px 12px;
    background: #f0f0f1;
    border-radius: 4px;
    font-size: 13px;
}

.ovr-statut-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.ovr-detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

@media (min-width: 768px) {
    .ovr-detail-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.ovr-detail-section {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 6px;
    border-left: 4px solid #0073aa;
}

.ovr-detail-section h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: #0073aa;
}

.ovr-detail-item {
    margin-bottom: 15px;
}

.ovr-detail-item:last-child {
    margin-bottom: 0;
}

.ovr-detail-item strong {
    display: block;
    margin-bottom: 5px;
    color: #23282d;
    font-size: 13px;
}

.ovr-detail-item span,
.ovr-detail-item div {
    color: #50575e;
}

.ovr-description-content {
    padding: 15px;
    background: white;
    border-radius: 4px;
    border: 1px solid #ddd;
    line-height: 1.6;
}

.ovr-photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.ovr-photo-link {
    display: block;
    border-radius: 4px;
    overflow: hidden;
    transition: transform 0.2s ease;
}

.ovr-photo-link:hover {
    transform: scale(1.05);
}

.ovr-photo-thumbnail {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.ovr-detail-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ==================== FORMULAIRE D'ÉDITION ==================== */

.ovr-annonce-edit-form {
    font-size: 14px;
}

.ovr-form-header {
    border-bottom: 2px solid #0073aa;
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.ovr-form-header h2 {
    margin: 0 0 10px 0;
    font-size: 26px;
    color: #23282d;
}

.ovr-form-header .description {
    margin: 0;
    padding: 12px;
    background: #fff3cd;
    border-left: 4px solid #f0b849;
    border-radius: 4px;
    font-size: 13px;
    color: #856404;
}

/* Notice de revalidation */
.ovr-revalidation-notice {
    margin: 15px 0 0 0;
    padding: 20px;
    background: #fff3cd;
    border: 1px solid #f0b849;
    border-left: 4px solid #f0b849;
    border-radius: 4px;
}

.ovr-revalidation-notice h3 {
    margin: 0 0 10px 0;
    font-size: 15px;
    color: #856404;
    font-weight: 600;
}

.ovr-revalidation-notice > p {
    margin: 0 0 10px 0;
    color: #856404;
    font-size: 13px;
}

.ovr-revalidation-list {
    margin: 10px 0;
    padding-left: 20px;
    list-style: none;
}

.ovr-revalidation-list li {
    margin-bottom: 8px;
    color: #856404;
    font-size: 13px;
    position: relative;
    padding-left: 20px;
}

.ovr-revalidation-list li::before {
    content: "⚠️";
    position: absolute;
    left: 0;
    top: 0;
}

.ovr-revalidation-list li strong {
    color: #664d03;
}

.ovr-revalidation-info {
    margin: 15px 0 0 0;
    padding: 10px 12px;
    background: #d1ecf1;
    border-left: 3px solid #0c5460;
    border-radius: 3px;
    color: #0c5460;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ovr-revalidation-info .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Badges de revalidation sur les champs */
.ovr-revalidation-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 3px 8px;
    background: #fff3cd;
    border: 1px solid #f0b849;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    color: #856404;
    cursor: help;
    vertical-align: middle;
}

.ovr-revalidation-badge:hover {
    background: #ffeaa7;
}

/* Info prix */
.ovr-price-info {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 12px;
    font-style: italic;
}

.ovr-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .ovr-form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .ovr-form-field.ovr-full-width {
        grid-column: 1 / -1;
    }
}

.ovr-form-field {
    display: flex;
    flex-direction: column;
}

.ovr-form-field label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #23282d;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Tooltip d'aide */
.ovr-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #8c8f94;
    color: #fff !important;
    border-radius: 50%;
    font-size: 12px;
    cursor: help;
    font-weight: 700;
    flex-shrink: 0;
    text-decoration: none;
}

.ovr-tooltip:hover {
    background: #50575e;
    color: #fff !important;
}

.ovr-form-field input[type="text"],
.ovr-form-field input[type="number"],
.ovr-form-field select,
.ovr-form-field textarea {
    padding: 8px 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
    color: #23282d;
    background: #fff;
    transition: border-color 0.2s ease;
}

.ovr-form-field input[type="text"]:focus,
.ovr-form-field input[type="number"]:focus,
.ovr-form-field select:focus,
.ovr-form-field textarea:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 1px #0073aa;
}

.ovr-field-error {
    border-color: #dc3232 !important;
}

.ovr-field-error:focus {
    box-shadow: 0 0 0 1px #dc3232 !important;
}

/* Gestion des photos */
.ovr-photos-manager {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.ovr-photo-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ovr-photo-preview {
    position: relative;
    width: 100%;
    height: 200px;
    border: 2px dashed #c3c4c7;
    border-radius: 4px;
    overflow: hidden;
    background: #f6f7f7;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ovr-photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ovr-photo-placeholder {
    color: #8c8f94;
    font-size: 13px;
    text-align: center;
}

.ovr-remove-photo {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 30px;
    height: 30px;
    background: rgba(220, 50, 50, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.ovr-remove-photo:hover {
    background: rgba(220, 50, 50, 1);
}

.ovr-upload-photo {
    width: 100%;
}

/* ==================== BOUTONS WORDPRESS - STYLES COMPLETS (FRONTEND + BACKEND) ==================== */

/* 
 * Ces styles recréent les boutons WordPress admin pour le frontend
 * Car les classes .button et .button-primary n'ont pas de styles par défaut sur le frontend
 */

/* Styles de base pour tous les boutons */
.ovr-modal-content .button,
.ovr-modal-content button.button,
.ovr-detail-actions .button,
.ovr-detail-actions button,
.ovr-form-actions .button,
.ovr-form-actions button {
    /* Reset et base */
    display: inline-block;
    text-decoration: none;
    font-size: 13px;
    line-height: 2.15384615; /* 28px */
    min-height: 30px;
    margin: 0;
    padding: 0 10px;
    cursor: pointer;
    border-width: 1px;
    border-style: solid;
    border-radius: 3px;
    white-space: nowrap;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-weight: 400;
    vertical-align: top;
    
    /* Couleurs par défaut (bouton secondaire gris) */
    color: #2271b1;
    border-color: #2271b1;
    background: #f6f7f7;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1);
    
    /* Transition */
    transition: background 0.05s ease-in-out, border-color 0.05s ease-in-out, box-shadow 0.05s ease-in-out, color 0.05s ease-in-out;
}

/* Hover pour bouton secondaire */
.ovr-modal-content .button:hover,
.ovr-modal-content button.button:hover,
.ovr-detail-actions .button:hover,
.ovr-detail-actions button:hover:not(.button-primary),
.ovr-form-actions .button:hover,
.ovr-form-actions button:hover:not(.button-primary):not([type="submit"]) {
    background: #f0f0f1;
    border-color: #0a4d7a;
    color: #0a4d7a;
}

/* Focus */
.ovr-modal-content .button:focus,
.ovr-modal-content button.button:focus,
.ovr-detail-actions .button:focus,
.ovr-detail-actions button:focus,
.ovr-form-actions .button:focus,
.ovr-form-actions button:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
    outline: 2px solid transparent;
}

/* Active/pressed */
.ovr-modal-content .button:active,
.ovr-modal-content button.button:active,
.ovr-detail-actions .button:active,
.ovr-detail-actions button:active,
.ovr-form-actions .button:active,
.ovr-form-actions button:active {
    background: #f0f0f1;
    border-color: #8c8f94;
    box-shadow: none;
}

/* ========== BOUTON PRIMAIRE (BLEU) ========== */

.ovr-modal-content .button-primary,
.ovr-modal-content button.button-primary,
.ovr-detail-actions .button-primary,
.ovr-detail-actions button.button-primary,
.ovr-form-actions .button-primary,
.ovr-form-actions button.button-primary,
.ovr-form-actions button[type="submit"] {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff !important;
    text-shadow: none;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1);
}

/* Hover primaire */
.ovr-modal-content .button-primary:hover,
.ovr-modal-content button.button-primary:hover,
.ovr-detail-actions .button-primary:hover,
.ovr-detail-actions button.button-primary:hover,
.ovr-form-actions .button-primary:hover,
.ovr-form-actions button.button-primary:hover,
.ovr-form-actions button[type="submit"]:hover {
    background: #135e96;
    border-color: #135e96;
    color: #fff !important;
}

/* Focus primaire */
.ovr-modal-content .button-primary:focus,
.ovr-modal-content button.button-primary:focus,
.ovr-detail-actions .button-primary:focus,
.ovr-detail-actions button.button-primary:focus,
.ovr-form-actions .button-primary:focus,
.ovr-form-actions button.button-primary:focus,
.ovr-form-actions button[type="submit"]:focus {
    border-color: #0a4d7a;
    box-shadow: 0 0 0 1px #0a4d7a;
}

/* Active primaire */
.ovr-modal-content .button-primary:active,
.ovr-modal-content button.button-primary:active,
.ovr-detail-actions .button-primary:active,
.ovr-detail-actions button.button-primary:active,
.ovr-form-actions .button-primary:active,
.ovr-form-actions button.button-primary:active,
.ovr-form-actions button[type="submit"]:active {
    background: #135e96;
    border-color: #135e96;
    box-shadow: inset 0 1px 0 rgba(0,0,0,0.1);
    color: #fff !important;
}

/* ========== TAILLE LARGE ========== */

.ovr-modal-content .button-large,
.ovr-detail-actions .button-large,
.ovr-form-actions .button-large {
    height: 36px;
    line-height: 2.30769231; /* 30px */
    min-height: 36px;
    padding: 0 12px;
    font-size: 14px;
}

/* ========== BOUTONS UPLOAD PHOTO ========== */

.ovr-upload-photo {
    width: 100%;
    margin-top: 8px;
    text-align: center;
}

/* ==================== ACTIONS SPÉCIFIQUES ==================== */

/* Container des actions */
.ovr-detail-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Actions du formulaire */
.ovr-form-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.ovr-form-loader {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #666;
}

.ovr-form-loader .spinner {
    float: none;
    margin: 0;
}

/* ==================== NOTICES ==================== */

.ovr-modal-content .notice {
    margin: 0 0 20px 0;
    padding: 12px;
    border-left-width: 4px;
    border-left-style: solid;
}

.ovr-modal-content .notice-success {
    background: #d4edda;
    border-left-color: #28a745;
    color: #155724;
}

.ovr-modal-content .notice-error {
    background: #f8d7da;
    border-left-color: #dc3545;
    color: #721c24;
}

.ovr-modal-content .notice p {
    margin: 0;
}

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

@media (max-width: 767px) {
    .ovr-modal-container {
        width: 95%;
        max-height: 95vh;
    }
    
    .ovr-modal-content {
        padding: 20px;
    }
    
    .ovr-detail-header h2 {
        font-size: 22px;
    }
    
    .ovr-detail-meta {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .ovr-form-actions {
        flex-direction: column;
    }
    
    .ovr-form-actions button {
        width: 100%;
    }
    
    .ovr-photos-manager {
        grid-template-columns: 1fr;
    }
}

/* ==================== EDITOR TINYMCE ==================== */

.ovr-form-field .wp-editor-wrap {
    border: 1px solid #8c8f94;
    border-radius: 4px;
}

.ovr-form-field .wp-editor-wrap.ovr-field-error {
    border-color: #dc3232;
}

/* Textarea pour la description (sans TinyMCE) */
.ovr-form-field textarea.ovr-description-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    color: #23282d !important;
    background: #fff !important;
    resize: vertical;
}

.ovr-form-field textarea.ovr-description-textarea:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 1px #0073aa;
}

.ovr-form-field .description {
    margin-top: 5px;
    font-size: 13px;
    color: #646970;
    font-style: italic;
}

/* Forcer la visibilité du texte dans TinyMCE - Sélecteurs très spécifiques */
.ovr-modal-content .ovr-form-field .wp-editor-area,
.ovr-modal-content .ovr-form-field .mce-content-body,
.ovr-modal-content .ovr-form-field #wp-annonce_description-wrap .wp-editor-area,
.ovr-modal-content .ovr-form-field iframe,
.ovr-modal-content .ovr-form-field .mce-edit-area iframe,
body.mce-content-body {
    color: #23282d !important;
    background: #fff !important;
}

/* Forcer aussi pour le mode texte (textarea) */
.ovr-modal-content .ovr-form-field textarea#annonce_description {
    color: #23282d !important;
    background: #fff !important;
}

/* Pour le contenu à l'intérieur de l'iframe TinyMCE */
.ovr-modal-content .mce-content-body,
.ovr-modal-content .mce-content-body p,
.ovr-modal-content .mce-content-body div,
.ovr-modal-content .mce-content-body span {
    color: #23282d !important;
}

/* ==================== ANIMATIONS ==================== */

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

.ovr-modal-show .ovr-modal-container {
    animation: slideIn 0.3s ease;
}

/* ==================== PRINT ==================== */

@media print {
    .ovr-modal-overlay {
        position: static;
        background: none;
    }
    
    .ovr-modal-container {
        max-width: 100%;
        max-height: none;
        box-shadow: none;
    }
    
    .ovr-detail-actions,
    .ovr-form-actions {
        display: none;
    }
}

/* ==================== PAGE ACCÈS REFUSÉ ==================== */

.ovr-access-denied {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    padding: 40px 20px;
}

.ovr-access-box {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 40px;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ovr-access-box h3 {
    margin: 0 0 20px 0;
    font-size: 24px;
    color: #23282d;
    font-weight: 600;
}

.ovr-access-box p {
    margin: 0 0 30px 0;
    font-size: 16px;
    color: #50575e;
    line-height: 1.6;
}

.ovr-access-box .button {
    text-decoration: none;
    margin: 0;
}

/* ==================== ACCESSIBILITÉ ==================== */

.ovr-modal-overlay:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: -2px;
}

.ovr-form-field input:focus-visible,
.ovr-form-field select:focus-visible,
.ovr-form-field textarea:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

button:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* ==================== DARK MODE (pour WordPress 5.7+) ==================== */

.wp-admin.dark-mode .ovr-modal-container {
    background: #1e1e1e;
    color: #e0e0e0;
}

.wp-admin.dark-mode .ovr-detail-section {
    background: #2c2c2c;
}

.wp-admin.dark-mode .ovr-description-content {
    background: #2c2c2c;
    border-color: #3c3c3c;
    color: #e0e0e0;
}

.wp-admin.dark-mode .ovr-form-field input,
.wp-admin.dark-mode .ovr-form-field select,
.wp-admin.dark-mode .ovr-form-field textarea {
    background: #2c2c2c;
    border-color: #3c3c3c;
    color: #e0e0e0;
}

/* ========================================
   CORRECTIFS MODALE ANNONCE v3.0.3
   À ajouter à la fin de public/css/ovr-annonces-edit.css
   ======================================== */

/* Bouton fermer rond en haut à droite */
.ovr-close-detail {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #f0f0f0;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 1001;
    padding: 0;
}

.ovr-close-detail:hover {
    background: #e0e0e0;
    color: #333;
    transform: scale(1.1);
}

/* Photos en grille horizontale (3 colonnes) */
.ovr-detail-photos {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.ovr-photo-thumbnail {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.ovr-photo-link:hover .ovr-photo-thumbnail {
    transform: scale(1.05);
}

/* Bouton fermer en bas à droite */
.ovr-detail-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
    text-align: right; /* Alignement à droite */
}

.ovr-btn-secondary {
    background: #6c757d;
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.ovr-btn-secondary:hover {
    background: #5a6268;
}

/* Description avec sauts de ligne */
.ovr-detail-description {
    line-height: 1.8;
    color: #333;
    white-space: pre-wrap; /* Préserve les sauts de ligne */
}

/* Grille d'infos complémentaires */
.ovr-detail-grid-info {
    display: grid;
    gap: 12px;
}

.ovr-info-item {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
}

.ovr-info-item strong {
    color: #555;
    margin-right: 8px;
}

/* Responsive : 1 colonne sur mobile */
@media (max-width: 768px) {
    .ovr-detail-photos {
        grid-template-columns: 1fr;
    }
    
    .ovr-photo-thumbnail {
        height: 250px;
    }
}

/* Prix en gras et centré */
.ovr-detail-prix {
    font-size: 28px;
    font-weight: 700;
    color: #2c5282;
    text-align: center;
    margin: 15px 0 20px;
    padding: 15px;
    background: linear-gradient(135deg, #e8f4f8 0%, #d4e9f7 100%);
    border-radius: 8px;
    border-left: 4px solid #2c5282;
}