/* ─────────────────────────────────────────────────────────────────
   styler.css — Theme Editor Panel
───────────────────────────────────────────────────────────────── */

/* ── Floating trigger ─────────────────────────────────────────── */
.styler-trigger {
    position: fixed;
    bottom: 28px;
    left: 28px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--main-color, #2c4135);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22), 0 1px 4px rgba(0, 0, 0, 0.12);
    z-index: 9000;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.2s ease,
        background 0.2s ease;
    outline: none;
}

.styler-trigger:hover {
    transform: scale(1.12) rotate(28deg);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}

.styler-trigger:focus-visible {
    box-shadow: 0 0 0 3px var(--main-color, #2c4135), 0 0 0 5px rgba(255, 255, 255, 0.8);
}

/* ── Main panel ───────────────────────────────────────────────── */
.styler-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    height: 100dvh;
    z-index: 9002;
    display: flex;
    flex-direction: column;
    background: var(--cms-surface-1, #f0efeb);

    border-left: 4px solid var(--main-color, #2c4135);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.18), -2px 0 10px rgba(0, 0, 0, 0.08);

    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    color: #1a1a1a;
    line-height: 1.5;
}

.styler-panel.open {
    transform: translateX(0);
}

/* ── Unified Header / Toolbar ─────────────────────────────────── */
.styler-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Added to push buttons to the right */
    padding: 14px 20px;
    gap: 12px;
    background: var(--cms-surface-3, #fff);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.styler-search-box {
    flex: 1 1 100% !important;
    /* Force it to take up the remaining space */
    position: relative;
    display: flex !important;
    /* Override potential CMS display:block */
    align-items: center;
    min-width: 160px;
    /* Prevent it from collapsing completely */
    margin: 0;
}

.styler-search-box svg {
    position: absolute;
    left: 10px;
    color: #c0c0c0;
    z-index: 1;
}

.styler-search-box input {
    width: 100% !important;
    /* Force input to fill the wrapper */
    padding: 8px 10px 8px 30px;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    height: 34px;
    box-sizing: border-box;
}

.styler-search-box input:focus {
    border-color: var(--main-color, #2c4135);
}

.styler-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.styler-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    color: #555;
    transition: all 0.2s;
    box-sizing: border-box;
    padding: 0;
}

.styler-icon-btn:hover:not(:disabled) {
    background: #f5f5f5;
    color: #000;
    border-color: #ccc;
}

.styler-icon-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #fafafa;
}

.styler-icon-btn.active {
    background: rgba(255, 149, 0, 0.1);
    border-color: rgba(255, 149, 0, 0.3);
    color: var(--cms-warning, #ff9500);
}

.styler-divider {
    width: 1px;
    height: 16px;
    background: rgba(0, 0, 0, 0.12);
    margin: 0 2px;
}

.styler-dirty-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: var(--cms-warning, #ff9500);
    border-radius: 50%;
    margin-left: 5px;
    vertical-align: middle;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.styler-dirty-dot.visible {
    opacity: 1;
}

/* ── Scrollable body ──────────────────────────────────────────── */
.styler-body {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 20px 16px;
    scroll-behavior: smooth;
}

.styler-body::-webkit-scrollbar {
    width: 4px;
}

.styler-body::-webkit-scrollbar-track {
    background: transparent;
}

.styler-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.13);
    border-radius: 2px;
}

/* ── Alert area ───────────────────────────────────────────────── */
#styler-alert-area .cms-alert {
    margin-bottom: 12px;
}

/* ── Token row ────────────────────────────────────────────────── */
.styler-token {
    padding: 12px 0 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.055);
    position: relative;
    transition: background 0.15s ease;
}

.styler-token:last-child {
    border-bottom: none;
}

.styler-token-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

.styler-token::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 18px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--cms-warning, #ff9500);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.styler-token.styler-token-changed::before {
    opacity: 1;
}

.styler-var-name {
    display: inline-block;
    font-size: 10px;
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
    color: var(--cms-brand, #2c4135);
    opacity: 0.45;
    margin-top: 5px;
    cursor: pointer;
    transition: opacity 0.15s ease;
    user-select: none;
    letter-spacing: 0.01em;
}

.styler-var-name:hover {
    opacity: 0.9;
}

.styler-var-name::after {
    content: ' ⎘';
    font-style: normal;
}

/* ── No-results state ─────────────────────────────────────────── */
.styler-empty {
    text-align: center;
    padding: 32px 0;
    font-size: 13px;
    color: #999;
}

/* ── Footer action bar ────────────────────────────────────────── */
.styler-footer {
    flex-shrink: 0;
    padding: 12px 20px;
    background: var(--cms-surface-3, #fff);
    border-top: 1px solid rgba(0, 0, 0, 0.07);
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}

.styler-footer .cms-btn:first-child {
    margin-right: auto;
}

/* ── Isolated Accordion Classes ─────────────── */
.styler-group {
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
    background: var(--cms-surface-3, #fff);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.styler-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    font-weight: 600;
    user-select: none;
    transition: background-color 0.2s ease;
}

.styler-group-header:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.styler-group-title {
    font-size: 13px;
}

.styler-group-desc {
    font-size: 11px;
    line-height: 1.4;
    color: #666;
    margin: 4px 0 12px 0;
}

.styler-group-chevron {
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Expand / Collapse Logic */
.styler-group.styler-collapsed .styler-group-body {
    display: none;
}

.styler-group.styler-collapsed .styler-group-chevron {
    transform: rotate(0deg);
}

.styler-group:not(.styler-collapsed) .styler-group-chevron {
    transform: rotate(180deg);
}

.styler-group-body {
    padding: 0 16px 8px;
}

/* ── Overriding CMS inputs inside styler to ensure consistency ── */
.styler-panel .cms-field {
    margin-bottom: 0;
    padding-bottom: 0;
}

.styler-panel .cms-label {
    font-size: 12.5px;
}

.styler-panel .cms-muted {
    font-size: 11px;
    line-height: 1.4;
    margin-bottom: 6px;
}

/* ── Color UI Redesign ────────────────────────────────────────── */
.cms-color-field {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.cms-color-swatch-wrapper {
    position: relative;
    width: 34px;
    height: 34px;
}

.cms-color-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 2;
}

.cms-color-swatch {
    position: absolute;
    inset: 0;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    z-index: 1;
}

.cms-color-hex {
    flex: 1;
    font-family: 'SFMono-Regular', 'Consolas', monospace;
    border-radius: 6px;
    border: 1px solid #dcdcdc;
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s ease;
}

.cms-color-hex:focus {
    border-color: var(--cms-brand, #2c4135);
}

/* Color Suggestions UI */
.styler-color-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.styler-color-suggestion {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.styler-color-suggestion:hover {
    transform: scale(1.18);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* ── Responsive: full-width on mobile ─────────────────────────── */
@media (max-width: 480px) {
    .styler-panel {
        width: 100dvw;
        border-radius: 0;
    }

    .styler-trigger {
        bottom: 20px;
        left: 16px;
    }
}