/* =============================================================================
   ICOVELL CMS — Styles éditeur inline
   ============================================================================= */

/* === Base CMS === */
body.cms-active {
    padding-top: 52px !important;
}

body.cms-active.cms-edit-mode [data-cms-no-edit],
body.cms-active.cms-edit-mode header.navbar,
body.cms-active.cms-edit-mode footer.footer {
    pointer-events: none;
}

/* Hover outline */
body.cms-edit-mode :not(header.navbar):not(footer.footer):not([id^="cms-"]):not([id^="cms-"] *):hover:not(:has(:hover)) {
    outline: 2px dashed #3b82f6 !important;
    outline-offset: 2px;
    cursor: pointer !important;
}

/* Selected outline (overrides hover) */
.cms-selected,
.cms-selected:hover {
    outline: 3px solid #3b82f6 !important;
    outline-offset: 2px !important;
    cursor: pointer !important;
}

/* Preview mode disables editing visuals */
body.cms-preview-mode [data-cms-editable],
body.cms-preview-mode * {
    outline: none !important;
    cursor: default !important;
}

body.cms-preview-mode .cms-selected { outline: none !important; }

/* === Toolbar === */
#cms-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: #11151c;
    color: #e6e8eb;
    border-bottom: 1px solid #2a3242;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 999998;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 13px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
    gap: 12px;
}

#cms-toolbar * { box-sizing: border-box; }

.cms-tb-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cms-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: #fff;
    margin-right: 8px;
    white-space: nowrap;
}

.cms-brand-logo {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.cms-brand em {
    font-style: normal;
    color: #3b82f6;
    font-weight: 500;
    margin-left: 4px;
}

.cms-tb-btn {
    height: 32px;
    padding: 0 12px;
    background: transparent;
    border: none;
    color: #a8b0bd;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.cms-tb-btn:hover {
    background: #232a36;
    color: #fff;
}

.cms-tb-btn.active,
.cms-tb-toggle.active {
    background: #232a36;
    color: #3b82f6;
    box-shadow: inset 0 -2px 0 #3b82f6;
}

.cms-tb-btn.cms-primary {
    background: #3b82f6;
    color: #fff;
}

.cms-tb-btn.cms-primary:hover { background: #2563eb; }

.cms-tb-btn.cms-success {
    background: #10b981;
    color: #fff;
}

.cms-tb-btn.cms-success:hover { background: #059669; }

.cms-tb-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.cms-tb-sep {
    width: 1px;
    height: 22px;
    background: #2a3242;
    margin: 0 4px;
}

.cms-select {
    height: 32px;
    padding: 0 8px;
    background: #232a36;
    border: 1px solid #2a3242;
    color: #e6e8eb;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    outline: none;
    max-width: 200px;
}

.cms-select:focus {
    border-color: #3b82f6;
}

.cms-select option {
    background: #232a36;
    color: #e6e8eb;
}

/* === Inspector (right sidebar) === */
#cms-inspector {
    position: fixed;
    top: 52px;
    right: 0;
    bottom: 0;
    width: 320px;
    background: #11151c;
    color: #e6e8eb;
    border-left: 1px solid #2a3242;
    overflow-y: auto;
    padding: 16px;
    z-index: 999996;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 13px;
}

body.cms-active {
    margin-right: 320px !important;
}

#cms-inspector * { box-sizing: border-box; }

.cms-insp-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6c7689;
}

.cms-insp-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.6;
}

.cms-insp-empty h3 {
    font-size: 15px;
    color: #a8b0bd;
    margin: 0 0 8px;
    font-weight: 600;
}

.cms-insp-empty p {
    font-size: 13px;
    margin: 0 0 8px;
    line-height: 1.5;
}

.cms-insp-tip {
    font-size: 11px !important;
    opacity: 0.7;
    margin-top: 16px !important;
}

.cms-insp-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #2a3242;
}

.cms-insp-tag {
    display: inline-block;
    padding: 3px 8px;
    background: #3b82f6;
    color: #fff;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 6px;
}

.cms-insp-selector {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: #6c7689;
    word-break: break-all;
    margin-top: 4px;
}

.cms-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin: 8px 0;
}

.cms-crumb {
    padding: 3px 7px;
    background: #232a36;
    border-radius: 4px;
    color: #a8b0bd;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    transition: all 0.15s ease;
}

.cms-crumb:hover {
    background: #2a3242;
    color: #3b82f6;
}

.cms-crumb.current {
    background: #3b82f6;
    color: #fff;
    cursor: default;
}

.cms-crumb-sep {
    color: #6c7689;
    font-size: 11px;
}

.cms-insp-section {
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid #2a3242;
}

.cms-insp-section:last-child { border-bottom: none; }

.cms-insp-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #6c7689;
    margin-bottom: 10px;
}

.cms-insp-label {
    display: block;
    font-size: 12px;
    color: #a8b0bd;
    margin: 8px 0 5px;
}

.cms-insp-input,
.cms-insp-textarea,
.cms-insp-select {
    width: 100%;
    padding: 8px 10px;
    background: #232a36;
    border: 1px solid #2a3242;
    border-radius: 6px;
    color: #e6e8eb;
    font-family: inherit;
    font-size: 13px;
    margin-bottom: 6px;
    outline: none;
    transition: border-color 0.15s ease;
}

.cms-insp-input:focus,
.cms-insp-textarea:focus,
.cms-insp-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.cms-insp-textarea {
    min-height: 80px;
    resize: vertical;
    font-family: inherit;
}

.cms-mono {
    font-family: 'JetBrains Mono', monospace !important;
}

.cms-val {
    color: #3b82f6;
    font-weight: 500;
}

.cms-color-row {
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}

.cms-color-row input[type="color"] {
    width: 36px;
    height: 32px;
    padding: 0;
    border: 1px solid #2a3242;
    border-radius: 6px;
    cursor: pointer;
    background: #232a36;
}

.cms-color-row input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}
.cms-color-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }

.cms-range {
    width: 100%;
    accent-color: #3b82f6;
    margin-bottom: 6px;
}

.cms-img-preview {
    width: 100%;
    aspect-ratio: 16/10;
    background: #232a36;
    border: 1px solid #2a3242;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 8px;
}

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

.cms-btn,
.cms-btn-primary,
.cms-btn-danger,
.cms-btn-warning {
    padding: 8px 12px;
    border: 1px solid #2a3242;
    border-radius: 6px;
    background: #232a36;
    color: #e6e8eb;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 4px;
}

.cms-btn:hover {
    background: #2a3242;
    border-color: #3b82f6;
}

.cms-btn-primary {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

.cms-btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
}

.cms-btn-danger {
    color: #ef4444;
    border-color: #2a3242;
}

.cms-btn-danger:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: #ef4444;
    color: #ef4444;
}

.cms-btn-warning {
    color: #f59e0b;
    border-color: #2a3242;
}

.cms-btn-warning:hover {
    background: rgba(245, 158, 11, 0.12);
    border-color: #f59e0b;
}

.cms-w100 {
    width: 100%;
    margin-top: 6px;
}

.cms-btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 4px;
    margin-bottom: 6px;
}

.cms-btn-row > .cms-btn { width: 100%; padding: 8px 4px; }

.cms-insp-section .cms-btn-row:has(button:nth-child(2):last-child) {
    grid-template-columns: 1fr 1fr;
}

.cms-insp-section .cms-btn-row:has(button:nth-child(3):last-child) {
    grid-template-columns: 1fr 1fr 1fr;
}

/* === Side panels (components, theme) === */
#cms-components-panel,
#cms-theme-panel {
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    width: 320px;
    background: #11151c;
    color: #e6e8eb;
    border-right: 1px solid #2a3242;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 999995;
    overflow-y: auto;
    padding: 16px;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 13px;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
}

#cms-components-panel.cms-open,
#cms-theme-panel.cms-open {
    transform: translateX(0);
}

.cms-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #2a3242;
}

.cms-panel-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.cms-panel-close {
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: #a8b0bd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s ease;
}

.cms-panel-close:hover {
    background: #232a36;
    color: #ef4444;
}

.cms-panel-help {
    font-size: 12px;
    color: #a8b0bd;
    margin: 0 0 14px;
    line-height: 1.5;
}

/* Components grid */
.cms-comp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.cms-comp-card {
    background: #181d27;
    border: 1px solid #2a3242;
    border-radius: 8px;
    padding: 14px 8px;
    cursor: grab;
    text-align: center;
    transition: all 0.15s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.cms-comp-card:hover {
    background: #232a36;
    border-color: #3b82f6;
    transform: translateY(-2px);
}

.cms-comp-card:active { cursor: grabbing; }

.cms-comp-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.cms-comp-name {
    font-size: 12px;
    font-weight: 500;
    color: #e6e8eb;
}

/* Theme group */
.cms-theme-group {
    margin-bottom: 18px;
}

.cms-theme-group h4 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6c7689;
    margin: 0 0 10px;
}

.cms-theme-row {
    display: grid;
    grid-template-columns: 1fr 36px 90px;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}

.cms-theme-row label {
    font-size: 12px;
    color: #a8b0bd;
}

.cms-theme-color {
    width: 36px;
    height: 32px;
    padding: 0;
    border: 1px solid #2a3242;
    border-radius: 6px;
    cursor: pointer;
    background: #232a36;
}

.cms-theme-color::-webkit-color-swatch { border: none; border-radius: 4px; }
.cms-theme-color::-webkit-color-swatch-wrapper { padding: 0; }

.cms-theme-color-text {
    padding: 6px 8px;
    background: #232a36;
    border: 1px solid #2a3242;
    color: #e6e8eb;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    text-transform: uppercase;
    outline: none;
    width: 100%;
}

.cms-theme-row:has(input[type="range"]) {
    grid-template-columns: 1fr 1fr 50px;
}

.cms-theme-row input[type="range"] {
    accent-color: #3b82f6;
    grid-column: 2 / 3;
}

.cms-theme-row select {
    grid-column: 2 / 4;
    padding: 6px 8px;
    background: #232a36;
    border: 1px solid #2a3242;
    color: #e6e8eb;
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    outline: none;
}

.cms-theme-row select option {
    background: #232a36;
    color: #e6e8eb;
}

.cms-theme-row span {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: #3b82f6;
    text-align: right;
}

/* === Sections panel (bottom-left) === */
#cms-sections-panel {
    position: fixed;
    left: 16px;
    bottom: 16px;
    width: 280px;
    max-height: 360px;
    background: #11151c;
    color: #e6e8eb;
    border: 1px solid #2a3242;
    border-radius: 10px;
    z-index: 999994;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 13px;
    display: flex;
    flex-direction: column;
}

#cms-sections-panel.cms-collapsed { max-height: 40px; }

.cms-sec-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #181d27;
    border-bottom: 1px solid #2a3242;
    font-weight: 600;
    font-size: 12px;
    color: #a8b0bd;
}

.cms-sec-toggle {
    width: 22px;
    height: 22px;
    background: #232a36;
    border: none;
    color: #e6e8eb;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

#cms-sec-list {
    list-style: none;
    margin: 0;
    padding: 6px;
    overflow-y: auto;
    flex: 1;
}

.cms-sec-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    background: #181d27;
    margin-bottom: 3px;
    font-size: 12px;
    transition: background 0.15s ease;
}

.cms-sec-item:hover { background: #232a36; }

.cms-sec-handle {
    color: #6c7689;
    cursor: grab;
    font-size: 12px;
}

.cms-sec-name {
    flex: 1;
    cursor: pointer;
    color: #e6e8eb;
}

.cms-sec-actions {
    display: flex;
    gap: 2px;
}

.cms-sec-actions button {
    width: 22px;
    height: 22px;
    background: transparent;
    border: none;
    color: #a8b0bd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s ease;
}

.cms-sec-actions button:hover {
    background: #2a3242;
    color: #fff;
}

.cms-sec-actions [data-act="del"]:hover {
    background: rgba(239, 68, 68, 0.18);
    color: #ef4444;
}

.cms-hint {
    color: #6c7689;
    text-align: center;
    padding: 12px;
    font-style: italic;
    font-size: 11px;
}

/* === Hover badge === */
#cms-hover-badge {
    position: fixed;
    pointer-events: none;
    background: #3b82f6;
    color: #fff;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    z-index: 999999;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: none;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* === Drop zones === */
.cms-drop-zone {
    min-height: 60px;
    border: 2px dashed #3b82f6;
    background: rgba(59, 130, 246, 0.08);
    margin: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3b82f6;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.cms-drop-zone.cms-drop-active {
    background: rgba(59, 130, 246, 0.20);
    border-style: solid;
    transform: scale(1.02);
}

/* === Toast notifications === */
#cms-toast-container {
    position: fixed;
    bottom: 20px;
    right: 340px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 999999;
    pointer-events: none;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
}

.cms-toast {
    background: #232a36;
    border: 1px solid #2a3242;
    border-left: 3px solid #3b82f6;
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    min-width: 220px;
    color: #e6e8eb;
    animation: cms-toast-in 0.25s ease;
    pointer-events: auto;
}

.cms-toast-success { border-left-color: #10b981; }
.cms-toast-warning { border-left-color: #f59e0b; }
.cms-toast-danger { border-left-color: #ef4444; }

@keyframes cms-toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.cms-toast.cms-toast-out {
    animation: cms-toast-out 0.2s ease forwards;
}

@keyframes cms-toast-out {
    to { transform: translateX(100%); opacity: 0; }
}

/* === Responsive (small screens) === */
@media (max-width: 900px) {
    #cms-toolbar {
        flex-wrap: wrap;
        height: auto;
        padding: 6px 12px;
        gap: 6px;
    }
    .cms-tb-group {
        flex-wrap: wrap;
    }
    body.cms-active {
        padding-top: 110px !important;
        margin-right: 0 !important;
    }
    #cms-inspector {
        position: fixed;
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 50vh;
        border-left: none;
        border-top: 1px solid #2a3242;
    }
    #cms-sections-panel {
        bottom: 50vh;
    }
    #cms-components-panel,
    #cms-theme-panel {
        width: 88vw;
    }
}
