/* TBP ACF Tabs Widget */

.tbp-acf-tabs-wrapper {
    display: flex;
    flex-direction: column;
}

.tbp-acf-tabs-nav {
    display: flex;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tbp-acf-tab-title {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 15px 20px;
    background: #f7f7f7;
    border: 1px solid #ddd;
    border-bottom: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #333;
    transition: all 0.3s ease;
    margin: 0;
    outline: none;
}

.tbp-acf-tab-title:hover {
    background: #eee;
}

.tbp-acf-tab-title.active {
    background: #fff;
    color: #0073aa;
    border-bottom-color: #fff;
    position: relative;
}

/* Horizontal Layout */
.tbp-acf-tabs-view-horizontal .tbp-acf-tabs-wrapper {
    flex-direction: column;
}

.tbp-acf-tabs-view-horizontal .tbp-acf-tabs-nav {
    flex-direction: row;
    border-bottom: 1px solid #ddd;
}

.tbp-acf-tabs-view-horizontal .tbp-acf-tab-title {
    margin-bottom: -1px;
}

.tbp-acf-tabs-view-horizontal .tbp-acf-tab-title.active {
    border-bottom-color: #fff;
}

.tbp-acf-tabs-view-horizontal .tbp-acf-tabs-content {
    border: 1px solid #ddd;
    border-top: none;
}

/* Stretch alignment */
.tbp-acf-tabs-view-horizontal .tbp-acf-tabs-nav[style*="stretch"] .tbp-acf-tab-title {
    flex: 1;
}

/* Vertical Layout */
.tbp-acf-tabs-view-vertical .tbp-acf-tabs-wrapper {
    flex-direction: row;
}

.tbp-acf-tabs-view-vertical .tbp-acf-tabs-nav {
    flex-direction: column;
    flex-shrink: 0;
    width: 200px;
    border-right: 1px solid #ddd;
    border-bottom: none;
}

.tbp-acf-tabs-view-vertical .tbp-acf-tab-title {
    justify-content: flex-start;
    border: 1px solid #ddd;
    border-right: none;
    border-bottom: none;
    margin-right: -1px;
}

.tbp-acf-tabs-view-vertical .tbp-acf-tab-title:last-child {
    border-bottom: 1px solid #ddd;
}

.tbp-acf-tabs-view-vertical .tbp-acf-tab-title.active {
    border-right-color: #fff;
    z-index: 1;
}

.tbp-acf-tabs-view-vertical .tbp-acf-tabs-content {
    flex: 1;
    border: 1px solid #ddd;
    border-left: none;
}

/* Vertical Right Position */
.tbp-acf-tabs-view-vertical.tbp-acf-tabs-position-right .tbp-acf-tabs-wrapper {
    flex-direction: row-reverse;
}

.tbp-acf-tabs-view-vertical.tbp-acf-tabs-position-right .tbp-acf-tabs-nav {
    border-right: none;
    border-left: 1px solid #ddd;
}

.tbp-acf-tabs-view-vertical.tbp-acf-tabs-position-right .tbp-acf-tab-title {
    justify-content: flex-end;
    border-right: 1px solid #ddd;
    border-left: none;
    margin-right: 0;
    margin-left: -1px;
}

.tbp-acf-tabs-view-vertical.tbp-acf-tabs-position-right .tbp-acf-tab-title.active {
    border-left-color: #fff;
    border-right-color: #ddd;
}

.tbp-acf-tabs-view-vertical.tbp-acf-tabs-position-right .tbp-acf-tabs-content {
    border-left: 1px solid #ddd;
    border-right: none;
}

/* Sticky Tabs */
.tbp-acf-tabs-view-vertical.tbp-acf-tabs-sticky-yes .tbp-acf-tabs-nav {
    position: sticky;
    top: 0;
    align-self: flex-start;
    max-height: 100vh;
    overflow-y: auto;
}

/* Content Area */
.tbp-acf-tabs-content {
    background: #fff;
}

.tbp-acf-tab-content {
    display: none;
    padding: 20px;
}

.tbp-acf-tab-content.active {
    display: block;
}

/* ACF Field Styles */
.tbp-acf-field {
    margin-bottom: 20px;
}

.tbp-acf-field:last-child {
    margin-bottom: 0;
}

.tbp-acf-field-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Field Tooltip */
.tbp-acf-field-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.tbp-acf-field-tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 12px;
    font-weight: 700;
    color: #666;
    background: #e8e8e8;
    border-radius: 50%;
    cursor: help;
    transition: all 0.2s ease;
    text-transform: none;
    letter-spacing: 0;
}

.tbp-acf-field-tooltip-icon:hover,
.tbp-acf-field-tooltip.is-active .tbp-acf-field-tooltip-icon {
    color: #fff;
    background: #0073aa;
}

.tbp-acf-field-tooltip-content {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    min-width: 200px;
    max-width: 400px;
    width: calc(100% - 40px);
    padding: 20px;
    padding-top: 40px;
    background: #333;
    color: #fff;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.6;
    text-transform: none;
    letter-spacing: 0;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000000;
}

/* Arrow hidden - tooltip is now a centered modal */
.tbp-acf-field-tooltip-content::after {
    display: none;
}

/* Tooltip Overlay - Fixed to viewport */
.tbp-acf-field-tooltip-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999999;
    cursor: pointer;
}

.tbp-acf-field-tooltip.is-active .tbp-acf-field-tooltip-overlay {
    display: block;
}

/* Tooltip Close Button */
.tbp-acf-field-tooltip-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    color: #999;
    cursor: pointer;
    transition: color 0.2s ease;
    z-index: 1;
}

.tbp-acf-field-tooltip-close:hover {
    color: #fff;
}

/* Show tooltip when active (click triggered) */
.tbp-acf-field-tooltip.is-active .tbp-acf-field-tooltip-content {
    opacity: 1;
    visibility: visible;
}


.tbp-acf-field-value {
    line-height: 1.6;
}

/* Image Field */
.tbp-acf-image {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Gallery Field */
.tbp-acf-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.tbp-acf-gallery-item {
    width: 100%;
    height: auto;
    display: block;
}

/* File Field */
.tbp-acf-file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s ease;
}

.tbp-acf-file:hover {
    background: #0073aa;
    border-color: #0073aa;
    color: #fff;
}

.tbp-acf-file-icon {
    flex-shrink: 0;
}

.tbp-acf-file-name {
    font-weight: 500;
}

/* Dropzone Field */
.tbp-acf-dropzone-files {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.tbp-acf-dropzone-file {
    flex: 0 0 auto;
}

.tbp-acf-dropzone-image-link {
    display: block;
    border-radius: 6px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tbp-acf-dropzone-image-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tbp-acf-dropzone-image {
    display: block;
    max-width: 150px;
    height: auto;
    border-radius: 6px;
}

/* Link Field */
.tbp-acf-link {
    color: #0073aa;
    text-decoration: none;
}

.tbp-acf-link:hover {
    text-decoration: underline;
}

/* Color Field */
.tbp-acf-color-swatch {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    vertical-align: middle;
    margin-right: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.tbp-acf-color-value {
    font-family: monospace;
}

/* List Fields */
.tbp-acf-checkbox-list,
.tbp-acf-posts-list,
.tbp-acf-terms-list,
.tbp-acf-users-list {
    margin: 0;
    padding-left: 20px;
}

.tbp-acf-checkbox-list li,
.tbp-acf-posts-list li,
.tbp-acf-terms-list li,
.tbp-acf-users-list li {
    margin-bottom: 5px;
}

/* Repeater Field - Table Layout */
.tbp-acf-repeater {
    margin: 0;
}

.tbp-acf-repeater-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tbp-acf-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 14px;
}

.tbp-acf-table thead {
    background: #f5f5f5;
}

.tbp-acf-table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #e0e0e0;
    white-space: nowrap;
}

.tbp-acf-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: top;
}

.tbp-acf-table tbody tr:last-child td {
    border-bottom: none;
}

.tbp-acf-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.tbp-acf-table tbody tr:hover {
    background: #f0f0f0;
}

.tbp-acf-table img {
    max-width: 80px;
    height: auto;
    border-radius: 4px;
}

/* Repeater Field - Cards Layout */
.tbp-acf-repeater-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.tbp-acf-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.tbp-acf-card-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.tbp-acf-card-field:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.tbp-acf-card-label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tbp-acf-card-value {
    color: #333;
}

.tbp-acf-card-value img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Group Field */
.tbp-acf-group {
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.tbp-acf-group-field {
    margin-bottom: 10px;
}

.tbp-acf-group-field:last-child {
    margin-bottom: 0;
}

.tbp-acf-group-label {
    font-weight: 600;
    color: #666;
}

/* Map Field */
.tbp-acf-map a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #0073aa;
    text-decoration: none;
}

.tbp-acf-map a:hover {
    text-decoration: underline;
}

/* Empty State */
.tbp-acf-tabs-empty {
    padding: 40px 20px;
    text-align: center;
    background: #f9f9f9;
    border: 2px dashed #ddd;
    border-radius: 4px;
    color: #666;
}

/* Responsive */
@media (max-width: 767px) {
    .tbp-acf-tabs-view-vertical .tbp-acf-tabs-wrapper {
        flex-direction: column;
    }

    .tbp-acf-tabs-view-vertical .tbp-acf-tabs-nav {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #ddd;
    }

    .tbp-acf-tabs-view-vertical .tbp-acf-tab-title {
        border: 1px solid #ddd;
        border-bottom: none;
        margin-right: 0;
        margin-bottom: -1px;
    }

    .tbp-acf-tabs-view-vertical .tbp-acf-tabs-content {
        border: 1px solid #ddd;
        border-top: none;
        border-left: 1px solid #ddd;
    }

    .tbp-acf-tabs-view-vertical.tbp-acf-tabs-sticky-yes .tbp-acf-tabs-nav {
        position: relative;
        top: auto;
    }

    .tbp-acf-tabs-view-vertical.tbp-acf-tabs-position-right .tbp-acf-tabs-wrapper {
        flex-direction: column;
    }

    .tbp-acf-tabs-view-vertical.tbp-acf-tabs-position-right .tbp-acf-tabs-nav {
        border-left: none;
        border-bottom: 1px solid #ddd;
    }

    .tbp-acf-tabs-view-vertical.tbp-acf-tabs-position-right .tbp-acf-tab-title {
        justify-content: center;
        border-left: 1px solid #ddd;
        border-right: 1px solid #ddd;
        margin-left: 0;
    }

    .tbp-acf-tabs-view-vertical.tbp-acf-tabs-position-right .tbp-acf-tabs-content {
        border-right: 1px solid #ddd;
        border-left: 1px solid #ddd;
    }

    /* Responsive Cards */
    .tbp-acf-repeater-cards {
        grid-template-columns: 1fr;
    }
}

/* Responsive Table - Stack Mode (Enhanced Cards) */
@media (max-width: 767px) {
    .tbp-acf-repeater-responsive-stack .tbp-acf-table {
        border: none;
        background: transparent;
    }

    .tbp-acf-repeater-responsive-stack .tbp-acf-table thead {
        display: none;
    }

    .tbp-acf-repeater-responsive-stack .tbp-acf-table tbody,
    .tbp-acf-repeater-responsive-stack .tbp-acf-table tr {
        display: block;
    }

    .tbp-acf-repeater-responsive-stack .tbp-acf-table tr {
        background: #fff;
        border: none;
        border-radius: 12px;
        margin-bottom: 16px;
        padding: 0;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
        overflow: hidden;
    }

    .tbp-acf-repeater-responsive-stack .tbp-acf-table tr:last-child {
        margin-bottom: 0;
    }

    /* First cell as card header */
    .tbp-acf-repeater-responsive-stack .tbp-acf-table td:first-child {
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
        padding: 14px 16px;
        border-bottom: 1px solid #e0e0e0;
        font-weight: 600;
        font-size: 15px;
        color: #333;
    }

    .tbp-acf-repeater-responsive-stack .tbp-acf-table td:first-child::before {
        display: none;
    }

    .tbp-acf-repeater-responsive-stack .tbp-acf-table td {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        padding: 12px 16px;
        border-bottom: 1px solid #f0f0f0;
        text-align: left;
        background: #fff;
    }

    .tbp-acf-repeater-responsive-stack .tbp-acf-table td:nth-child(odd):not(:first-child) {
        background: #fafbfc;
    }

    .tbp-acf-repeater-responsive-stack .tbp-acf-table td:last-child {
        border-bottom: none;
        border-radius: 0 0 12px 12px;
    }

    .tbp-acf-repeater-responsive-stack .tbp-acf-table td::before {
        content: attr(data-label);
        flex: 0 0 40%;
        font-size: 12px;
        font-weight: 600;
        color: #666;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        padding-top: 2px;
    }

    .tbp-acf-repeater-responsive-stack .tbp-acf-table td:empty {
        display: none;
    }

    .tbp-acf-repeater-responsive-stack .tbp-acf-table td:empty::before {
        display: none;
    }

    /* Value styling */
    .tbp-acf-repeater-responsive-stack .tbp-acf-table td > *:last-child,
    .tbp-acf-repeater-responsive-stack .tbp-acf-table td {
        flex: 1;
        text-align: right;
        color: #333;
    }

    .tbp-acf-repeater-responsive-stack .tbp-acf-table td:first-child {
        text-align: left;
    }

    .tbp-acf-repeater-responsive-stack .tbp-acf-table img {
        max-width: 80px;
        height: auto;
        border-radius: 6px;
        margin-left: auto;
    }

    .tbp-acf-repeater-responsive-stack .tbp-acf-table a {
        color: #0073aa;
        text-decoration: none;
        font-weight: 500;
    }

    .tbp-acf-repeater-responsive-stack .tbp-acf-table a:hover {
        text-decoration: underline;
    }
}

/* Responsive Table - Scroll Mode */
.tbp-acf-repeater-responsive-scroll .tbp-acf-repeater-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tbp-acf-repeater-responsive-scroll .tbp-acf-table {
    min-width: 600px;
}

/* Scroll indicator for mobile */
@media (max-width: 767px) {
    .tbp-acf-repeater-responsive-scroll .tbp-acf-repeater-table {
        position: relative;
    }

    .tbp-acf-repeater-responsive-scroll .tbp-acf-repeater-table::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 30px;
        background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.9));
        pointer-events: none;
        opacity: 1;
        transition: opacity 0.3s;
    }

    .tbp-acf-repeater-responsive-scroll .tbp-acf-repeater-table::-webkit-scrollbar {
        height: 6px;
    }

    .tbp-acf-repeater-responsive-scroll .tbp-acf-repeater-table::-webkit-scrollbar-track {
        background: #f0f0f0;
        border-radius: 3px;
    }

    .tbp-acf-repeater-responsive-scroll .tbp-acf-repeater-table::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 3px;
    }

    .tbp-acf-repeater-responsive-scroll .tbp-acf-repeater-table::-webkit-scrollbar-thumb:hover {
        background: #999;
    }
}

/* Dots Navigation - Hidden on Desktop */
.tbp-acf-tabs-dots {
    display: none;
}

/* =============================================
   MOBILE TABS - Carousel Style
   ============================================= */
@media (max-width: 767px) {
    /* Show dots on mobile */
    .tbp-acf-tabs-dots {
        display: flex;
        justify-content: center;
        gap: 8px;
        padding: 16px 0;
        background: #f9f9f9;
        border-top: 1px solid #eee;
    }

    .tbp-acf-tabs-dot {
        width: 10px;
        height: 10px;
        padding: 0;
        border: none;
        border-radius: 50%;
        background: #ccc;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .tbp-acf-tabs-dot:hover {
        background: #999;
    }

    .tbp-acf-tabs-dot.active {
        background: #0073aa;
        transform: scale(1.2);
    }

    /* Wrapper padding to prevent border clipping */
    .tbp-acf-tabs-wrapper {
        padding-top: 4px;
    }

    /* Tabs Nav - Snap Scroll Carousel */
    .tbp-acf-tabs-nav {
        display: flex;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overflow-y: visible;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding: 4px 0;
        padding-right: 16%;
        margin-top: -4px;
        border-bottom: 1px solid #ddd;
    }

    .tbp-acf-tabs-nav::-webkit-scrollbar {
        display: none;
    }

    .tbp-acf-tab-title {
        flex: 0 0 84%;
        scroll-snap-align: start;
        scroll-snap-stop: always;
        margin: 0 4px;
        border-radius: 8px 8px 0 0;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
    }

    .tbp-acf-tab-title:first-child {
        margin-left: 0;
    }

    /* Override vertical styles on mobile */
    .tbp-acf-tabs-view-vertical .tbp-acf-tabs-nav {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        padding: 0;
        padding-right: 16%;
    }

    .tbp-acf-tabs-view-vertical .tbp-acf-tab-title {
        flex: 0 0 84%;
        scroll-snap-align: start;
    }

    /* Content - Swipeable with native scroll-snap */
    .tbp-acf-tabs-content {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: scroll !important;
        overflow-y: hidden !important;
        scroll-snap-type: x mandatory !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        border: none !important;
    }

    .tbp-acf-tabs-content::-webkit-scrollbar {
        display: none;
    }

    /* All panels must be visible and same width for scroll-snap */
    .tbp-acf-tabs-wrapper .tbp-acf-tabs-content .tbp-acf-tab-content,
    .tbp-acf-tabs-wrapper .tbp-acf-tabs-content .tbp-acf-tab-content.active,
    .tbp-acf-tab-content,
    .tbp-acf-tab-content.active {
        flex: 0 0 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        scroll-snap-align: start !important;
        scroll-snap-stop: always !important;
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
        box-sizing: border-box !important;
        flex-shrink: 0 !important;
    }
}
