/* Additional styles for the website */

/* Editable content styles */
[data-editable="true"],
.editable {
    position: relative;
    transition: all 0.2s ease;
}

/* Only show editable indicators when in edit mode */
.edit-mode [data-editable="true"]:hover,
.edit-mode .editable:hover,
.editable.editable-visible:hover,
[data-editable="true"].hover,
.edit-mode .editable.hover {
    outline: 2px dashed #d4a79e;
    cursor: pointer;
    background-color: rgba(212, 167, 158, 0.05);
}

/* Hide hover effects when not in edit mode */
[data-editable="true"]:not(.edit-mode *):hover:not(.hover):not(.editing-active):not(.editing),
.editable:not(.edit-mode *):hover:not(.hover):not(.editing-active):not(.editing):not(.editable-visible) {
    outline: none !important;
    cursor: inherit !important;
    background-color: transparent !important;
}

[data-editable="true"].editing-active,
.editable.editing-active,
.editable.editing {
    outline: 2px solid #d4a79e;
    background-color: rgba(212, 167, 158, 0.05);
}

.editing-toolbar {
    animation: fadeIn 0.2s ease;
}

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

/* Dynamic Block Styles */
.service-block, .testimonial-block, .certification-block {
    position: relative;
}

.block-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
    padding: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    z-index: 10;
    transition: opacity 0.2s ease;
    opacity: 0;
    display: none; /* Hide by default */
}

/* Only show block controls in edit mode */
.edit-mode .block-controls {
    display: block;
}

.edit-mode .service-block:hover .block-controls,
.edit-mode .testimonial-block:hover .block-controls,
.edit-mode .certification-block:hover .block-controls {
    opacity: 1;
}

/* Testimonial Cards */
.testimonial-card {
    background-color: #fff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

/* Certificate Cards */
.certificate-card {
    transition: all 0.3s ease;
}

.certificate-card:hover .fa-certificate {
    transform: scale(1.1);
}

#add-block-modal {
    animation: fadeIn 0.3s ease;
}

/* Block hover effects - now handled with opacity in the block-controls class */

/* Add block button pulse effect */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(212, 167, 158, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(212, 167, 158, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(212, 167, 158, 0);
    }
}

#add-service-block,
#add-certification-block,
#add-testimonial-block {
    animation: pulse 2s infinite;
}

/* Prevent editable behavior on non-editable buttons */
.non-editable-button {
    outline: none !important;
}

.non-editable-button:hover {
    outline: none !important;
    cursor: pointer !important;
    background-color: inherit !important;
}

/* Ensure buttons don't show editable hover effects when not in edit mode */
button:not(.edit-mode button):hover {
    outline: none !important;
    background-color: inherit !important;
}

/* Image container and edit overlay styles */
.image-container {
    position: relative;
    display: inline-block;
}

/* Ensure image containers don't break layouts */
.image-container {
    position: relative;
    overflow: hidden;
    pointer-events: none; /* Disable pointer events by default */
}

/* Only enable pointer events in edit mode */
.edit-mode .image-container {
    pointer-events: auto;
}

/* Modify links and buttons in edit mode */
.edit-mode a,
.edit-mode button:not(.editing-toolbar button):not(.block-controls button):not(.change-image-btn):not(#edit-mode-toggle):not(#logout-button) {
    /* Don't disable pointer events completely, as we need to be able to click them for editing */
    pointer-events: auto !important;
    /* Use pointer cursor to indicate they're clickable */
    cursor: pointer !important;
}

/* Add visual indicator for links in edit mode */
.edit-mode a:hover {
    background-color: rgba(212, 167, 158, 0.1) !important;
    outline: 1px dashed #d4a79e !important;
}

/* Add visual indicator for buttons in edit mode */
.edit-mode button:not(.editing-toolbar button):not(.block-controls button):not(.change-image-btn):not(#edit-mode-toggle):not(#logout-button):hover {
    background-color: rgba(212, 167, 158, 0.1) !important;
    outline: 1px dashed #d4a79e !important;
}

/* Ensure editable elements have proper styling */
.edit-mode [data-editable="true"],
.edit-mode .editable,
.edit-mode [data-editable-key] {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Only create the overlay in edit mode */
.edit-mode .image-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    z-index: 1;
}

/* Only show hover effect in edit mode */
.edit-mode .image-container:hover::before {
    background: rgba(0, 0, 0, 0.2);
}

.image-container img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Image edit overlay styles */
.image-edit-overlay {
    border-radius: inherit;
    overflow: hidden;
    z-index: 5;
}

/* For circular images */
.rounded-full + .image-edit-overlay {
    border-radius: 9999px;
}

/* For rounded images */
.rounded-lg + .image-edit-overlay {
    border-radius: 0.5rem;
}

.rounded + .image-edit-overlay {
    border-radius: 0.25rem;
}

/* Legacy button styles (keeping for backward compatibility) */
.change-image-btn {
    z-index: 10;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: all 0.3s ease;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden; /* Hide by default */
}

/* Only show in edit mode */
.edit-mode .change-image-btn {
    visibility: visible;
}

/* Only show image edit buttons in edit mode */
.edit-mode .image-container:hover .change-image-btn {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

/* Image upload modal styles */
.image-upload-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.image-upload-content {
    background-color: white;
    padding: 2rem;
    border-radius: 0.5rem;
    max-width: 500px;
    width: 90%;
}

.image-preview {
    width: 100%;
    height: 200px;
    border: 2px dashed #ddd;
    border-radius: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
    overflow: hidden;
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Responsive improvements */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 2rem;
    }
}

/* Print styles */
@media print {
    nav, footer, .floating-leaf, .btn-primary, form {
        display: none !important;
    }

    body {
        background-color: white;
        color: black;
    }

    section {
        page-break-inside: avoid;
    }
}

/* Admin controls */
#admin-controls {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 0.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
    z-index: 100;
    top: 95px;
}

/* Hide block manager controls by default */
.block-manager-controls {
    display: none;
}

/* Show block manager controls in edit mode */
.edit-mode .block-manager-controls {
    display: block;
}

/* Image editing in edit mode */
.image-container .change-image-btn {
    opacity: 0;
}

/* Accessibility improvements */
:focus {
    outline: 3px solid #d4a79e;
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Mobile menu transitions */
#mobile-menu {
    max-height: 0;
    transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out;
    opacity: 0;
    overflow: hidden;
}

#mobile-menu.hidden {
    max-height: 0;
    opacity: 0;
}

#mobile-menu:not(.hidden) {
    max-height: 280px;
    opacity: 1;
}

/* Mobile menu item styling */
#mobile-menu a {
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

#mobile-menu a:hover, #mobile-menu a:focus {
    border-left: 3px solid #d4a79e;
    background-color: rgba(212, 167, 158, 0.1);
}

/* Hamburger icon transition */
#mobile-menu-button {
    transition: transform 0.3s ease;
}

#mobile-menu-button:hover {
    transform: rotate(90deg);
}

/* Ensure links, buttons and other clickable elements have pointer cursor in non-edit mode */
a, button, [role="button"], input[type="button"], input[type="submit"], input[type="reset"], 
.clickable, [onclick], [data-clickable="true"] {
    cursor: pointer !important;
}
