/**
 * SP Toolkit Decision Tree Styles
 * UPDATED: Enhanced Gutenberg block support with proper layout handling
 */

 :root {
    --sp-primary-color: #5C2163;
    --sp-primary-color-hover: #7f2a89;
	--sp-option-button-a-init: #eb7100;
    --sp-option-button-a-hover: #f77600;
    --sp-option-button-b-init: #656183;
    --sp-option-button-b-hover: #241e4e;
    --sp-option-button-c-init: #8d6492;
    --sp-option-button-c-hover: #5c2163;

 }

/* Main Wrapper */
.sp-toolkit-wrapper {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
}

/* Journey Container */
.sp-toolkit-journey {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Journey Steps */
.sp-journey-step {
    opacity: 0;
    animation: fadeIn 0.5s ease-in-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Question Container */
.sp-question-container {
    padding: 30px;
    background: #ffffff;
    border-radius: 6px;
}

.sp-question-text h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.5em;
    color: #333;
}

.sp-question-options {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

/* Option Buttons */
.sp-option-button {
    flex: 1;
    min-width: 200px;
    padding: 15px 30px;
    font-size: 1.1em;
    font-weight: 600;
    color: #ffffff;
    background: var(--sp-option-button-a-init);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.sp-option-button:hover {
    background: var(--sp-option-button-a-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.sp-option-button:active {
    transform: translateY(0);
}

.sp-option-button.option-b {
    background: var(--sp-option-button-b-init);
}

.sp-option-button.option-b:hover {
    background: var(--sp-option-button-b-hover);
}

.sp-option-button.option-c {
    background: var(--sp-option-button-c-init);
}

.sp-option-button.option-c:hover {
    background: var(--sp-option-button-c-hover);
}

/* Selected Button State */
.sp-option-button.selected {
    background: var(--sp-primary-color);
    color: #fff;
}

.sp-option-button.selected::after {
    content: "✓";
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2em;
    font-weight: bold;
}

.sp-option-button.selected:hover {
    background: #333;
    transform: none;
    box-shadow: 0 0 0 3px rgba(51, 51, 51, 0.3);
}

/* Dimmed (Not Selected) Button State */
.sp-option-button.dimmed {
    opacity: 0.4;
    position: relative;
}

.sp-option-button.dimmed::before {
    content: "Click to change path";
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75em;
    color: #666;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.sp-option-button.dimmed:hover {
    opacity: 0.7;
}

.sp-option-button.dimmed:hover::before {
    opacity: 1;
}

/* Content Step (Loaded Post) */
.sp-content-step {
    padding: 30px;
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sp-loaded-post {
    line-height: 1.6;
}

.sp-loaded-title {
    margin: 0 0 1em 0;
    font-size: 1.8em;
    color: var(--sp-primary-color);
    border-bottom: 4px solid var(--sp-primary-color);
    padding-bottom: 10px;
}

.sp-loaded-body {
    color: #333;
    margin-bottom: 30px;
}

.sp-loaded-body p {
    margin-bottom: 1em;
}

.sp-loaded-body h1,
.sp-loaded-body h2,
.sp-loaded-body h3,
.sp-loaded-body h4 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    color: #333;
}

.sp-loaded-body ul,
.sp-loaded-body ol {
    margin-left: 20px;
    margin-bottom: 1em;
}

.sp-loaded-body img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    margin: 1em 0;
}

/* ==========================================
   GUTENBERG BLOCK SUPPORT - ESSENTIAL FIXES
   ========================================== */

/* Kadence Accordion Blocks - Critical for functionality */
.sp-loaded-body .kt-accordion-panel {
    overflow: hidden;
    transition: all 0.3s ease;
}

.sp-loaded-body .kt-accordion-panel-hidden {
    display: none !important;
}

.sp-loaded-body .kt-accordion-panel:not(.kt-accordion-panel-hidden) {
    display: block !important;
}

.sp-loaded-body .kt-blocks-accordion-header {
    cursor: pointer;
    user-select: none;
}

/* Oxygen Builder Blocks Support */
.sp-loaded-body [class*="oxy-"] {
    box-sizing: border-box;
}

/* Oxygen Tabs */
.sp-loaded-body .oxy-tabs {
    display: block;
}

.sp-loaded-body .oxy-tab-content {
    display: none;
}

.sp-loaded-body .oxy-tab-content.oxy-tab-content-active {
    display: block !important;
}

/* Oxygen Accordions */
.sp-loaded-body .oxy-pro-accordion_content,
.sp-loaded-body .oxy-accordion-content {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sp-loaded-body .oxy-pro-accordion_tab,
.sp-loaded-body .oxy-accordion-title {
    cursor: pointer;
    user-select: none;
}

/* Oxygen Toggles */
.sp-loaded-body .oxy-toggle-content {
    display: none;
    overflow: hidden;
}

.sp-loaded-body .oxy-toggle-active .oxy-toggle-content {
    display: block !important;
}

/* Oxygen Modals */
.sp-loaded-body .oxy-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.sp-loaded-body .oxy-modal-active {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* Oxygen Link Wrappers */
.sp-loaded-body .ct-link-text {
    cursor: pointer;
}

/* Oxygen Sliders/Carousels */
.sp-loaded-body .oxy-slider,
.sp-loaded-body [class*="oxy-carousel"] {
    position: relative;
    overflow: hidden;
}

/* Columns Block - Critical for Layout */
.sp-loaded-body .wp-block-columns {
    display: flex !important;
    flex-wrap: wrap;
    gap: 2em;
    margin-bottom: 1.5em;
}

.sp-loaded-body .wp-block-column {
    flex: 1;
    min-width: 0; /* Prevents overflow */
    flex-basis: 0;
    flex-grow: 1;
}

/* 2 Column Layout */
.sp-loaded-body .wp-block-columns.has-2-columns > .wp-block-column {
    flex-basis: calc(50% - 1em);
}

/* 3 Column Layout */
.sp-loaded-body .wp-block-columns.has-3-columns > .wp-block-column {
    flex-basis: calc(33.33% - 1.34em);
}

/* 4 Column Layout */
.sp-loaded-body .wp-block-columns.has-4-columns > .wp-block-column {
    flex-basis: calc(25% - 1.5em);
}

/* Responsive Columns */
@media (max-width: 781px) {
    .sp-loaded-body .wp-block-columns {
        flex-direction: column !important;
    }
    
    .sp-loaded-body .wp-block-column {
        flex-basis: 100% !important;
    }
}

/* Group Block */
.sp-loaded-body .wp-block-group {
    margin-bottom: 1.5em;
}

.sp-loaded-body .wp-block-group__inner-container {
    padding: 1.5em;
}

/* Buttons Block */
.sp-loaded-body .wp-block-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
    margin-bottom: 1em;
}

.sp-loaded-body .wp-block-button {
    display: inline-block;
}

.sp-loaded-body .wp-block-button__link {
    display: inline-block;
    padding: 0.75em 1.5em;
    text-decoration: none;
    border-radius: 5px;
    background: var(--primary-color);
    color: #fff !important;
    transition: background 0.3s ease;
}

.sp-loaded-body .wp-block-button__link:hover {
    background: var(--sp-primary-color-hover);
}

/* Cover Block */
.sp-loaded-body .wp-block-cover {
    position: relative;
    min-height: 430px;
    padding: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
}

.sp-loaded-body .wp-block-cover__inner-container {
    width: 100%;
    z-index: 1;
    color: #fff;
}

/* Gallery Block */
.sp-loaded-body .wp-block-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 1em;
    list-style: none;
    padding: 0;
    margin-bottom: 1.5em;
}

.sp-loaded-body .wp-block-gallery .wp-block-image {
    flex: 1;
    min-width: 200px;
}

.sp-loaded-body .wp-block-gallery.columns-2 .wp-block-image {
    flex-basis: calc(50% - 0.5em);
}

.sp-loaded-body .wp-block-gallery.columns-3 .wp-block-image {
    flex-basis: calc(33.33% - 0.67em);
}

.sp-loaded-body .wp-block-gallery.columns-4 .wp-block-image {
    flex-basis: calc(25% - 0.75em);
}

/* Image Block */
.sp-loaded-body .wp-block-image {
    margin-bottom: 1.5em;
}

.sp-loaded-body .wp-block-image img {
    display: block;
    max-width: 100%;
    height: auto;
}

.sp-loaded-body .wp-block-image.alignleft {
    float: left;
    margin-right: 1em;
    margin-bottom: 1em;
}

.sp-loaded-body .wp-block-image.alignright {
    float: right;
    margin-left: 1em;
    margin-bottom: 1em;
}

.sp-loaded-body .wp-block-image.aligncenter {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

/* Media & Text Block */
.sp-loaded-body .wp-block-media-text {
    display: grid;
    grid-template-columns: 50% 1fr;
    gap: 1.5em;
    margin-bottom: 1.5em;
    align-items: center;
}

.sp-loaded-body .wp-block-media-text.has-media-on-the-right {
    grid-template-columns: 1fr 50%;
}

.sp-loaded-body .wp-block-media-text__media {
    margin: 0;
}

.sp-loaded-body .wp-block-media-text__content {
    padding: 0 1.5em;
}

@media (max-width: 600px) {
    .sp-loaded-body .wp-block-media-text {
        grid-template-columns: 1fr !important;
    }
}

/* Separator Block */
.sp-loaded-body .wp-block-separator {
    border: none;
    border-top: 1px solid #ccc;
    margin: 2em auto;
    max-width: 100px;
}

.sp-loaded-body .wp-block-separator.is-style-wide {
    max-width: 100%;
}

/* Spacer Block */
.sp-loaded-body .wp-block-spacer {
    clear: both;
}

/* Quote Block */
.sp-loaded-body .wp-block-quote {
    margin: 1.5em 0;
    padding-left: 1.5em;
    border-left: 4px solid #0c99db;
    font-style: italic;
}

.sp-loaded-body .wp-block-quote cite {
    display: block;
    margin-top: 0.5em;
    font-style: normal;
    font-size: 0.9em;
    color: #666;
}

/* Pullquote Block */
.sp-loaded-body .wp-block-pullquote {
    margin: 2em 0;
    padding: 2em;
    border-top: 4px solid #0c99db;
    border-bottom: 4px solid #0c99db;
    text-align: center;
}

.sp-loaded-body .wp-block-pullquote blockquote {
    margin: 0;
    font-size: 1.5em;
    font-style: italic;
}

/* Table Block */
.sp-loaded-body .wp-block-table {
    margin-bottom: 1.5em;
    overflow-x: auto;
}

.sp-loaded-body .wp-block-table table {
    width: 100%;
    border-collapse: collapse;
}

.sp-loaded-body .wp-block-table td,
.sp-loaded-body .wp-block-table th {
    padding: 0.5em;
    border: 1px solid #ddd;
}

.sp-loaded-body .wp-block-table th {
    font-weight: bold;
    background: #f5f5f5;
}

/* Embed Blocks */
.sp-loaded-body .wp-block-embed {
    margin-bottom: 1.5em;
}

.sp-loaded-body .wp-block-embed iframe {
    max-width: 100%;
}

/* Alignments */
.sp-loaded-body .alignleft {
    float: left;
    margin-right: 1em;
    margin-bottom: 1em;
}

.sp-loaded-body .alignright {
    float: right;
    margin-left: 1em;
    margin-bottom: 1em;
}

.sp-loaded-body .aligncenter {
    display: block;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.sp-loaded-body .alignwide {
    max-width: 100%;
}

.sp-loaded-body .alignfull {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
}

/* Clear floats */
.sp-loaded-body::after,
.sp-loaded-body .wp-block-group::after,
.sp-loaded-body .entry-content::after {
    content: "";
    display: table;
    clear: both;
}

/* ==========================================
   END GUTENBERG BLOCK SUPPORT
   ========================================== */

/* Questions within loaded posts */
.sp-post-questions {
    margin-top: 30px;
    padding-top: 30px;
}

.sp-post-questions .sp-question-container {
    background: #fff;
}

.sp-post-questions .sp-question-text h3 {
    color: #666;
}

.sp-post-questions .sp-question-text h3::before {
    content: "Continue: ";
    font-size: 0.8em;
    color: #666;
    font-weight: normal;
    display: block;
    margin-bottom: 5px;
}

/* Loading State */
.sp-loading-step {
    padding: 30px;
    background: #f9f9f9;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
}

.sp-loading-content {
    text-align: center;
    padding: 40px 20px;
    font-size: 1.2em;
    color: #666;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Error State */
.sp-error {
    text-align: center;
    padding: 20px;
    color: #d63638;
    font-weight: 600;
}

/* Breadcrumb Trail */
.sp-toolkit-breadcrumb {
    background: #f9f9f9;
    padding: 15px 20px;
    border-radius: 5px;
    margin-bottom: 30px;
    border-left: 4px solid #0c99db;
}

.sp-toolkit-breadcrumb h4 {
    margin: 0 0 10px 0;
    font-size: 1em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sp-breadcrumb-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.sp-breadcrumb-list li {
    display: flex;
    align-items: center;
}

.sp-breadcrumb-list li:not(:last-child)::after {
    content: "→";
    margin-left: 10px;
    color: #999;
    font-weight: bold;
}

.sp-breadcrumb-list li a {
    color: #0c99db;
    text-decoration: none;
    transition: color 0.3s ease;
}

.sp-breadcrumb-list li a:hover {
    color: #005177;
    text-decoration: underline;
}

.sp-breadcrumb-list li.current strong {
    color: #333;
    font-weight: 600;
}

/* Referrer Info */
.sp-toolkit-referrer {
    background: #e8f5e9;
    padding: 10px 15px;
    border-radius: 5px;
    border-left: 3px solid #46b450;
    margin-bottom: 20px;
}

.sp-toolkit-referrer a {
    color: #2d8633;
    font-weight: 600;
    text-decoration: none;
}

.sp-toolkit-referrer a:hover {
    text-decoration: underline;
}

/* Reset Button */
.sp-toolkit-reset-form {
    margin: 5px 0;
}

.sp-toolkit-reset-button {
    padding: 10px 20px;
    font-size: 16px;
    color: #222222;
    background: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: max-content;
    text-transform: uppercase;
    font-family: 'League Spartan';
    font-weight: 700;
    line-height: 1;
}

.sp-toolkit-reset-button:hover {
    background: #bdbbca;
    color: #222222;
}

/* Progress Indicator (optional) */
.sp-toolkit-progress {
    background: #f0f0f0;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
}

.sp-toolkit-progress-bar {
    width: 100%;
    height: 10px;
    background: #ddd;
    border-radius: 5px;
    overflow: hidden;
    margin-top: 10px;
}

.sp-toolkit-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0c99db, #46b450);
    transition: width 0.5s ease;
}

/* Print Styles */
@media print {
    .sp-toolkit-wrapper {
        max-width: 100%;
        padding: 0;
    }
    
    .sp-journey-step {
        page-break-inside: avoid;
        margin-bottom: 20px;
    }
    
    .sp-option-button {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    
    .sp-option-button.dimmed {
        display: none;
    }
    
    .sp-toolkit-reset-button,
    .sp-toolkit-reset-form {
        display: none;
    }
    
    .sp-option-button.dimmed::before {
        display: none;
    }
    
    .sp-post-questions {
        border-top: 2px solid #ccc;
    }
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .sp-question-options {
        flex-direction: column;
        position: relative;
        padding-bottom: 30px;
    }
    
    .sp-option-button {
        min-width: 100%;
    }
    
    .sp-option-button.dimmed::before {
        bottom: -30px;
        font-size: 0.85em;
    }
    
    .sp-breadcrumb-list {
        flex-direction: column;
        gap: 5px;
    }
    
    .sp-breadcrumb-list li:not(:last-child)::after {
        content: "↓";
        margin-left: 0;
        margin-top: 5px;
    }
    
    .sp-question-container,
    .sp-content-step,
    .sp-loading-step {
        padding: 20px;
    }
    
    .sp-loaded-title {
        font-size: 1.5em;
    }
    
    .sp-post-questions {
        margin-top: 20px;
        padding-top: 20px;
    }
}
