/**
 * GA4 Analytics - Tab Navigation & UI Components
 */

/* ===== Sub-Tab Bar ===== */
.ga4-tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #dee2e6;
    margin-bottom: 1.5rem;
    margin-top: 1rem;
}

.ga4-tab-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #6c757d;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.ga4-tab-btn:hover {
    color: #0d6efd;
    background: #f8f9fa;
    border-bottom-color: #cbd5e0;
}

.ga4-tab-btn.active {
    color: #0d6efd;
    border-bottom-color: #0d6efd;
    background: transparent;
}

.ga4-tab-btn i {
    margin-right: 0.5rem;
}

/* Hide tab bar when engine disabled */
.ga4-tab-bar.hidden {
    display: none;
}

/* ===== Tab Content ===== */
.ga4-tab-content {
    display: none;
}

.ga4-tab-content.active {
    display: block;
}

/* ===== Compare Mode Toggle ===== */
.ga4-compare-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #f8f9fa;
    border-radius: 0.25rem;
    margin-bottom: 1rem;
}

.ga4-compare-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.ga4-compare-toggle label {
    margin: 0;
    cursor: pointer;
    user-select: none;
}

/* ===== Delta Badges ===== */
.ga4-delta-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.ga4-delta-badge.positive {
    background: #d4edda;
    color: #155724;
}

.ga4-delta-badge.negative {
    background: #f8d7da;
    color: #721c24;
}

.ga4-delta-badge.neutral {
    background: #e2e3e5;
    color: #383d41;
}

.ga4-delta-badge i {
    margin-right: 0.25rem;
}

/* ===== Skeleton Loaders ===== */
.skeleton-loader {
    padding: 1rem;
}

.skeleton-line {
    height: 20px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
    border-radius: 4px;
    margin-bottom: 12px;
}

.skeleton-line:last-child {
    margin-bottom: 0;
    width: 60%;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ===== Filters Bar ===== */
.ga4-filters-bar {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.ga4-filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ga4-filter-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #6c757d;
    margin: 0;
}

.ga4-filter-group select,
.ga4-filter-group input {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

/* ===== Error/Warning Banners ===== */
.ga4-banner {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ga4-banner.partial-data {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.ga4-banner.rate-limited {
    background: #f8d7da;
    border: 1px solid #dc3545;
    color: #721c24;
}

.ga4-banner.feature-disabled {
    background: #e2e3e5;
    border: 1px solid #6c757d;
    color: #383d41;
}

.ga4-banner i {
    font-size: 1.25rem;
}

/* ===== Custom Query Builder ===== */
.ga4-query-builder {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 1.5rem;
}

.ga4-query-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.ga4-query-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.ga4-query-section h6 {
    margin-bottom: 1rem;
    color: #495057;
    font-weight: 600;
}

.ga4-picker {
    min-height: 150px;
    padding: 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    background: #ffffff;
}

.ga4-picker option {
    padding: 0.5rem;
}

.ga4-picker option:checked {
    background: #0d6efd;
    color: #ffffff;
}

.ga4-run-button {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    background: #0d6efd;
    border: none;
    color: #ffffff;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ga4-run-button:hover {
    background: #0b5ed7;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

.ga4-run-button:active {
    transform: translateY(0);
}

.ga4-run-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

/* ===== Query Results ===== */
.ga4-results-container {
    margin-top: 1.5rem;
}

.ga4-results-table {
    width: 100%;
    border-collapse: collapse;
}

.ga4-results-table thead th {
    background: #f8f9fa;
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
}

.ga4-results-table tbody td {
    padding: 0.75rem;
    border-bottom: 1px solid #e9ecef;
}

.ga4-results-table tbody tr:hover {
    background: #f8f9fa;
}

.ga4-export-button {
    padding: 0.5rem 1rem;
    background: #198754;
    color: #ffffff;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s ease;
}

.ga4-export-button:hover {
    background: #157347;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .ga4-tab-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .ga4-tab-btn {
        white-space: nowrap;
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    .ga4-filters-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .ga4-filter-group {
        width: 100%;
    }
}

/* ===== Empty States ===== */
.ga4-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.ga4-empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.ga4-empty-state h5 {
    margin-bottom: 0.5rem;
    color: #495057;
}

.ga4-empty-state p {
    margin-bottom: 0;
    font-size: 0.875rem;
}

/* ===== Loading States ===== */
.ga4-loading-overlay {
    position: relative;
}

.ga4-loading-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Tooltips ===== */
.ga4-tooltip {
    position: relative;
    cursor: help;
}

.ga4-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: #333;
    color: #fff;
    border-radius: 0.25rem;
    white-space: nowrap;
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    z-index: 1000;
}

.ga4-tooltip:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
    margin-bottom: -5px;
    z-index: 1000;
}
