/**
 * Grid Layout Widget Styles
 * Purpose: Styles for configurable grid layout with header and 3 item types
 * 
 * Color variables from Figma Color Scheme 5:
 * - Background: --_primitives---colors--neutral-dark (#544c50)
 * - Card background: --_primitives---colors--neutral (#857f82)
 * - Text: --e-global-color-text (white in scheme 5)
 * - Border: --_primitives---opacity--neutral-darkest-15
 */

/* =============================================
   BASE LAYOUT
   ============================================= */
.wb-grid-layout {
    display: block;
    width: 100%;
}

.wb-grid-layout__component {
    display: flex;
    flex-direction: column;
    margin-left: auto;
    margin-right: auto;
    padding-left: 5%;
    padding-right: 5%;
}

.wb-grid-layout__component > *:not(:last-child) {
    margin-bottom: var(--section-padding-padding-section-medium, 5rem);
}

/* =============================================
   HEADER SECTION
   ============================================= */
.wb-grid-layout__header {
    display: block;
}

.wb-grid-layout__header-content {
    display: flex;
    flex-direction: column;
    max-width: var(--max-width-max-width-large, 50rem);
    /* Default: left-aligned block */
    margin-left: 0;
    margin-right: auto;
}

/* Center: both margins auto to center the block */
.wb-grid-layout-ha-center .wb-grid-layout__header-content {
    margin-left: auto;
}

/* Right: push block to the right */
.wb-grid-layout-ha-right .wb-grid-layout__header-content {
    margin-left: auto;
    margin-right: 0;
}

.wb-grid-layout__header .button-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.wb-grid-layout__header .button-group > *:not(:last-child) {
    margin-right: var(--wb-spacing-sm, 1rem);
}

/* =============================================
   HEADER SPLIT LAYOUT (two columns via prefix_class)
   ============================================= */
.wb-grid-layout-hl-split .wb-grid-layout__header-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: var(--section-padding-padding-section-medium, 5rem);
    align-items: start;
    max-width: none;
}

.wb-grid-layout-hl-split .wb-grid-layout__header-content > .wb-grid-layout__tagline,
.wb-grid-layout-hl-split .wb-grid-layout__header-content > .wb-grid-layout__title {
    grid-column: 1;
}

.wb-grid-layout-hl-split .wb-grid-layout__header-content > .wb-grid-layout__description,
.wb-grid-layout-hl-split .wb-grid-layout__header-content > .button-group {
    grid-column: 2;
}

/* =============================================
   GRID CONTAINER
   ============================================= */
.wb-grid-layout__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--wb-spacing-lg, 2rem); /* Mantener gap: CSS Grid estándar */
}

/* =============================================
   GRID ITEMS - BASE
   ============================================= */
.wb-grid-layout__item {
    display: flex;
    flex-direction: column;
    background-color: var(--_primitives---colors--neutral, #857f82);
    border-radius: var(--radius-small);
    overflow: hidden;
    min-height: 0;
    min-width: 0;
}

/* Grid span utilities */
.wb-grid-layout__item--col-2 {
    grid-column: span 2;
}

.wb-grid-layout__item--col-3 {
    grid-column: span 3;
}

.wb-grid-layout__item--row-2 {
    grid-row: span 2;
}

.wb-grid-layout__item--row-3 {
    grid-row: span 3;
}

/* =============================================
   CARD TYPE
   ============================================= */
.wb-grid-layout__item--card {
    display: flex;
    flex-direction: column;
}

/* Card with image - image at top */
.wb-grid-layout__card-image-wrapper {
    position: relative;
    width: 100%;
    flex-shrink: 0;
}

/* For cards spanning 2 rows, image takes more space */
.wb-grid-layout__item--row-2 .wb-grid-layout__card-image-wrapper {
    min-height: 15rem;
}

.wb-grid-layout__card-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Card content area */
.wb-grid-layout__card-content {
    display: flex;
    flex-direction: column;
    padding: var(--wb-spacing-md, 1.5rem);
    flex: 1;
}

.wb-grid-layout__card-content > *:not(:last-child) {
    margin-bottom: var(--wb-spacing-sm, 1rem);
}

/* Cards with more space (row span 2) */
.wb-grid-layout__item--row-2 .wb-grid-layout__card-content {
    padding: var(--wb-spacing-lg, 2rem) var(--wb-spacing-md, 1.5rem);
}

.wb-grid-layout__item--row-2 .wb-grid-layout__card-content > *:not(:last-child) {
    margin-bottom: var(--wb-spacing-md, 2rem);
}

/* Card icon */
.wb-grid-layout__card-icon {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: var(--e-global-typography-text-font-size, 1.5rem);
    color: var(--e-global-color-text, #ffffff);
}

.wb-grid-layout__card-icon i,
.wb-grid-layout__card-icon svg {
    width: 1.5rem;
    height: 1.5rem;
}

/* Card tagline */
.wb-grid-layout .wb-grid-layout__card-tagline {
    color: var(--e-global-color-text, #ffffff);
}

/* Card title */
.wb-grid-layout .wb-grid-layout__card-title {
    color: var(--e-global-color-text, #ffffff);
    margin: 0;
}

/* Card description */
.wb-grid-layout .wb-grid-layout__card-description {
    color: var(--e-global-color-text, #ffffff);
    margin: 0;
}

/* Card buttons */
.wb-grid-layout__card-buttons {
    display: flex;
    flex-wrap: wrap;
}

/* Cards without col- span: smaller spacing */
.wb-grid-layout__item--card:not([class*="--col-"]) .wb-grid-layout__card-title {
    margin-bottom: var(--spacing-8x) !important;
}

.wb-grid-layout__item--card:not([class*="--col-"]) .wb-grid-layout__card-buttons {
    margin-top: var(--spacing-12x) !important;
}

.wb-grid-layout__card-buttons > *:not(:last-child) {
    margin-right: var(--wb-spacing-sm, 1rem);
}

.wb-grid-layout__btn {
    /* Buttons inherit from .button base class */
}

/* =============================================
   IMAGE TYPE
   ============================================= */
.wb-grid-layout__item--image {
    padding: 0;
}

.wb-grid-layout__image-wrapper {
    width: 100%;
    height: 100%;
    min-height: 15rem;
}

.wb-grid-layout__image-link {
    display: block;
    width: 100%;
    height: 100%;
}

.wb-grid-layout__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* =============================================
   COUNTER TYPE
   ============================================= */
.wb-grid-layout__item--counter {
    display: flex;
    flex-direction: column;
}

.wb-grid-layout__counter-content {
    display: flex;
    flex-direction: column;
    padding: var(--wb-spacing-md, 1.5rem);
    flex: 1;
}

.wb-grid-layout__counter-content > *:not(:last-child) {
    margin-bottom: var(--wb-spacing-xs, 0.5rem);
}

/* Counter title */
.wb-grid-layout .wb-grid-layout__counter-title {
    color: var(--e-global-color-text, #ffffff);
    margin: 0;
}

/* Counter value container */
.wb-grid-layout__counter-value {
    display: flex;
    align-items: baseline;
    gap: 0;
    color: var(--e-global-color-accent, #df006e);
    font-size: var(--e-global-typography-accent-font-size, 3.5rem);
    font-weight: var(--e-global-typography-accent-font-weight, 400);
    line-height: 1.2;
}

.wb-grid-layout__counter-prefix,
.wb-grid-layout__counter-suffix {
    font-size: inherit;
    color: inherit;
}

.wb-grid-layout__counter-number {
    font-size: inherit;
    color: inherit;
    font-variant-numeric: tabular-nums;
}

/* Counter divider */
.wb-grid-layout__counter-divider {
    width: 100%;
    height: 1px;
    background-color: var(--_primitives---opacity--white-15, rgba(255, 255, 255, 0.15));
}

/* Counter description */
.wb-grid-layout .wb-grid-layout__counter-description {
    color: var(--e-global-color-text, #ffffff);
    margin: 0;
}

/* =============================================
   RESPONSIVE - TABLET
   ============================================= */
@media (max-width: 991px) {
    /* Header alignment — tablet overrides (prefix_class adds -tablet suffix) */
    .wb-grid-layout-ha-left-tablet .wb-grid-layout__header-content {
        margin-left: 0;
        margin-right: auto;
    }

    .wb-grid-layout-ha-center-tablet .wb-grid-layout__header-content {
        margin-left: auto;
        margin-right: auto;
    }

    .wb-grid-layout-ha-right-tablet .wb-grid-layout__header-content {
        margin-left: auto;
        margin-right: 0;
    }
    .wb-grid-layout__grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Reset spans that would break on tablet */
    .wb-grid-layout__item--col-3 {
        grid-column: span 2;
    }
    
    .wb-grid-layout__item--row-2 .wb-grid-layout__card-content {
        padding: var(--wb-spacing-lg, 2rem);
    }
    
    .wb-grid-layout__counter-value {
        font-size: var(--e-global-typography-accent-font-size, 2.5rem);
    }
}

/* =============================================
   RESPONSIVE - MOBILE
   ============================================= */
@media (max-width: 767px) {
    /* Header alignment — mobile overrides (prefix_class adds -mobile suffix) */
    .wb-grid-layout-ha-left-mobile .wb-grid-layout__header-content {
        margin-left: 0;
        margin-right: auto;
    }

    .wb-grid-layout-ha-center-mobile .wb-grid-layout__header-content {
        margin-left: auto;
        margin-right: auto;
    }

    .wb-grid-layout-ha-right-mobile .wb-grid-layout__header-content {
        margin-left: auto;
        margin-right: 0;
    }
    .wb-grid-layout__component > *:not(:last-child) {
        margin-bottom: var(--wb-spacing-xl, 3rem);
    }
    
    .wb-grid-layout__grid {
        grid-template-columns: 1fr;
        gap: var(--wb-spacing-md, 1.5rem); /* Mantener gap: CSS Grid estándar */
    }
    
    /* Reset all column spans on mobile */
    .wb-grid-layout__item--col-2,
    .wb-grid-layout__item--col-3 {
        grid-column: span 1;
    }
    
    /* Row spans still work on mobile for visual variety */
    .wb-grid-layout__item--row-2,
    .wb-grid-layout__item--row-3 {
        grid-row: span 1;
    }
    
    .wb-grid-layout__item--row-2 .wb-grid-layout__card-image-wrapper {
        height: auto;
        min-height: 12rem;
    }
    
    .wb-grid-layout__item--row-2 .wb-grid-layout__card-content {
        padding: var(--wb-spacing-md, 1.5rem);
    }
    
    .wb-grid-layout__item--row-2 .wb-grid-layout__card-content > *:not(:last-child) {
        margin-bottom: var(--wb-spacing-sm, 1rem);
    }
    
    .wb-grid-layout__image-wrapper {
        min-height: 12rem;
    }
    
    .wb-grid-layout__counter-value {
        font-size: var(--e-global-typography-accent-font-size, 2rem);
    }
    
    .wb-grid-layout-hl-split .wb-grid-layout__header-content {
        grid-template-columns: 1fr;
    }
    
    .wb-grid-layout__header .button-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .wb-grid-layout__header .button-group .button {
        width: 100%;
        justify-content: center;
    }
}

/* =============================================
   ANIMATION STATES
   ============================================= */
/* Counter animation - start state */
.wb-grid-layout__counter-value:not([data-animated="true"]) .wb-grid-layout__counter-number {
    /* Initial state before animation */
}

/* Counter animation - animating state */
.wb-grid-layout__counter-value[data-animating="true"] .wb-grid-layout__counter-number {
    /* During animation */
}

/* Counter animation - completed state */
.wb-grid-layout__counter-value[data-animated="true"] .wb-grid-layout__counter-number {
    /* After animation completes */
}
