/* ==================== ADMIN EDIT MODE ==================== */

/* Floating toggle button - bottom left to avoid chat widget */
.admin-edit-toggle {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    z-index: 9500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: #0a1628;
    color: #fffefb;
    border: 2px solid #c9a961;
    border-radius: 30px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(10, 22, 40, 0.3);
}

.admin-edit-toggle:hover {
    background: #c9a961;
    color: #0a1628;
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(201, 169, 97, 0.4);
}

.admin-edit-toggle.active {
    background: #c9a961;
    color: #0a1628;
}

.admin-edit-toggle svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Image edit overlays */
body.admin-edit-active img:not(.no-edit):not([src^="data:"]):not([src*="emailjs"]):not([src*="cdn"]) {
    cursor: pointer !important;
    transition: outline 0.2s, box-shadow 0.2s;
}

body.admin-edit-active img:not(.no-edit):not([src^="data:"]):not([src*="emailjs"]):not([src*="cdn"]):hover {
    outline: 3px solid #c9a961 !important;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(201, 169, 97, 0.2) !important;
}

.admin-img-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(10, 22, 40, 0.85);
    color: #c9a961;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 500;
    font-family: 'Montserrat', sans-serif;
    letter-spacing: 0.05em;
    pointer-events: none;
    z-index: 5;
    display: none;
}

body.admin-edit-active .admin-img-wrapper:hover .admin-img-badge {
    display: block;
}

.admin-img-wrapper {
    position: relative;
    display: inline-block;
}

/* ==================== EDIT PANEL ==================== */
.admin-edit-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    height: 100vh;
    background: #fffefb;
    z-index: 9999;
    box-shadow: -4px 0 30px rgba(10, 22, 40, 0.15);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    font-family: 'Montserrat', sans-serif;
}

.admin-edit-panel.open {
    right: 0;
}

.admin-edit-panel-header {
    background: #0a1628;
    color: #fffefb;
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 2;
}

.admin-edit-panel-header h3 {
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
}

.admin-edit-panel-close {
    background: none;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: #fffefb;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.admin-edit-panel-close:hover {
    background: #c9a961;
    border-color: #c9a961;
    color: #0a1628;
}

.admin-edit-panel-body {
    padding: 1.5rem;
}

.admin-edit-panel-preview {
    width: 100%;
    height: 180px;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1.25rem;
    background: #f5f1eb;
    border: 1px solid rgba(0,0,0,0.06);
}

.admin-edit-panel-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.admin-edit-panel-src {
    font-size: 0.7rem;
    color: #6b6b6b;
    word-break: break-all;
    margin-bottom: 1.25rem;
    padding: 0.5rem 0.75rem;
    background: #f5f5f5;
    border-radius: 6px;
    font-family: monospace;
}

.admin-edit-section {
    margin-bottom: 1.5rem;
}

.admin-edit-section h4 {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #0a1628;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

/* Position grid */
.admin-position-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    width: 150px;
    margin: 0 auto;
}

.admin-position-cell {
    width: 46px;
    height: 36px;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    background: #f5f5f5;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #999;
}

.admin-position-cell:hover {
    border-color: #c9a961;
    background: rgba(201, 169, 97, 0.05);
}

.admin-position-cell.active {
    border-color: #c9a961;
    background: #c9a961;
    color: #0a1628;
    font-weight: 600;
}

/* Fit options */
.admin-fit-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.admin-fit-option {
    padding: 6px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    background: white;
    font-size: 0.75rem;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Montserrat', sans-serif;
}

.admin-fit-option:hover {
    border-color: #c9a961;
}

.admin-fit-option.active {
    border-color: #c9a961;
    background: #c9a961;
    color: #0a1628;
}

/* Height slider */
.admin-height-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-height-control input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    border-radius: 3px;
    background: #e0e0e0;
    outline: none;
}

.admin-height-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #c9a961;
    cursor: pointer;
}

.admin-height-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: #0a1628;
    min-width: 50px;
    text-align: right;
}

.admin-height-auto {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 0.8rem;
    color: #666;
}

/* Replace upload */
.admin-replace-zone {
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    padding: 1.25rem;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}

.admin-replace-zone:hover {
    border-color: #c9a961;
    background: rgba(201, 169, 97, 0.03);
}

.admin-replace-zone input[type="file"] {
    display: none;
}

.admin-replace-zone p {
    font-size: 0.8rem;
    color: #666;
    margin: 0;
}

.admin-replace-zone .upload-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: #c9a961;
}

/* Panel footer buttons */
.admin-edit-panel-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(0,0,0,0.06);
    display: flex;
    gap: 8px;
    position: sticky;
    bottom: 0;
    background: #fffefb;
}

.admin-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 6px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s;
}

.admin-btn-save {
    background: #c9a961;
    color: #0a1628;
}

.admin-btn-save:hover {
    background: #b89a52;
}

.admin-btn-cancel {
    background: #f5f5f5;
    color: #666;
}

.admin-btn-cancel:hover {
    background: #e0e0e0;
}

.admin-btn-reset {
    background: none;
    color: #c62828;
    font-size: 0.75rem;
    padding: 0.5rem;
}

.admin-btn-reset:hover {
    background: #ffebee;
}

.admin-btn-revert {
    background: #fff3e0;
    color: #e65100;
}

.admin-btn-revert:hover {
    background: #ffe0b2;
}

/* Scrim behind panel */
.admin-edit-scrim {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 22, 40, 0.3);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.admin-edit-scrim.open {
    opacity: 1;
    visibility: visible;
}

/* Status message */
.admin-status-msg {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

.admin-status-msg.success {
    background: #e8f5e9;
    color: #2e7d32;
}

.admin-status-msg.error {
    background: #ffebee;
    color: #c62828;
}

/* ==================== SECTION BACKGROUND HIGHLIGHTS ==================== */
body.admin-edit-active [data-bg-section] {
    cursor: pointer !important;
    transition: outline 0.2s, box-shadow 0.2s;
    position: relative;
}

body.admin-edit-active [data-bg-section]:hover {
    outline: 3px dashed #c9a961 !important;
    outline-offset: -3px;
    box-shadow: inset 0 0 0 3px rgba(201, 169, 97, 0.15) !important;
}

body.admin-edit-active [data-bg-section]::after {
    content: 'Click to edit background';
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(10, 22, 40, 0.85);
    color: #c9a961;
    padding: 4px 12px;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 500;
    font-family: 'Montserrat', sans-serif;
    letter-spacing: 0.03em;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

body.admin-edit-active [data-bg-section]:hover::after {
    opacity: 1;
}

/* ==================== BACKGROUND PANEL CONTROLS ==================== */
.admin-bg-type-options {
    display: flex;
    gap: 6px;
}

.admin-bg-type-btn {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    background: white;
    font-size: 0.73rem;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Montserrat', sans-serif;
    text-align: center;
}

.admin-bg-type-btn:hover {
    border-color: #c9a961;
}

.admin-bg-type-btn.active {
    border-color: #c9a961;
    background: #c9a961;
    color: #0a1628;
}

.admin-color-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-color-input {
    width: 50px;
    height: 40px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    padding: 2px;
    background: white;
}

.admin-color-input::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.admin-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

.admin-color-hex {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.85rem;
    color: #333;
}

.admin-color-hex:focus {
    border-color: #c9a961;
    outline: none;
}

.admin-gradient-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.admin-gradient-row label {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: #666;
    font-weight: 500;
}

.admin-gradient-row .admin-color-input {
    width: 100%;
    height: 36px;
}

.admin-gradient-angle {
    text-align: center;
}

.admin-gradient-angle label {
    font-size: 0.8rem;
    color: #666;
}

.admin-angle-input {
    width: 60px;
    padding: 4px 8px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    text-align: center;
    font-size: 0.85rem;
}

.admin-angle-input:focus {
    border-color: #c9a961;
    outline: none;
}

.admin-bg-img-preview {
    margin-top: 0.75rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.06);
}

.admin-bg-img-preview img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.admin-overlay-control label {
    font-size: 0.75rem;
    color: #666;
    font-weight: 500;
    display: block;
    margin-bottom: 6px;
}

.admin-bg-preview-box {
    width: 100%;
    height: 80px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.1);
    background: #ffffff;
    transition: background 0.2s;
}

/* ==================== TEXT EDITING ==================== */

/* Text hover highlight in edit mode */
body.admin-edit-active h1:not(.no-edit):hover,
body.admin-edit-active h2:not(.no-edit):hover,
body.admin-edit-active h3:not(.no-edit):hover,
body.admin-edit-active h4:not(.no-edit):hover,
body.admin-edit-active p:not(.no-edit):hover,
body.admin-edit-active li:not(.no-edit):hover,
body.admin-edit-active blockquote:not(.no-edit):hover {
    outline: 2px dashed rgba(201, 169, 97, 0.5) !important;
    outline-offset: 2px;
    cursor: text !important;
}

/* Active text editing */
.admin-text-editing {
    outline: 3px solid #c9a961 !important;
    outline-offset: 2px;
    background: rgba(255, 255, 255, 0.05) !important;
    min-height: 1.5em;
    cursor: text !important;
}

/* Floating toolbar */
.admin-text-toolbar {
    position: absolute;
    z-index: 10001;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 8px;
    background: #0a1628;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(10, 22, 40, 0.4);
    font-family: 'Montserrat', sans-serif;
    white-space: nowrap;
}

.admin-text-tb-btn {
    width: 32px;
    height: 30px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #fffefb;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.admin-text-tb-btn:hover {
    background: rgba(201, 169, 97, 0.3);
}

.admin-text-tb-sep {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 4px;
}

.admin-text-tb-save {
    padding: 5px 12px;
    border: none;
    border-radius: 4px;
    background: #c9a961;
    color: #0a1628;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    transition: background 0.15s;
}

.admin-text-tb-save:hover {
    background: #d4af37;
}

.admin-text-tb-cancel {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: #fffefb;
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    transition: background 0.15s;
}

.admin-text-tb-cancel:hover {
    background: rgba(255, 255, 255, 0.2);
}

.admin-text-tb-reset {
    padding: 5px 8px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #ef9a9a;
    font-size: 0.68rem;
    font-weight: 500;
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    transition: background 0.15s;
}

.admin-text-tb-reset:hover {
    background: rgba(198, 40, 40, 0.2);
}

/* Toast notifications */
.admin-text-toast {
    position: fixed;
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 24px;
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 10002;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.admin-text-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.admin-text-toast.success {
    background: #0a1628;
    color: #c9a961;
    box-shadow: 0 4px 20px rgba(10, 22, 40, 0.4);
}

.admin-text-toast.error {
    background: #c62828;
    color: #fff;
    box-shadow: 0 4px 20px rgba(198, 40, 40, 0.3);
}

/* Mobile */
@media (max-width: 768px) {
    .admin-edit-panel {
        width: 100%;
        right: -100%;
    }

    .admin-edit-toggle {
        bottom: 1rem;
        left: 1rem;
        padding: 0.6rem 1rem;
        font-size: 0.75rem;
    }
}
