/* ============================================
   Wedding Editor - Styles
   ============================================ */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    /* Editor Colors */
    --editor-bg: #1a1a2e;
    --editor-surface: #16213e;
    --editor-surface-light: #1f3460;
    --editor-border: #2a4080;
    --editor-text: #e8e8e8;
    --editor-text-muted: #8a8aa3;
    --editor-primary: #4a90d9;
    --editor-primary-light: #6aa8f0;
    --editor-success: #4ade80;
    --editor-warning: #fbbf24;
    --editor-danger: #f87171;
    --editor-gold: #D4AF37;

    /* Sizing */
    --toolbar-height: 56px;
    --sidebar-width: 300px;

    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-base: 250ms ease-in-out;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.5);
}

/* ============================================
   Reset & Base
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--editor-bg);
    color: var(--editor-text);
    font-size: 14px;
    line-height: 1.5;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input,
textarea,
select {
    font-family: inherit;
    font-size: inherit;
}

.hidden {
    display: none !important;
}

/* ============================================
   Top Toolbar
   ============================================ */
.editor-toolbar {
    height: var(--toolbar-height);
    background: var(--editor-surface);
    border-bottom: 1px solid var(--editor-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.toolbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 18px;
}

.brand-icon {
    font-size: 24px;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--editor-surface-light);
    border-radius: 6px;
    color: var(--editor-text);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.toolbar-btn:hover {
    background: var(--editor-primary);
    color: white;
}

.toolbar-btn.btn-primary {
    background: var(--editor-primary);
    color: white;
}

.toolbar-btn.btn-primary:hover {
    background: var(--editor-primary-light);
}

.toolbar-btn.btn-danger:hover {
    background: var(--editor-danger);
}

.btn-icon {
    font-size: 16px;
}

.toolbar-separator {
    width: 1px;
    height: 28px;
    background: var(--editor-border);
    margin: 0 8px;
}

/* ============================================
   Main Layout
   ============================================ */
.editor-main {
    display: flex;
    height: calc(100vh - var(--toolbar-height));
    margin-top: var(--toolbar-height);
}

/* ============================================
   Sidebar
   ============================================ */
.editor-sidebar {
    width: var(--sidebar-width);
    background: var(--editor-surface);
    border-right: 1px solid var(--editor-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-panel {
    border-bottom: 1px solid var(--editor-border);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--editor-surface-light);
    cursor: pointer;
    user-select: none;
}

.panel-header:hover {
    background: var(--editor-border);
}

.panel-icon {
    font-size: 16px;
}

.panel-title {
    flex: 1;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-toggle {
    color: var(--editor-text-muted);
    font-size: 12px;
    transition: transform var(--transition-fast);
}

.panel-toggle.collapsed {
    transform: rotate(-90deg);
}

.panel-badge {
    background: var(--editor-primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.panel-content {
    padding: 12px;
    /* Content flows naturally, sidebar scrolls */
}

.panel-content.collapsed {
    display: none;
}

/* Sections Groups (Active + Templates) */
.sections-group {
    margin-bottom: 16px;
}

.sections-group:last-child {
    margin-bottom: 0;
}

.sections-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--editor-text-muted);
    margin-bottom: 10px;
    padding: 0 4px;
}

.group-icon {
    font-size: 12px;
}

.sections-group-badge {
    background: var(--editor-primary);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
}

.sections-group-templates .sections-group-title {
    color: var(--editor-warning);
}

.sections-group-templates .sections-group-badge {
    background: var(--editor-warning);
    color: #1a1a2e;
}

/* Section List */
.section-list {
    list-style: none;
}

.section-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--editor-surface-light);
    border-radius: 6px;
    cursor: grab;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.section-item:hover {
    border-color: var(--editor-primary);
    background: var(--editor-border);
}

.section-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.section-item.drag-over {
    border-color: var(--editor-primary);
    border-style: dashed;
}

.section-item.selected {
    border-color: var(--editor-gold);
    background: rgba(212, 175, 55, 0.1);
}

.section-drag-handle {
    color: var(--editor-text-muted);
    font-size: 16px;
    cursor: grab;
}

.section-drag-handle.section-drag-disabled {
    cursor: default;
    opacity: 0.6;
}

.section-item.section-fixed {
    background: rgba(212, 175, 55, 0.1);
    border: 1px dashed var(--editor-gold);
}

.section-icon {
    font-size: 18px;
}

.section-name {
    flex: 1;
    font-weight: 500;
}

.section-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.section-item:hover .section-actions {
    opacity: 1;
}

.section-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 14px;
    transition: all var(--transition-fast);
}

.section-btn:hover {
    background: var(--editor-primary);
}

.section-btn.btn-hide:hover {
    background: var(--editor-warning);
    color: #1a1a2e;
}

/* Template List */
.template-list {
    list-style: none;
}

.template-empty {
    color: var(--editor-text-muted);
    font-style: italic;
    text-align: center;
    padding: 16px;
}

.template-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--editor-surface-light);
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.7;
    transition: all var(--transition-fast);
}

.template-item:hover {
    opacity: 1;
    background: var(--editor-success);
    color: #1a1a2e;
}

.template-add-icon {
    font-size: 16px;
}

/* Templates in group - compact style */
.sections-group-templates .template-list {
    opacity: 0.9;
}

.sections-group-templates .template-item {
    background: rgba(45, 80, 22, 0.1);
    border: 1px dashed var(--editor-text-muted);
}

.sections-group-templates .template-item:hover {
    background: var(--editor-success);
    border-color: var(--editor-success);
}

/* Theme Panel */
.theme-colors {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.color-picker-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.color-picker-group label {
    font-size: 12px;
    color: var(--editor-text-muted);
}

.color-picker-group input[type="color"] {
    width: 100%;
    height: 36px;
    border: 1px solid var(--editor-border);
    border-radius: 6px;
    cursor: pointer;
    background: var(--editor-surface-light);
    padding: 2px;
}

.theme-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.preset-btn {
    flex: 1;
    min-width: 80px;
    padding: 8px 12px;
    background: var(--editor-surface-light);
    border-radius: 6px;
    color: var(--editor-text);
    font-size: 12px;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.preset-btn:hover {
    background: var(--editor-primary);
    color: white;
}

.preset-btn.active {
    background: var(--editor-gold);
    color: #1a1a1a;
    font-weight: 600;
}

/* Properties Panel */
.properties-empty {
    text-align: center;
    padding: 24px 16px;
    color: var(--editor-text-muted);
}

.properties-editor {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.property-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.property-group label {
    font-size: 12px;
    color: var(--editor-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.property-value {
    font-weight: 500;
    color: var(--editor-primary);
}

.property-group input[type="text"],
.property-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--editor-surface-light);
    border: 1px solid var(--editor-border);
    border-radius: 6px;
    color: var(--editor-text);
    resize: vertical;
}

.property-group input[type="text"]:focus,
.property-group textarea:focus {
    outline: none;
    border-color: var(--editor-primary);
}

.property-group input[type="color"] {
    width: 100%;
    height: 36px;
    border: 1px solid var(--editor-border);
    border-radius: 6px;
    cursor: pointer;
    background: var(--editor-surface-light);
    padding: 2px;
}

.size-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.size-control input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: var(--editor-surface-light);
    border-radius: 3px;
}

.size-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--editor-primary);
    border-radius: 50%;
    cursor: pointer;
}

.size-control span {
    min-width: 50px;
    font-weight: 500;
    color: var(--editor-primary);
}

.btn-upload {
    width: 100%;
    padding: 10px;
    background: var(--editor-surface-light);
    border: 1px dashed var(--editor-border);
    border-radius: 6px;
    color: var(--editor-text);
    margin-top: 8px;
    transition: all var(--transition-fast);
}

.btn-upload:hover {
    border-color: var(--editor-primary);
    color: var(--editor-primary);
}

.property-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}

.property-actions .btn-cancel {
    flex: 1;
    padding: 12px;
    background: var(--editor-surface-light);
    border: 1px solid var(--editor-border);
    border-radius: 6px;
    color: var(--editor-text);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.property-actions .btn-cancel:hover {
    background: var(--editor-warning);
    color: #1a1a1a;
    border-color: var(--editor-warning);
}

.btn-apply {
    flex: 1;
    padding: 12px;
    background: var(--editor-primary);
    border-radius: 6px;
    color: white;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.btn-apply:hover {
    background: var(--editor-primary-light);
}

/* ============================================
   Preview Area
   ============================================ */
.editor-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #2a2a3e;
    position: relative;
}

.preview-container {
    flex: 1;
    padding: 20px;
    overflow: hidden;
    position: relative;
}

#previewFrame {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    background: white;
}

.preview-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    pointer-events: none;
    border-radius: 8px;
    overflow: hidden;
}

.overlay-highlight {
    position: absolute;
    border: 2px solid var(--editor-primary);
    background: rgba(74, 144, 217, 0.1);
    pointer-events: none;
    transition: all var(--transition-fast);
}

.preview-resize-handle {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 8px;
    background: var(--editor-border);
    border-radius: 4px 4px 0 0;
    cursor: ns-resize;
}

.preview-resize-handle:hover {
    background: var(--editor-primary);
}

/* ============================================
   Modals
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: relative;
    background: var(--editor-surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
}

.modal-content.modal-sm {
    max-width: 400px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--editor-border);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--editor-text-muted);
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--editor-danger);
    color: white;
}

.modal-body {
    padding: 24px;
}

.export-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.export-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 16px;
    background: var(--editor-surface-light);
    border: 1px solid var(--editor-border);
    border-radius: 8px;
    text-align: left;
    transition: all var(--transition-fast);
}

.export-option:hover {
    border-color: var(--editor-primary);
    background: var(--editor-border);
}

.option-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.option-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.option-desc {
    font-size: 13px;
    color: var(--editor-text-muted);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.btn-cancel {
    flex: 1;
    padding: 12px;
    background: var(--editor-surface-light);
    border-radius: 6px;
    color: var(--editor-text);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.btn-cancel:hover {
    background: var(--editor-border);
}

.modal-actions .btn-danger {
    flex: 1;
    padding: 12px;
    background: var(--editor-danger);
    border-radius: 6px;
    color: white;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.modal-actions .btn-danger:hover {
    opacity: 0.9;
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    padding: 14px 20px;
    background: var(--editor-surface);
    border-left: 4px solid var(--editor-primary);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success {
    border-color: var(--editor-success);
}

.toast.warning {
    border-color: var(--editor-warning);
}

.toast.error {
    border-color: var(--editor-danger);
}

.toast-icon {
    font-size: 18px;
}

.toast-message {
    font-weight: 500;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   Edit Mode Styles (injected into iframe)
   ============================================ */
.editor-mode-highlight {
    outline: 2px dashed rgba(74, 144, 217, 0.5) !important;
    outline-offset: 2px;
    cursor: pointer !important;
}

.editor-mode-selected {
    outline: 3px solid #D4AF37 !important;
    outline-offset: 2px;
}

.editor-mode-editing {
    outline: 3px solid #4ade80 !important;
    background: rgba(74, 222, 128, 0.05) !important;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 260px;
    }

    .toolbar-btn .btn-text {
        display: none;
    }

    .toolbar-btn {
        padding: 8px 12px;
    }
}

@media (max-width: 768px) {
    .editor-sidebar {
        position: fixed;
        left: 0;
        top: var(--toolbar-height);
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform var(--transition-base);
    }

    .editor-sidebar.open {
        transform: translateX(0);
    }

    .preview-container {
        padding: 10px;
    }
}

/* ============================================
   Scrollbar Styling
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--editor-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--editor-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--editor-primary);
}

/* ============================================
   Components Panel
   ============================================ */
.component-toggles {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.component-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--editor-surface-light);
    border-radius: 6px;
}

.component-icon {
    font-size: 18px;
}

.component-name {
    flex: 1;
    font-weight: 500;
}

.toggle-btn {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    transition: all var(--transition-fast);
    background: var(--editor-surface-light);
    border: 1px solid var(--editor-border);
    color: var(--editor-text-muted);
}

.toggle-btn.active {
    background: var(--editor-success);
    border-color: var(--editor-success);
    color: #1a1a1a;
}

.toggle-btn.active .toggle-on {
    display: inline;
}

.toggle-btn.active .toggle-off {
    display: none;
}

.toggle-btn:not(.active) .toggle-on {
    display: none;
}

.toggle-btn:not(.active) .toggle-off {
    display: inline;
}

.component-section {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--editor-border);
}

.component-section h5 {
    font-size: 12px;
    color: var(--editor-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.timeline-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.component-btn {
    width: 100%;
    padding: 10px 12px;
    background: var(--editor-surface-light);
    border: 1px solid var(--editor-border);
    border-radius: 6px;
    color: var(--editor-text);
    font-weight: 500;
    font-size: 13px;
    text-align: left;
    transition: all var(--transition-fast);
}

.component-btn:hover {
    background: var(--editor-primary);
    border-color: var(--editor-primary);
    color: white;
}

/* ============================================
   Schedule Panel Styles
   ============================================ */
.schedule-events-section {
    margin-bottom: 20px;
}

.schedule-events-section h5,
.schedule-blur-section h5 {
    font-size: 12px;
    color: var(--editor-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.schedule-events-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    max-height: 280px;
    overflow-y: auto;
}

.schedule-event-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--editor-surface-light);
    border: 1px solid var(--editor-border);
    border-radius: 8px;
    transition: all var(--transition-fast);
}

.schedule-event-item:hover {
    border-color: var(--editor-primary);
}

.schedule-event-item.dragging {
    opacity: 0.5;
    border-color: var(--editor-primary);
}

.schedule-event-time {
    width: 60px;
    padding: 4px 6px;
    background: white;
    border: 1px solid var(--editor-border);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--editor-primary);
    text-align: center;
}

.schedule-event-time:focus {
    outline: none;
    border-color: var(--editor-primary);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

/* Hide clock icon in time input */
.schedule-event-time::-webkit-calendar-picker-indicator {
    display: none;
}

.schedule-event-title {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.schedule-event-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.schedule-event-item:hover .schedule-event-actions {
    opacity: 1;
}

.schedule-event-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 12px;
    color: var(--editor-text-muted);
    transition: all var(--transition-fast);
}

.schedule-event-btn:hover {
    background: var(--editor-danger);
    color: white;
}

.schedule-actions {
    display: flex;
    gap: 8px;
}

.schedule-actions .component-btn {
    flex: 1;
}

/* Blur Section Styles */
.schedule-blur-section {
    padding-top: 16px;
    border-top: 1px solid var(--editor-border);
}

.blur-global-toggle {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--editor-surface-light);
    border-radius: 8px;
}

.blur-toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
}

.blur-toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.blur-hint {
    font-size: 11px;
    color: var(--editor-text-muted);
    margin-top: 6px;
    margin-left: 28px;
}

.blur-subtitle {
    font-size: 12px;
    color: var(--editor-text-muted);
    margin-bottom: 10px;
}

.tile-blur-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    max-height: 180px;
    overflow-y: auto;
}

.tile-blur-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--editor-surface-light);
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 11px;
}

.tile-blur-item:hover {
    border-color: var(--editor-primary);
    background: white;
}

.tile-blur-item input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

.tile-blur-item span {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}