/**
 * Inline Editor Styles
 * Edit mode UI for admin users
 */

/* Edit Mode Banner */
.edit-mode-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.edit-mode-banner .banner-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.edit-mode-banner .banner-icon {
    width: 32px;
    height: 32px;
    background: #d4af37;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-mode-banner .banner-icon i {
    color: #1a1a2e;
    font-size: 16px;
}

.edit-mode-banner .banner-text h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #d4af37;
}

.edit-mode-banner .banner-text p {
    margin: 2px 0 0;
    font-size: 12px;
    color: #aaa;
}

.edit-mode-banner .banner-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.edit-mode-banner .btn-exit-edit {
    background: transparent;
    border: 1px solid #d4af37;
    color: #d4af37;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.edit-mode-banner .btn-exit-edit:hover {
    background: #d4af37;
    color: #1a1a2e;
}

/* Body padding when edit mode is active */
body.edit-mode-active {
    padding-top: 52px !important;
}

body.edit-mode-active .top-bar {
    top: 52px;
}

body.edit-mode-active .header {
    top: 82px;
}

/* Editable Element Highlight */
[data-editable],
[data-i18n][data-editable],
[data-edit-type] {
    position: relative;
    transition: outline 0.2s, background-color 0.2s;
}

/* Show light border on all editable elements */
body.edit-mode-active [data-editable],
body.edit-mode-active [data-page-field] {
    outline: 1px dashed rgba(212, 175, 55, 0.4);
    outline-offset: 2px;
}

body.edit-mode-active [data-editable]:hover,
body.edit-mode-active [data-i18n][data-editable]:hover,
body.edit-mode-active [data-edit-type]:hover,
body.edit-mode-active [data-page-field]:hover {
    outline: 2px dashed #d4af37;
    outline-offset: 2px;
    cursor: pointer;
}

/* Edit Icon Overlay */
.edit-icon-overlay {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #d4af37;
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer !important;
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    overflow: visible !important;
    pointer-events: auto !important;
}

/* Ensure editable elements can show the icon */
body.edit-mode-active [data-editable] {
    position: relative !important;
    overflow: visible !important;
}

body.edit-mode-active [data-page-field] {
    position: relative !important;
    overflow: visible !important;
}

/* Handle inline elements like span inside anchor tags */
body.edit-mode-active span[data-editable],
body.edit-mode-active span[data-page-field],
body.edit-mode-active span[data-i18n] {
    display: inline-block !important;
    position: relative !important;
}

/* Preserve block display for summary bar labels */
body.edit-mode-active .booking-summary-bar span[data-i18n],
body.edit-mode-active .summary-row span[data-i18n],
body.edit-mode-active .summary-total span[data-i18n],
body.edit-mode-active .subtotal-row span[data-i18n] {
    display: block !important;
}

/* Prevent anchor click when editing span inside */
body.edit-mode-active a:has([data-editable]),
body.edit-mode-active a:has([data-page-field]),
body.edit-mode-active a:has([data-i18n]) {
    pointer-events: none;
}

body.edit-mode-active a [data-editable],
body.edit-mode-active a [data-page-field],
body.edit-mode-active a [data-i18n] {
    pointer-events: auto !important;
    cursor: pointer !important;
}

.edit-icon-overlay i {
    color: #1a1a2e;
    font-size: 11px;
}

body.edit-mode-active [data-editable]:hover .edit-icon-overlay,
body.edit-mode-active [data-i18n][data-editable]:hover .edit-icon-overlay,
body.edit-mode-active [data-edit-type]:hover .edit-icon-overlay,
body.edit-mode-active [data-page-field]:hover .edit-icon-overlay {
    opacity: 1;
    transform: scale(1);
}

.edit-icon-overlay:hover {
    transform: scale(1.1) !important;
    background: #e5c349;
}

/* Edit Modal */
.edit-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 100001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.edit-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.edit-modal {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    transform: translateY(20px);
    transition: transform 0.3s;
}

.edit-modal-overlay.active .edit-modal {
    transform: translateY(0);
}

.edit-modal-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.edit-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.edit-modal-header h3 i {
    color: #d4af37;
}

.edit-modal-header .close-btn {
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.edit-modal-header .close-btn:hover {
    color: #fff;
}

.edit-modal-body {
    padding: 20px;
    max-height: 50vh;
    overflow-y: auto;
}

.edit-form-group {
    margin-bottom: 16px;
}

.edit-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.edit-form-group input,
.edit-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.edit-form-group input:focus,
.edit-form-group textarea:focus {
    outline: none;
    border-color: #d4af37;
    box-shadow: 0 0 0 3px rgba(212,175,55,0.1);
}

.edit-form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.edit-form-group .field-info {
    font-size: 11px;
    color: #888;
    margin-top: 4px;
}

.edit-modal-footer {
    padding: 16px 20px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.edit-modal-footer .btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.edit-modal-footer .btn-cancel {
    background: #fff;
    border: 1px solid #ddd;
    color: #666;
}

.edit-modal-footer .btn-cancel:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.edit-modal-footer .btn-save {
    background: #d4af37;
    border: 1px solid #d4af37;
    color: #1a1a2e;
}

.edit-modal-footer .btn-save:hover {
    background: #e5c349;
    border-color: #e5c349;
}

.edit-modal-footer .btn-save:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.edit-modal-footer .btn-save.saving {
    position: relative;
    color: transparent;
}

.edit-modal-footer .btn-save.saving::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid #1a1a2e;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    left: 50%;
    top: 50%;
    margin-left: -8px;
    margin-top: -8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast Notification */
.edit-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #1a1a2e;
    color: #fff;
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 100002;
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
}

.edit-toast.show {
    transform: translateY(0);
    opacity: 1;
}

.edit-toast.success {
    border-left: 4px solid #4caf50;
}

.edit-toast.success i {
    color: #4caf50;
}

.edit-toast.error {
    border-left: 4px solid #f44336;
}

.edit-toast.error i {
    color: #f44336;
}

.edit-toast .toast-message {
    font-size: 14px;
}

/* Language Tabs in Edit Modal */
.edit-lang-tabs {
    display: flex;
    border-bottom: 1px solid #eee;
    margin-bottom: 16px;
}

.edit-lang-tab {
    padding: 8px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.edit-lang-tab:hover {
    color: #333;
}

.edit-lang-tab.active {
    color: #d4af37;
    border-bottom-color: #d4af37;
}

.edit-lang-content {
    display: none;
}

.edit-lang-content.active {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .edit-mode-banner {
        flex-direction: column;
        gap: 10px;
        padding: 12px 15px;
    }

    .edit-mode-banner .banner-left {
        width: 100%;
    }

    .edit-mode-banner .banner-right {
        width: 100%;
        justify-content: flex-end;
    }

    body.edit-mode-active {
        padding-top: 80px !important;
    }

    body.edit-mode-active .top-bar {
        top: 80px;
    }

    body.edit-mode-active .header {
        top: 110px;
    }

    .edit-modal {
        width: 95%;
        margin: 10px;
    }
}

/* Edit marker for elements */
body.edit-mode-active [data-editable]::before,
body.edit-mode-active [data-i18n][data-editable]::before,
body.edit-mode-active [data-edit-type]::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
}

/* ========================================
   Edit Mode: Passenger Selector Styles
   ======================================== */
body.edit-mode-active .passenger-selector.edit-mode-open {
    position: relative;
}

body.edit-mode-active .passenger-selector.edit-mode-open .passenger-dropdown {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
    transform: none !important;
    box-shadow: none !important;
    border: 1px dashed rgba(212, 175, 55, 0.5);
    border-radius: 8px;
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.95);
}

body.edit-mode-active .passenger-selector .passenger-display {
    pointer-events: none;
    opacity: 0.7;
}

body.edit-mode-active .passenger-selector .passenger-row {
    padding: 8px;
    margin-bottom: 5px;
    border-radius: 6px;
}

body.edit-mode-active .passenger-selector .passenger-row:hover {
    background: rgba(212, 175, 55, 0.1);
}

body.edit-mode-active .passenger-selector .stepper-btn,
body.edit-mode-active .passenger-selector input[type="number"] {
    pointer-events: none;
    opacity: 0.5;
}

/* ========================================
   Edit Mode: Tracking Modal Styles
   ======================================== */
body.edit-mode-active .tracking-modal.edit-mode-visible {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    position: fixed !important;
    top: 60px !important;
    right: 20px !important;
    left: auto !important;
    bottom: auto !important;
    width: 400px !important;
    max-width: calc(100vw - 40px) !important;
    height: auto !important;
    background: transparent !important;
    z-index: 99998 !important;
}

body.edit-mode-active .tracking-modal.edit-mode-visible .tracking-modal-content {
    position: relative !important;
    transform: none !important;
    border: 2px dashed #d4af37 !important;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2) !important;
}

body.edit-mode-active .tracking-modal.edit-mode-visible .tracking-modal-close {
    display: none !important;
}

body.edit-mode-active .tracking-modal.edit-mode-visible .tracking-submit-btn,
body.edit-mode-active .tracking-modal.edit-mode-visible input[type="text"] {
    pointer-events: none;
    opacity: 0.5;
}

body.edit-mode-active .tracking-modal.edit-mode-visible::before {
    content: 'Manage Booking Modal - Edit Mode';
    position: absolute;
    top: -30px;
    left: 0;
    background: #d4af37;
    color: #1a1a2e;
    padding: 4px 12px;
    border-radius: 4px 4px 0 0;
    font-size: 12px;
    font-weight: 600;
}

/* Mobile adjustments for edit mode elements */
@media (max-width: 768px) {
    body.edit-mode-active .tracking-modal.edit-mode-visible {
        right: 10px !important;
        width: calc(100vw - 20px) !important;
        top: 90px !important;
    }
}
