/**
 * Schema Builder Styles
 * Webflow-inspired clean and modern design
 * 
 * @package CustomSchemaSchemafy
 * @since 2.0.0
 */

/* ============================================
   CSS VARIABLES
   Inherits the full token system from admin-v2.css.
   Only builder-specific overrides live here.
   ============================================ */
:root {
    /* Override transition to match builder's smoother easing */
    --schemafy-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   BUILDER CONTAINER
   ============================================ */
.schemafy-builder-container {
    max-width: 1400px;
    margin: 20px auto;
    background: #fff;
    border-radius: var(--schemafy-radius-lg);
    box-shadow: var(--schemafy-shadow-lg);
    overflow: hidden;
}

.schemafy-builder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    border-bottom: 1px solid var(--schemafy-gray-200);
    background: var(--schemafy-gray-50);
}

.schemafy-builder-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--schemafy-gray-900);
    margin: 0;
}

.schemafy-builder-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--schemafy-gray-600);
    cursor: pointer;
    padding: 8px;
    line-height: 1;
    transition: var(--schemafy-transition);
}

.schemafy-builder-close:hover {
    color: var(--schemafy-danger);
}

/* ============================================
   BUILDER LAYOUT (Sidebar + Main)
   ============================================ */
.schemafy-builder-body {
    display: flex;
    min-height: 600px;
}

.schemafy-builder-sidebar {
    width: 280px;
    background: var(--schemafy-gray-50);
    border-right: 1px solid var(--schemafy-gray-200);
    padding: 24px 0;
    flex-shrink: 0;
}

.schemafy-builder-main {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    max-height: 80vh;
}

/* ============================================
   SIDEBAR NAV TABS
   ============================================ */
.schemafy-builder-nav {
    list-style: none;
    margin: 0;
    padding: 0;
}

.schemafy-builder-nav-item {
    margin: 0;
}

.schemafy-builder-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    color: var(--schemafy-gray-700);
    text-decoration: none;
    font-weight: 500;
    font-size: 15px;
    transition: var(--schemafy-transition);
    border-left: 3px solid transparent;
}

.schemafy-builder-nav-link:hover {
    background: rgba(79, 110, 245, 0.05);
    color: var(--schemafy-primary);
}

.schemafy-builder-nav-link.active {
    background: rgba(79, 110, 245, 0.1);
    color: var(--schemafy-primary);
    border-left-color: var(--schemafy-primary);
    font-weight: 600;
}

.schemafy-builder-nav-icon {
    font-size: 18px;
}

/* ============================================
   SEO SCORE WIDGET
   ============================================ */
.schemafy-seo-score-widget {
    margin: 24px 0;
    padding: 0 24px;
}

.schemafy-seo-score-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--schemafy-gray-600);
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.schemafy-seo-score-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--schemafy-gray-900);
    margin-bottom: 8px;
}

.schemafy-seo-score-bar {
    height: 8px;
    background: var(--schemafy-gray-200);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.schemafy-seo-score-fill {
    height: 100%;
    transition: width 0.3s ease, background-color 0.3s ease;
    border-radius: 4px;
}

.schemafy-seo-score-fill[data-score="excellent"] {
    background: var(--schemafy-success);
}

.schemafy-seo-score-fill[data-score="good"] {
    background: var(--schemafy-primary);
}

.schemafy-seo-score-fill[data-score="needs-work"] {
    background: var(--schemafy-warning);
}

.schemafy-seo-score-fill[data-score="poor"] {
    background: var(--schemafy-danger);
}

.schemafy-seo-checklist {
    list-style: none;
    margin: 0;
    padding: 0;
}

.schemafy-seo-checklist-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    color: var(--schemafy-gray-700);
}

.schemafy-seo-checklist-item.valid {
    color: var(--schemafy-success);
}

.schemafy-seo-checklist-item.invalid {
    color: var(--schemafy-warning);
}

/* ============================================
   FORM FIELDS
   ============================================ */
.schemafy-field-group {
    margin-bottom: 24px;
}

.schemafy-field-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--schemafy-gray-900);
    margin-bottom: 8px;
}

.schemafy-required {
    color: var(--schemafy-danger);
}

.schemafy-field-help {
    font-size: 12px;
    color: var(--schemafy-gray-600);
    margin-top: 4px;
}

.schemafy-field-input,
.schemafy-field-textarea,
.schemafy-field-select {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    border: 1px solid var(--schemafy-gray-300);
    border-radius: var(--schemafy-radius);
    background: #fff;
    color: var(--schemafy-gray-900);
    font-family: inherit;
    transition: var(--schemafy-transition);
}

.schemafy-field-input:focus,
.schemafy-field-textarea:focus,
.schemafy-field-select:focus {
    outline: none;
    border-color: var(--schemafy-primary);
    box-shadow: 0 0 0 3px rgba(79, 110, 245, 0.1);
}

.schemafy-field-input.invalid,
.schemafy-field-textarea.invalid {
    border-color: var(--schemafy-danger);
}

.schemafy-field-input.valid,
.schemafy-field-textarea.valid {
    border-color: var(--schemafy-success);
}

.schemafy-field-textarea {
    resize: vertical;
    min-height: 100px;
}

/* Character Counter */
.schemafy-char-counter {
    font-size: 12px;
    color: var(--schemafy-gray-500);
    margin-top: 4px;
    text-align: right;
}

.schemafy-char-counter .current {
    font-weight: 600;
}

/* Validation Messages */
.schemafy-field-validation {
    margin-top: 6px;
    font-size: 13px;
    min-height: 18px;
}

.schemafy-field-validation.success {
    color: var(--schemafy-success);
}

.schemafy-field-validation.error {
    color: var(--schemafy-danger);
}

/* ============================================
   IMAGE UPLOAD FIELD
   ============================================ */
.schemafy-image-field {
    margin: 8px 0;
}

.schemafy-image-preview {
    position: relative;
    display: inline-block;
    margin-bottom: 12px;
}

.schemafy-image-preview img {
    max-width: 300px;
    max-height: 200px;
    border-radius: var(--schemafy-radius);
    border: 1px solid var(--schemafy-gray-300);
}

.schemafy-remove-image {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--schemafy-danger);
    color: #fff;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: var(--schemafy-transition);
}

.schemafy-remove-image:hover {
    background: #E03E3E;
}

/* ============================================
   BUTTONS
   ============================================ */
.schemafy-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: var(--schemafy-radius);
    cursor: pointer;
    transition: var(--schemafy-transition);
    text-decoration: none;
}

.schemafy-btn-primary {
    background: var(--schemafy-primary);
    color: #fff;
}

.schemafy-btn-primary:hover {
    background: var(--schemafy-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--schemafy-shadow);
}

.schemafy-btn-secondary {
    background: var(--schemafy-gray-200);
    color: var(--schemafy-gray-900);
}

.schemafy-btn-secondary:hover {
    background: var(--schemafy-gray-300);
}

.schemafy-btn-success {
    background: var(--schemafy-success);
    color: #fff;
}

.schemafy-btn-danger {
    background: var(--schemafy-danger);
    color: #fff;
}

/* ============================================
   GOOGLE PREVIEW
   ============================================ */
.schemafy-google-preview {
    background: #fff;
    border: 1px solid var(--schemafy-gray-300);
    border-radius: var(--schemafy-radius);
    padding: 20px;
    margin: 24px 0;
}

.schemafy-google-preview.desktop {
    max-width: 600px;
}

.schemafy-google-preview.mobile {
    max-width: 375px;
}

.preview-url {
    font-size: 13px;
    color: var(--schemafy-gray-700);
    margin-bottom: 4px;
}

.preview-title {
    font-size: 20px;
    color: #1A0DAB;
    margin: 0 0 8px 0;
    font-weight: 400;
}

.preview-description {
    font-size: 14px;
    color: var(--schemafy-gray-700);
    line-height: 1.5;
    margin: 0;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .schemafy-builder-body {
        flex-direction: column;
    }
    
    .schemafy-builder-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--schemafy-gray-200);
    }
    
    .schemafy-builder-nav {
        display: flex;
        overflow-x: auto;
    }
    
    .schemafy-builder-nav-link {
        border-left: none;
        border-bottom: 3px solid transparent;
    }
    
    .schemafy-builder-nav-link.active {
        border-left-color: transparent;
        border-bottom-color: var(--schemafy-primary);
    }
}

/* ============================================
   CATEGORY FILTER NAV
   ============================================ */
.schemafy-category-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 12px 14px 8px;
    border-bottom: 1px solid var(--schemafy-gray-200);
}

.schemafy-category-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--schemafy-gray-600);
    background: transparent;
    border: 1px solid var(--schemafy-gray-200);
    border-radius: 20px;
    cursor: pointer;
    transition: var(--schemafy-transition);
    white-space: nowrap;
}

.schemafy-category-btn:hover {
    background: var(--schemafy-gray-100);
    color: var(--schemafy-primary);
    border-color: var(--schemafy-primary);
}

.schemafy-category-btn.active {
    background: var(--schemafy-primary);
    color: #fff;
    border-color: var(--schemafy-primary);
    font-weight: 600;
}

.schemafy-category-icon {
    font-size: 13px;
    line-height: 1;
}

.schemafy-category-label {
    line-height: 1;
}

/* Schema type card hidden via category filter */
.schemafy-schema-type-card.schemafy-hidden-by-filter {
    display: none;
}

/* ============================================
   STEP PROGRESS INDICATOR
   Nota: evitamos .schemafy-step-num (ya definido en admin-v2.css como círculo
   autónomo). Usamos solo .schemafy-step-bubble como contenedor visual del número.
   El checkmark en estado "done" se genera con ::after para no depender de
   dashicons ni de display:none en SVG/iconos externos.
   ============================================ */
.schemafy-step-indicator {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    padding: 14px 20px 0;
    gap: 0;
    margin-bottom: 20px;
}

.schemafy-step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 76px;
}

/* The circle — contains only the plain-text number as innerHTML */
.schemafy-step-bubble {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: var(--schemafy-gray-300);
    color: var(--schemafy-gray-600);
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    line-height: 1;
    transition: var(--schemafy-transition);
    /* reset any admin-v2 global styles that target child spans */
    border: none;
    box-sizing: border-box;
}

/* override: ensure inner spans/text inside bubble have no rogue circle styles */
.schemafy-step-bubble * {
    background: none !important;
    border-radius: 0 !important;
    width: auto !important;
    height: auto !important;
    display: inline !important;
}

.schemafy-step-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--schemafy-gray-500);
    white-space: nowrap;
    transition: var(--schemafy-transition);
    text-align: center;
}

/* ── Active step ── */
.schemafy-step-item.active .schemafy-step-bubble {
    background: var(--schemafy-primary) !important;
    color: #fff !important;
    box-shadow: 0 0 0 4px rgba(79, 110, 245, 0.15);
}

.schemafy-step-item.active .schemafy-step-label {
    color: var(--schemafy-primary);
    font-weight: 700;
}

/* ── Done step: swap number for ✓ via pseudo-element ── */
.schemafy-step-item.done .schemafy-step-bubble {
    background: var(--schemafy-success) !important;
    color: transparent !important;  /* hide the number */
    font-size: 0;
}

.schemafy-step-item.done .schemafy-step-bubble::after {
    content: '✓';
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.schemafy-step-item.done .schemafy-step-label {
    color: var(--schemafy-success);
}

/* ── Connector line between steps ── */
.schemafy-step-connector {
    flex: 1;
    height: 2px;
    background: var(--schemafy-gray-200);
    margin-bottom: 22px;
    transition: background 0.3s ease;
    min-width: 16px;
}

.schemafy-step-connector.done {
    background: var(--schemafy-success);
}

/* ============================================
   PLACEHOLDER TIPS (EMPTY STATE)
   ============================================ */
.schemafy-placeholder-tips {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
    text-align: left;
    max-width: 300px;
}

.schemafy-placeholder-tip {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    background: var(--schemafy-gray-50);
    border: 1px solid var(--schemafy-gray-200);
    border-radius: var(--schemafy-radius);
    font-size: 13px;
    color: var(--schemafy-gray-700);
    line-height: 1.4;
}

.schemafy-placeholder-tip-icon {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* ============================================
   FRIENDLY PREVIEW CARD
   ============================================ */
.schemafy-preview-friendly {
    padding: 20px 16px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    border-bottom: 1px solid var(--schemafy-gray-200);
}

.schemafy-preview-friendly-icon {
    font-size: 32px;
    line-height: 1;
}

.schemafy-preview-friendly-hint {
    font-size: 13px;
    color: var(--schemafy-gray-500);
    margin: 0;
    line-height: 1.5;
}

/* Status rows (type / page / fields) */
.schemafy-preview-friendly-rows {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.schemafy-friendly-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 10px;
    background: var(--schemafy-gray-50);
    border-radius: 6px;
    font-size: 12px;
    gap: 8px;
}

.schemafy-friendly-label {
    font-weight: 600;
    color: var(--schemafy-gray-600);
    flex-shrink: 0;
}

.schemafy-friendly-value {
    color: var(--schemafy-gray-900);
    font-weight: 500;
    text-align: right;
    word-break: break-all;
}

.schemafy-friendly-value-url {
    font-size: 11px;
    color: var(--schemafy-primary);
}

/* Toggle technical code button */
.schemafy-toggle-json-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--schemafy-gray-600);
    background: var(--schemafy-gray-100);
    border: 1px solid var(--schemafy-gray-200);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--schemafy-transition);
    width: 100%;
    justify-content: center;
}

.schemafy-toggle-json-btn:hover {
    background: var(--schemafy-gray-200);
    color: var(--schemafy-gray-900);
}

.schemafy-toggle-json-btn .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.schemafy-toggle-arrow {
    font-size: 10px;
    margin-left: auto;
    transition: transform 0.2s ease;
}

/* JSON panel collapsed by default */
.schemafy-preview-body--collapsed {
    display: none;
}

/* ============================================
   LOCK OVERLAY — friendly upgrade badge
   ============================================ */
.schemafy-lock-overlay {
    position: absolute;
    top: 4px;
    right: 4px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fed7aa;
    border-radius: 10px;
    line-height: 1.4;
    pointer-events: none;
}

/* ============================================
   @TYPE INDICATOR — multi-type schema badge
   ============================================ */
.schemafy-type-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 5px 10px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    font-size: 12px;
    color: #1e40af;
}

.schemafy-type-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 11px;
}

.schemafy-type-primary {
    background: #dbeafe;
    color: #1d4ed8;
}

.schemafy-type-secondary {
    background: #e0e7ff;
    color: #4338ca;
}

.schemafy-type-note {
    color: #6b7280;
    font-size: 11px;
}

/* ============================================
   EXTRA FIELDS — additional JSON accordion
   ============================================ */
.schemafy-extra-fields-section {
    margin-top: 24px;
    border-top: 2px dashed #e5e7eb;
    padding-top: 16px;
}

.schemafy-extra-fields-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.schemafy-extra-fields-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.schemafy-extra-icon {
    font-size: 14px;
}

.schemafy-extra-arrow {
    margin-left: 4px;
    font-size: 10px;
    color: #9ca3af;
    transition: transform 0.2s;
}

.schemafy-extra-fields-content {
    margin-top: 10px;
}

.schemafy-extra-fields-textarea {
    width: 100%;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 12px;
    line-height: 1.6;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #1e1e2e;
    color: #cdd6f4;
    resize: vertical;
    box-sizing: border-box;
}

.schemafy-extra-fields-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

/* ============================================
   RESPONSIVE — REDESIGNED COMPONENTS
   ============================================ */
@media (max-width: 1024px) {
    .schemafy-step-indicator {
        padding: 10px 12px 0;
    }

    .schemafy-step-label {
        font-size: 10px;
    }

    .schemafy-category-nav {
        padding: 8px 10px;
    }

    .schemafy-placeholder-tips {
        max-width: 100%;
    }
}
}
