/**
 * File: framework/gutenberg/assets/editor.css
 * Conturalis Gutenberg Editor Styles
 *
 * Specific styles for the Conturalis Gutenberg integration.
 * Includes custom UI tweaks, component presets, and the Shortcode Generator UI.
 *
 * @package Conturalis
 * @subpackage Framework
 */

/* --- 0.0 Admin UI Tokens --- */
/* 
 * We cannot use our standard admin tokens natively in Gutenberg because the 
 * editor iframe strictly encapsulates styles and prevents inheritance from the 
 * WordPress dashboard :root. Therefore, we hardcode them here scoped to the 
 * editor wrappers to ensure consistent UI for badges, tools, and presets.
 */
:root, .editor-styles-wrapper {
    --cts-admin-color-success-bg:     #f0fdf4;
    --cts-admin-color-success-border: #bbf7d0;
    --cts-admin-color-success-text:   #166534;

    --cts-admin-color-warning-bg:     #fffbeb;
    --cts-admin-color-warning-border: #fde68a;
    --cts-admin-color-warning-text:   #92400e;

    --cts-admin-color-danger-bg:      #fef2f2;
    --cts-admin-color-danger-border:  #fecaca;
    --cts-admin-color-danger-text:    #991b1b;

    --cts-admin-color-info-bg:        #e3f2fd;
    --cts-admin-color-info-border:    #bbdefb;
    --cts-admin-color-info-text:      #1565C0;

    --cts-admin-color-accent-bg:      #f3e5f5;
    --cts-admin-color-accent-border:  #e1bee7;
    --cts-admin-color-accent-text:    #7B1FA2;

    --cts-admin-color-dark-bg:        #0f172a;  /* Slate-900 */
    --cts-admin-color-dark-surface:   #1e293b;  /* Slate-800 */
    --cts-admin-color-dark-border:    #334155;  /* Slate-700 */
    --cts-admin-color-dark-text:      #e2e8f0;  /* Slate-200 */
    --cts-admin-color-dark-muted:     #94a3b8;  /* Slate-400 */
}

/* --- 1.0 Custom Icons --- */

.dashicons-cts-cat-logo, 
.dashicons-cts-shortcode-logo {
    background-color: currentColor !important;
    -webkit-mask-repeat: no-repeat !important; 
    mask-repeat: no-repeat !important;
    -webkit-mask-position: center !important; 
    mask-position: center !important;
    -webkit-mask-size: contain !important; 
    mask-size: contain !important;
    width: 20px !important; 
    height: 20px !important;
}

.dashicons-cts-cat-logo { 
    -webkit-mask-image: url('../../assets/media/Logo-Icon_SVG.svg') !important; 
    mask-image: url('../../assets/media/Logo-Icon_SVG.svg') !important; 
}

.dashicons-cts-shortcode-logo { 
    -webkit-mask-image: url('../../assets/media/Conturalis-shortcode-logo.svg') !important; 
    mask-image: url('../../assets/media/Conturalis-shortcode-logo.svg') !important; 
}

.dashicons-cts-cat-logo::before, 
.dashicons-cts-shortcode-logo::before { 
    display: none !important; 
}

/* --- 2.0 Preset Editor UI Tweaks --- */

/* Hide draft button but keep Publish/Update visible on Preset Canvas */
body.post-type-cts_component_preset .components-button.editor-post-save-draft {
    display: none !important;
}

/* Hide the native Gutenberg title block on the canvas to prevent focus hijacking.
   Users can still rename the preset via the top bar or document settings menu. */
body.post-type-cts_component_preset .edit-post-visual-editor__post-title-wrapper {
    display: none !important;
}

/* Add spacing to the top of the canvas so the component isn't cramped against the toolbar */
body.post-type-cts_component_preset .is-root-container,
body.post-type-cts_component_preset .block-editor-block-list__layout {
    padding-top: 48px !important;
}

/* --- 3.0 Style Preset Warning & Dimming --- */

.cts-style-warning-msg {
    display: none;
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid #ffeeba;
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 4px;
    font-size: 13px;
}

/* Activate CSS when React adds body class */
body.cts-is-style-preset .cts-style-warning-msg {
    display: block !important;
}

/* --- 4.0 Info Notices --- */

.cts-info-notice-msg {
    display: block;
    background: #e3f2fd;
    color: #1565C0;
    border-left: 4px solid #bbdefb;
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.4;
}

.cts-inspector-notice-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cts-inspector-notice-row-1 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cts-inspector-notice-row-2 {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

/* --- 5.0 Shortcode Preview Styles (Dev Tools) --- */

.cts-sc-container {
    margin-top: 15px;
    margin-bottom: 5px;
    position: relative;
}

.cts-sc-btn {
    width: 100%;
    display: block;
    text-align: center;
}

.cts-sc-results-area {
    margin-top: 15px;
}

.cts-sc-item {
    position: relative;
    margin-bottom: 16px;
}

.cts-sc-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #8c8f94;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.cts-sc-box {
    background: #26292c;
    color: #81d29d;
    border: 1px solid #404349;
    padding: 10px;
    border-radius: 4px;
    font-family: 'Roboto Mono', monospace;
    font-size: 11px;
    line-height: 1.4;
    word-break: break-all;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 36px;
    user-select: none;
    margin: 0;
}

.cts-sc-box:hover {
    background: #2e3236;
    border-color: #556068;
}

.cts-sc-box:active {
    background: #202326;
}

.cts-sc-toast {
    position: absolute;
    top: -20px;
    right: 0;
    background: #46b450;
    color: #fff;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transform: translateY(5px);
    transition: all 0.2s ease;
    z-index: 10;
}

.cts-sc-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* --- 6.0 Preview Warning Banners --- */

.cts-preview-warning-banner {
    background: var(--cts-admin-color-warning-bg);
    color: var(--cts-admin-color-warning-text);
    border-left: 4px solid var(--cts-admin-color-warning-border);
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.4;
}

.cts-preview-warning-banner strong {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}