/**
 * Page Designer — Custom Code Settings Panel — dedicated styles
 * v1.0.0 (introduced in PAGE_DESIGNER_VERSION 2.7.10)
 *
 * Fully isolated `.pd-cc-pnl-*` namespace. Panel-chrome rules are
 * deliberately DUPLICATED locally instead of reusing any shared
 * `.pd-dsp-*` / `.pd-typ-*` / `.pd-img-pnl-*` base — this honours
 * the project's "no shared CSS classes between tools" rule.
 *
 * Every selector in this file is prefixed `.pd-cc-pnl-`. There is no
 * overlap with any other tool's namespace.
 */

/* ── Panel root (right-side slide-out rail) ───────────────────────── */
.pd-cc-pnl-root {
    position: fixed;
    top: 50px;
    right: -340px;
    width: 300px;
    height: calc(100vh - 50px);
    background: var(--at-color-background, #1e1e2e);
    border-left: 1px solid var(--at-color-border, #313244);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.40);
    z-index: 9000;
    display: flex;
    flex-direction: column;
    transition: right 0.25s ease;
    color: var(--at-color-card-foreground);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
}
.pd-cc-pnl-root.pd-cc-pnl-visible {
    right: 0;
}

/* ── Header ───────────────────────────────────────────────────────── */
.pd-cc-pnl-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--at-color-card, #181825);
    border-bottom: 1px solid var(--at-color-border, #313244);
    flex: 0 0 auto;
}
.pd-cc-pnl-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--at-color-card-foreground);
}
.pd-cc-pnl-title .fa {
    color: var(--at-color-primary);
    font-size: 13px;
}
.pd-cc-pnl-close {
    background: transparent;
    border: none;
    padding: 4px 9px;
    color: var(--at-color-card-foreground);
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
}
.pd-cc-pnl-close:hover {
    color: var(--at-color-destructive-ink);
    background: var(--at-color-secondary, #313244);
}

/* ── Body (scrolls) ───────────────────────────────────────────────── */
.pd-cc-pnl-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px 14px 24px;
}
.pd-cc-pnl-body::-webkit-scrollbar {
    width: 8px;
}
.pd-cc-pnl-body::-webkit-scrollbar-track {
    background: var(--at-color-card, #181825);
}
.pd-cc-pnl-body::-webkit-scrollbar-thumb {
    background: var(--at-color-secondary, #313244);
    border-radius: 4px;
}
.pd-cc-pnl-body::-webkit-scrollbar-thumb:hover {
    background: var(--at-color-muted, #45475a);
}

/* ── Reset to Default button ──────────────────────────────────────── */
.pd-cc-pnl-reset {
    width: 100%;
    background: var(--at-color-destructive);
    color: var(--at-color-destructive-foreground);
    border: 1px solid color-mix(in srgb, var(--at-color-destructive, #f38ba8) 25%, transparent);
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 12px;
    font-family: inherit;
}
.pd-cc-pnl-reset:hover {
    background: var(--at-color-destructive);
    border-color: color-mix(in srgb, var(--at-color-destructive, #f38ba8) 40%, transparent);
}
.pd-cc-pnl-reset .fa {
    margin-right: 5px;
}

/* ── Accordion sections ───────────────────────────────────────────── */
.pd-cc-pnl-section {
    border-top: 1px solid var(--at-color-border, #313244);
    margin: 0 -14px;
}
.pd-cc-pnl-section:last-child {
    border-bottom: 1px solid var(--at-color-border, #313244);
}
.pd-cc-pnl-section-header {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 16px;
    cursor: pointer;
    user-select: none;
    transition: background 0.12s;
}
.pd-cc-pnl-section-header:hover {
    background: var(--at-color-muted);
}
.pd-cc-pnl-section-icon {
    color: var(--at-color-primary);
    font-size: 12px;
    width: 14px;
    text-align: center;
}
.pd-cc-pnl-section-title {
    flex: 1 1 auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--at-color-card-foreground);
}
.pd-cc-pnl-section-arrow {
    color: var(--at-color-card-foreground);
    font-size: 10px;
    transition: transform 0.18s;
}
.pd-cc-pnl-section-open .pd-cc-pnl-section-arrow {
    transform: rotate(180deg);
}
.pd-cc-pnl-section-body {
    display: none;
    padding: 4px 16px 14px;
    flex-direction: column;
    gap: 11px;
}
.pd-cc-pnl-section-open .pd-cc-pnl-section-body {
    display: flex;
}

/* ── Generic field row ────────────────────────────────────────────── */
.pd-cc-pnl-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.pd-cc-pnl-field-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--at-color-card-foreground);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.pd-cc-pnl-field-hint {
    font-size: 10px;
    color: var(--at-color-card-foreground);
    line-height: 1.4;
}

/* ── Inputs / selects / textareas ─────────────────────────────────── */
.pd-cc-pnl-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    background: var(--at-color-input, #11111b);
    color: var(--at-color-card-foreground);
    border: 1px solid var(--at-color-border, #313244);
    border-radius: 5px;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}
.pd-cc-pnl-input:focus {
    border-color: var(--at-color-primary, #89b4fa);
    background: var(--at-color-background, #1e1e2e);
}
.pd-cc-pnl-input::placeholder {
    color: var(--at-color-card-foreground);
}
.pd-cc-pnl-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--at-color-primary, #89b4fa) 50%),
        linear-gradient(135deg, var(--at-color-primary, #89b4fa) 50%, transparent 50%);
    background-position:
        calc(100% - 14px) 50%,
        calc(100% - 9px) 50%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    padding-right: 28px;
    cursor: pointer;
}

/* ── Code editor area ─────────────────────────────────────────────── */
.pd-cc-pnl-code-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.pd-cc-pnl-code-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}
.pd-cc-pnl-code-toolbar-left {
    display: flex;
    align-items: center;
    gap: 6px;
}
.pd-cc-pnl-code-count {
    font-size: 10px;
    color: var(--at-color-card-foreground);
}
.pd-cc-pnl-code-area {
    width: 100%;
    box-sizing: border-box;
    min-height: 200px;
    max-height: 400px;
    resize: vertical;
    padding: 10px;
    background: var(--at-color-input, #11111b);
    color: var(--at-color-status-success-ink);
    border: 1px solid var(--at-color-border, #313244);
    border-radius: 5px;
    font-size: 12px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.15s;
    tab-size: 2;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}
.pd-cc-pnl-code-area:focus {
    border-color: var(--at-color-primary, #89b4fa);
}
.pd-cc-pnl-code-area::placeholder {
    color: var(--at-color-card-foreground);
}
.pd-cc-pnl-code-area.pd-cc-pnl-code-wrap-on {
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

/* ── Code action buttons (Apply, Format) ──────────────────────────── */
.pd-cc-pnl-code-actions {
    display: flex;
    gap: 6px;
}
.pd-cc-pnl-btn-apply {
    flex: 1 1 auto;
    background: var(--at-color-primary, #89b4fa);
    color: var(--at-color-card-foreground);
    border: 1px solid var(--at-color-border, #89b4fa);
    border-radius: 5px;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.pd-cc-pnl-btn-apply:hover {
    background: color-mix(in srgb, var(--at-color-primary, #89b4fa) 85%, var(--at-color-foreground, #cdd6f4));
    border-color: color-mix(in srgb, var(--at-color-primary, #89b4fa) 85%, var(--at-color-foreground, #cdd6f4));
}
.pd-cc-pnl-btn-secondary {
    flex: 0 0 auto;
    background: var(--at-color-secondary, #313244);
    color: var(--at-color-card-foreground);
    border: 1px solid var(--at-color-border, #45475a);
    border-radius: 5px;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.pd-cc-pnl-btn-secondary:hover {
    background: var(--at-color-muted, #45475a);
    border-color: var(--at-color-muted-foreground, #585b70);
}

/* ── Validation banner ────────────────────────────────────────────── */
.pd-cc-pnl-validation {
    display: none;
    padding: 8px 10px;
    border-radius: 5px;
    font-size: 11px;
    line-height: 1.4;
}
.pd-cc-pnl-validation.pd-cc-pnl-validation-ok {
    display: block;
    background: var(--at-color-card);
    color: var(--at-color-status-success-ink);
    border: 1px solid color-mix(in srgb, var(--at-color-status-success, #a6e3a1) 25%, transparent);
}
.pd-cc-pnl-validation.pd-cc-pnl-validation-warn {
    display: block;
    background: var(--at-color-muted);
    color: var(--at-color-status-warning-ink);
    border: 1px solid var(--at-color-border);
}
.pd-cc-pnl-validation.pd-cc-pnl-validation-err {
    display: block;
    background: var(--at-color-muted);
    color: var(--at-color-destructive-ink);
    border: 1px solid color-mix(in srgb, var(--at-color-destructive, #f38ba8) 25%, transparent);
}

/* ── Preview area ─────────────────────────────────────────────────── */
.pd-cc-pnl-preview-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.pd-cc-pnl-preview-frame {
    width: 100%;
    min-height: 120px;
    max-height: 300px;
    background: var(--at-color-card);
    border: 1px solid var(--at-color-border, #313244);
    border-radius: 5px;
    overflow: hidden;
}
.pd-cc-pnl-preview-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    color: var(--at-color-card-foreground);
    font-size: 11px;
    font-style: italic;
}

/* ── Checkboxes (custom styled — unchecked must be visible on dark bg) */
.pd-cc-pnl-checkrow {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    user-select: none;
    font-size: 11px;
    color: var(--at-color-card-foreground);
}
.pd-cc-pnl-checkrow input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
    background: var(--at-color-input, #11111b);
    border: 1px solid var(--at-color-primary, #89b4fa);
    border-radius: 3px;
    position: relative;
    flex: 0 0 auto;
    transition: background 0.15s, border-color 0.15s;
}
.pd-cc-pnl-checkrow input[type="checkbox"]:hover {
    border-color: var(--at-color-primary, #89b4fa);
}
.pd-cc-pnl-checkrow input[type="checkbox"]:checked {
    background: var(--at-color-primary, #89b4fa);
    border-color: var(--at-color-primary, #89b4fa);
}
.pd-cc-pnl-checkrow input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 0;
    width: 4px;
    height: 8px;
    border: solid var(--at-color-background, #1e1e2e);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ── Responsive visibility toggles ────────────────────────────────── */
.pd-cc-pnl-resp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}
.pd-cc-pnl-resp-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    background: var(--at-color-input, #11111b);
    border: 1px solid var(--at-color-border, #313244);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}
.pd-cc-pnl-resp-item:hover {
    border-color: var(--at-color-border, #45475a);
}
.pd-cc-pnl-resp-item.pd-cc-pnl-resp-active {
    border-color: var(--at-color-primary, #89b4fa);
    background: color-mix(in srgb, var(--at-color-primary, #89b4fa) 8%, transparent);
}
.pd-cc-pnl-resp-icon {
    font-size: 14px;
    color: var(--at-color-card-foreground);
}
.pd-cc-pnl-resp-item.pd-cc-pnl-resp-active .pd-cc-pnl-resp-icon {
    color: var(--at-color-primary);
}
.pd-cc-pnl-resp-label {
    font-size: 9px;
    color: var(--at-color-card-foreground);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ── Script warning banner ────────────────────────────────────────── */
.pd-cc-pnl-script-warn {
    display: none;
    padding: 8px 10px;
    background: var(--at-color-muted);
    color: var(--at-color-status-warning-ink);
    border: 1px solid var(--at-color-border);
    border-radius: 5px;
    font-size: 10px;
    line-height: 1.4;
    gap: 6px;
    align-items: flex-start;
}
.pd-cc-pnl-script-warn.pd-cc-pnl-script-warn-visible {
    display: flex;
}
.pd-cc-pnl-script-warn .fa {
    margin-top: 2px;
    flex: 0 0 auto;
}

/* ── Language mode indicator ──────────────────────────────────────── */
.pd-cc-pnl-lang-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--at-color-secondary, #313244);
    color: var(--at-color-card-foreground);
    border-radius: 3px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Word-wrap toggle button ──────────────────────────────────────── */
.pd-cc-pnl-wrap-btn {
    background: var(--at-color-secondary, #313244);
    color: var(--at-color-card-foreground);
    border: 1px solid var(--at-color-border, #45475a);
    border-radius: 4px;
    padding: 3px 7px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.15s;
}
.pd-cc-pnl-wrap-btn:hover {
    background: var(--at-color-muted, #45475a);
}
.pd-cc-pnl-wrap-btn.pd-cc-pnl-wrap-on {
    background: var(--at-color-primary, #89b4fa);
    color: var(--at-color-card-foreground);
    border-color: var(--at-color-primary, #89b4fa);
}

/* ── Advanced disclosure ──────────────────────────────────────────── */
.pd-cc-pnl-advanced {
    margin-top: 4px;
}
.pd-cc-pnl-advanced-summary {
    cursor: pointer;
    color: var(--at-color-card-foreground);
    font-size: 11px;
    padding: 6px 0;
    user-select: none;
    transition: color 0.15s;
}
.pd-cc-pnl-advanced-summary:hover {
    color: var(--at-color-card-foreground);
}
.pd-cc-pnl-advanced-summary .fa {
    margin-right: 5px;
    font-size: 10px;
}
.pd-cc-pnl-advanced-body {
    display: flex;
    flex-direction: column;
    gap: 11px;
    padding-top: 8px;
}
