/**
 * Editor CSS - Inline Editor UI styles
 * Universal Onepager Editor
 */

/* Edit Button in Footer */
.edit-trigger {
    display: inline-block;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.5);
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    cursor: pointer;
    margin-top: 1rem;
    transition: all 0.3s ease;
}

.edit-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-white);
    border-color: var(--color-secondary);
}

/* Edit Mode Banner */
.edit-mode-banner {
    display: none;
    position: fixed;
    top: 74px;
    left: 0;
    right: 0;
    background: var(--color-secondary);
    color: white;
    text-align: center;
    padding: 0.6rem 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.85rem;
    z-index: 9999;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

body.edit-mode .edit-mode-banner {
    display: block;
}

body.edit-mode section {
    scroll-margin-top: 120px;
}

/* Editable Elements */
body.edit-mode [data-editable] {
    outline: 2px dashed transparent;
    outline-offset: 4px;
    transition: outline-color 0.2s, background-color 0.2s;
    cursor: text;
    min-height: 1em;
}

body.edit-mode [data-editable]:hover {
    outline-color: var(--color-primary);
    background-color: rgba(0, 128, 200, 0.05);
}

body.edit-mode [data-editable]:focus {
    outline: 3px solid var(--color-secondary);
    outline-offset: 4px;
    background-color: rgba(162, 197, 22, 0.1);
}

/* Editable Images */
body.edit-mode [data-editable-image] {
    position: relative;
    cursor: pointer;
}

body.edit-mode [data-editable-image]::after {
    content: 'Bild andern';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 128, 200, 0.85);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 10;
}

body.edit-mode [data-editable-image]:hover::after {
    opacity: 1;
}

/* Gallery Caption - bessere Lesbarkeit beim Bearbeiten */
body.edit-mode .gallery-caption[data-editable] {
    background: #ffffff;
    color: #1a1a1a;
}

body.edit-mode .gallery-caption[data-editable]:focus {
    background: #ffffff;
    color: #1a1a1a;
    outline-color: var(--color-secondary);
}

/* Section Add Buttons */
body.edit-mode .section-add-btn {
    display: flex;
}

.section-add-btn {
    display: none;
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0, 128, 200, 0.4);
    transition: all 0.3s ease;
}

.section-add-btn:hover {
    background: var(--color-secondary);
    transform: translateX(-50%) scale(1.1);
}

/* Section Controls (Move/Delete) */
.section-controls {
    display: none;
    position: absolute;
    top: 10px;
    right: 10px;
    gap: 0.5rem;
    z-index: 100;
}

body.edit-mode .section-controls {
    display: flex;
}

.section-controls button {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.section-controls .btn-move-up,
.section-controls .btn-move-down {
    background: var(--color-primary);
    color: white;
}

.section-controls .btn-move-up:hover,
.section-controls .btn-move-down:hover {
    background: var(--color-primary-dark);
}

.section-controls .btn-settings {
    background: var(--color-gray);
    color: white;
}

.section-controls .btn-settings:hover {
    background: #555;
}

.section-controls .btn-delete {
    background: var(--color-danger);
    color: white;
}

.section-controls .btn-delete:hover {
    background: #b71c1c;
}

/* Custom section label in edit mode */
body.edit-mode .custom-section {
    position: relative;
    border: 2px dashed transparent;
    transition: border-color 0.3s;
}

body.edit-mode .custom-section:hover {
    border-color: var(--color-primary);
}

/* Editor Toolbar */
.editor-toolbar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-primary-dark);
    padding: 1rem var(--container-padding);
    z-index: 10000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

body.edit-mode .editor-toolbar {
    display: block;
}

.editor-toolbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.editor-toolbar button {
    background: var(--color-secondary);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.editor-toolbar button:hover {
    background: var(--color-secondary-dark);
}

.editor-toolbar button.secondary {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.editor-toolbar button.secondary:hover {
    border-color: white;
    background: rgba(255, 255, 255, 0.1);
}

.editor-toolbar button#btnHelp {
    width: 36px;
    padding: 0;
    font-size: 1.2rem;
    font-weight: bold;
}

.editor-toolbar .save-status {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
}

.editor-toolbar .save-status.saved {
    color: var(--color-secondary);
}

/* Theme Editor Panel */
.theme-editor-panel {
    display: none;
    position: fixed;
    top: 120px;
    right: 20px;
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 10001;
    min-width: 280px;
}

.theme-editor-panel.visible {
    display: block;
}

.theme-editor-panel h4 {
    margin: 0 0 1rem 0;
    color: var(--color-primary-dark);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.theme-editor-panel .close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-gray);
    padding: 0;
    width: auto;
}

.theme-editor-panel .close-btn:hover {
    color: var(--color-danger);
    background: none;
}

.theme-field {
    margin-bottom: 1rem;
}

.theme-field label {
    display: block;
    font-size: 0.85rem;
    color: var(--color-gray);
    margin-bottom: 0.5rem;
}

.theme-field input[type="color"] {
    width: 100%;
    height: 40px;
    border: 2px solid var(--color-gray-light);
    border-radius: 4px;
    cursor: pointer;
    padding: 2px;
}

.theme-field select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--color-gray-light);
    border-radius: 4px;
    font-family: var(--font-main);
    font-size: 1rem;
    cursor: pointer;
}

.theme-field select:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Floating Format Toolbar */
.format-toolbar {
    display: none;
    position: fixed;
    background: var(--color-black);
    padding: 0.5rem;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    gap: 0.25rem;
}

.format-toolbar.visible {
    display: flex;
}

.format-toolbar button {
    background: transparent;
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
    padding: 0;
}

.format-toolbar button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.format-toolbar button.active {
    background: var(--color-primary);
}

/* Login Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10002;
    align-items: center;
    justify-content: center;
    padding: var(--container-padding);
}

.modal-overlay.visible {
    display: flex;
}

.modal {
    background: white;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    position: relative;
}

.modal.wide {
    max-width: 600px;
}

.modal h3 {
    color: var(--color-primary-dark);
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
}

.modal input[type="password"],
.modal input[type="text"] {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--color-gray-light);
    font-family: var(--font-main);
    font-size: 1rem;
    margin-bottom: 1rem;
}

.modal input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.modal .form-group {
    margin-bottom: 1rem;
}

.modal .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--color-dark);
}

.modal .form-group label input[type="checkbox"] {
    margin-right: 0.5rem;
    transform: scale(1.2);
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.modal-buttons button {
    flex: 1;
    padding: 1rem;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s;
}

.modal-buttons .btn-primary {
    background: var(--color-secondary);
    color: white;
    border: none;
}

.modal-buttons .btn-primary:hover {
    background: var(--color-secondary-dark);
}

.modal-buttons .btn-secondary {
    background: transparent;
    color: var(--color-gray);
    border: 2px solid var(--color-gray-light);
}

.modal-buttons .btn-secondary:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.modal .error-message {
    color: var(--color-danger);
    font-size: 0.9rem;
    margin-top: -0.5rem;
    margin-bottom: 1rem;
    display: none;
}

.modal .error-message.visible {
    display: block;
}

.modal-buttons .btn-danger {
    background: #e74c3c;
    color: white;
    border: none;
    flex: 0 0 auto;
    padding: 1rem 1.5rem;
}

.modal-buttons .btn-danger:hover {
    background: #c0392b;
}

/* Media Tabs */
.media-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--color-gray-light);
}

.media-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    cursor: pointer;
    color: var(--color-gray);
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.media-tab:hover {
    color: var(--color-primary);
}

.media-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.media-tab-content {
    min-height: 200px;
}

/* Media Grid */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
    padding: 0.25rem;
}

.media-item {
    position: relative;
    aspect-ratio: 1;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    transition: all 0.2s;
}

.media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-item:hover {
    border-color: var(--color-primary);
}

.media-item.selected {
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 2px var(--color-secondary);
}

.media-item .media-date {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.65rem;
    padding: 0.25rem;
    text-align: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.media-item:hover .media-date,
.media-item.selected .media-date {
    opacity: 1;
}

/* Template Selection Modal */
.template-nav-input {
    margin-bottom: 1rem;
}

.template-nav-input label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--color-primary-dark);
}

.template-nav-input input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-gray-light);
    font-family: var(--font-main);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.template-nav-input input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.template-nav-input .input-hint {
    font-size: 0.8rem;
    color: var(--color-gray);
    margin-top: 0.5rem;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.template-card {
    border: 2px solid var(--color-gray-light);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.template-card:hover {
    border-color: var(--color-primary);
    background: rgba(0, 128, 200, 0.05);
}

.template-card.selected {
    border-color: var(--color-secondary);
    background: rgba(162, 197, 22, 0.1);
}

.template-card h4 {
    color: var(--color-primary-dark);
    margin-bottom: 0.5rem;
}

.template-card p {
    color: var(--color-gray);
    font-size: 0.85rem;
}

.template-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

/* Image Upload Modal */
.upload-zone {
    border: 3px dashed var(--color-gray-light);
    padding: 3rem;
    text-align: center;
    margin: 1.5rem 0;
    transition: all 0.3s;
    cursor: pointer;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--color-primary);
    background: rgba(0, 128, 200, 0.05);
}

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

.upload-zone p {
    color: var(--color-gray);
    margin-top: 1rem;
}

.upload-preview {
    max-width: 100%;
    max-height: 200px;
    margin-top: 1rem;
    display: none;
}

.upload-preview.visible {
    display: block;
}

/* Custom Section Styles */
.custom-section {
    position: relative;
}

body.edit-mode .custom-section::before {
    content: attr(data-section-type);
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--color-primary);
    color: white;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    z-index: 10;
}

/* Mobile Editor Adjustments */
@media (max-width: 768px) {
    .editor-toolbar-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .editor-toolbar button {
        width: 100%;
    }

    .format-toolbar {
        left: 50% !important;
        transform: translateX(-50%);
    }

    body.edit-mode .briefwahl-fab {
        bottom: 100px;
    }

    .theme-editor-panel {
        left: 20px;
        right: 20px;
        min-width: auto;
    }
}

/* Hide editor elements when not in edit mode */
body:not(.edit-mode) .editor-toolbar,
body:not(.edit-mode) .edit-mode-banner,
body:not(.edit-mode) .section-add-btn,
body:not(.edit-mode) .section-controls {
    display: none !important;
}
