/* ============================================================================
   STATS BLOCK - COMPLETE STYLES (Frontend & Editor)
   ============================================================================ */

/* ============================================================================
   FRONTEND STYLES
   ============================================================================ */

.stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    align-items: stretch;
    width: 100%;
    box-sizing: border-box;
}

.stats-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 0 30%;
    max-width: 30%;
    min-width: 0;
    box-sizing: border-box;
    padding: 45px;
    position: relative;
    text-align: center;
    word-wrap: break-word;
}

.stats-counter {
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    margin: 0 0 8px 0;
    padding: 0;
    line-height: normal;
    white-space: nowrap;
    display: block;
}

.stats-text {
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    text-align: center;
    text-transform: inherit;
    margin: 0;
    padding: 0;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    white-space: normal;
    width: 100%;
}

/* Divider - only between items in same row */
.stats-item:not(:last-child)::after {
    content: "";
    position: absolute;
    right: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.3);
    z-index: 1;
}

/* Hide divider after every 3rd item (end of row) */
.stats-item:nth-child(3n):not(:last-child)::after {
    display: none;
}

@media (min-width: 1024px) {
    .stats-item:nth-child(3)::after {
        display: none !important;
    }
}
/* Tablet Styles */
@media (max-width: 1024px) {
    .stats-row {
        gap: 24px;
    }
    
    .stats-item {
        flex: 0 0 45%;
        max-width: 45%;
    }
    
    .stats-item:not(:last-child)::after {
        right: -12px;
    }
    
    /* Hide divider after every 2nd item on tablet */
    .stats-item:nth-child(2n):not(:last-child)::after {
        display: none !important;
    }
    
    /* Reset the 3n rule for tablet */
    .stats-item:nth-child(3n):not(:last-child)::after {
        display: block;
    }
}

/* Mobile Styles */
@media (max-width: 768px) {
    .stats-row {
        flex-direction: column;
        gap: 20px;
        align-items: center;
        overflow: hidden;
    }
    
    .stats-item {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
        padding: 20px 0;
    }
    
    /* Horizontal divider on mobile */
    .stats-item:not(:last-child)::after {
        content: "";
        position: absolute;
        left: 50%;
        top: auto;
        bottom: -10px;
        transform: translateX(-50%);
        width: 100% !important;
        height: 1px !important;
        background-color: rgba(255, 255, 255, 1);
        z-index: 1;
        display: block !important;
    }
    .stats-item:nth-child(2n):not(:last-child)::after {
        display: block !important;
    }
}

/* ============================================================================
   EDITOR STYLES
   ============================================================================ */

/* Editor block wrapper */
.wp-block-custom-stats {
    margin: 20px 0;
}

/* Editor preview area styling */
.editor-styles-wrapper .wp-block-custom-stats {
    background-color: transparent;
}

/* Sidebar panel input styling */
.components-panel__body .components-base-control {
    margin-bottom: 16px;
}

.components-panel__body input[type="text"],
.components-panel__body input[type="number"],
.components-panel__body textarea,
.components-panel__body select {
    font-size: 13px;
    width: 100%;
}

/* Sidebar textarea styling */
.components-panel__body textarea {
    resize: vertical;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
}

/* Stats content cards in sidebar */
.components-panel__body > div > div[style*="backgroundColor: #f5f5f5"] {
    transition: all 0.2s ease;
}

.components-panel__body > div > div[style*="backgroundColor: #f5f5f5"]:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Editor preview container */
.wp-block-custom-stats > div[style*="border: 2px dashed"] {
    min-height: 200px;
}

/* Button spacing in editor */
.components-panel__body .components-button {
    margin-top: 0;
}

/* Color picker inputs */
.components-panel__body input[type="color"] {
    cursor: pointer;
    border-radius: 4px;
}

/* Remove spinners from number inputs in Firefox */
.components-panel__body input[type="number"] {
    -moz-appearance: textfield;
}

.components-panel__body input[type="number"]::-webkit-outer-spin-button,
.components-panel__body input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Panel body styling */
.components-panel__body-title {
    font-weight: 600;
}

/* Responsive device icons in sidebar */
.components-panel__body span[style*="width: 70px"] {
    color: #666;
    font-size: 13px;
}

/* Checkbox styling */
.components-panel__body input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.components-panel__body input[type="checkbox"]:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Make labels clickable */
.components-panel__body label {
    cursor: pointer;
    user-select: none;
}

/* Stats preview in editor */
.wp-block-custom-stats .stats-row {
    background-color: transparent;
}

/* Ensure proper spacing in nested panels */
.components-panel__body > div:last-child {
    margin-bottom: 0;
}

/* Button group styling */
.components-panel__body .components-button-group {
    display: flex;
    gap: 8px;
}

/* Primary button styling */
.components-button.is-primary {
    background-color: #007cba;
    border-color: #007cba;
    color: #fff;
}

.components-button.is-primary:hover {
    background-color: #005a87;
    border-color: #005a87;
}

/* Destructive button styling */
.components-button.is-destructive {
    color: #cc1818;
    border-color: #cc1818;
}

.components-button.is-destructive:hover {
    background-color: #cc1818;
    color: #fff;
    border-color: #cc1818;
}

/* Disabled button styling */
.components-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Panel spacing adjustments */
.components-panel__body + .components-panel__body {
    margin-top: 0;
}

/* Smooth transitions for interactive elements */
.components-button,
input,
select,
textarea {
    transition: all 0.15s ease;
}

/* Focus states for accessibility */
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #007cba;
    outline-offset: 0;
    border-color: #007cba;
}

/* ============================================================================
   BLOCK APPENDER (Add Block Button)
   ============================================================================ */

.wp-block-custom-stats .block-editor-block-list__empty-block-inserter,
.wp-block-custom-stats .block-list-appender {
    display: none;
}

/* ============================================================================
   RESPONSIVE EDITOR PREVIEW
   ============================================================================ */

/* Make sure editor preview respects container width */
.wp-block-custom-stats > div {
    width: 100%;
    box-sizing: border-box;
}

/* ============================================================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================================================ */

/* Better focus indicators */
*:focus-visible {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Skip link for screen readers */
.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    word-wrap: normal !important;
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    .stats-item:not(:last-child)::after {
        display: none !important;
    }
    
    .stats-row {
        page-break-inside: avoid;
    }
}