/* ================================================================ */
/* Reusable Global UI Components                                    */
/* ================================================================ */

/* ================================================================ */
/* Tabs Component (.tab-btn)                                        */
/* ================================================================ */
.tab-btn {
    display: inline-flex;
    align-items: center;
    font-weight: 700;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    color: #374151; /* Tailwind gray-700 */
    background-color: transparent;
    border: none;
    outline: none;
    text-decoration: none;
}

@media (max-width: 640px) {
    .tab-btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.8125rem;
    }
}

html.dark .tab-btn,
.dark .tab-btn,
body.dark-mode .tab-btn {
    color: #d1d5db; /* Tailwind gray-300 */
}

/* Inactive Hover: explicitly guarded with :not(.active) so active tabs CANNOT trigger hover colors */
.tab-btn:not(.active):hover {
    background-color: #e5e7eb; /* Tailwind gray-200 */
    color: #111827; /* Tailwind gray-900 */
    text-decoration: none;
}

html.dark .tab-btn:not(.active):hover,
.dark .tab-btn:not(.active):hover,
body.dark-mode .tab-btn:not(.active):hover {
    background-color: #374151; /* Tailwind gray-700 */
    color: #f9fafb; /* Tailwind gray-50 */
    text-decoration: none;
}

/* Authoritative Active State: immune to hover clashing */
.tab-btn.active,
.tab-btn.active:hover {
    background-color: #2563eb !important; /* Tailwind blue-600 */
    color: #ffffff !important;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    text-decoration: none;
}

html.dark .tab-btn.active,
html.dark .tab-btn.active:hover,
.dark .tab-btn.active,
.dark .tab-btn.active:hover,
body.dark-mode .tab-btn.active,
body.dark-mode .tab-btn.active:hover {
    background-color: #2563eb !important;
    color: #ffffff !important;
    text-decoration: none;
}

/* ================================================================ */
/* Form Select Component (.form-select)                            */
/* ================================================================ */
.form-select {
    padding-left: 0.75rem !important;
    padding-right: 1.75rem !important;
}

/* ================================================================ */
/* Constructor Color Stripe (.constructor-color-bar)               */
/* ================================================================ */
.constructor-color-bar {
    width: 4px;
    height: 24px;
    margin-right: 10px;
    border-radius: 1px;
    display: inline-block;
}

/* Light mode only: crisp black outline around white constructor bars so they are visible on light backgrounds */
html:not(.dark) body:not(.dark-mode) .constructor-color-bar.is-white-team,
html:not(.dark) body:not(.dark-mode) .constructor-color-bar[style*="#FFFFFF" i],
html:not(.dark) body:not(.dark-mode) .constructor-color-bar[style*="#ffffff" i],
html:not(.dark) body:not(.dark-mode) .constructor-color-bar[style*="rgb(255, 255, 255)"],
html:not(.dark) body:not(.dark-mode) .constructor-color-bar[style*="white"] {
    box-shadow: 0 0 0 1px #000000 !important;
}

/* Dark mode reset: ensure no black outline in dark mode where white is naturally visible */
html.dark .constructor-color-bar,
body.dark-mode .constructor-color-bar {
    box-shadow: none !important;
}

/* ================================================================ */
/* Data Table Hyperlinks                                            */
/* ================================================================ */
table tbody td a:not(.btn):not(.badge):not(.tab-btn),
.table tbody td a:not(.btn):not(.badge):not(.tab-btn) {
    color: #2563eb;
    text-decoration: none;
}

table tbody td a:not(.btn):not(.badge):not(.tab-btn):hover,
.table tbody td a:not(.btn):not(.badge):not(.tab-btn):hover {
    color: #1d4ed8;
    text-decoration: underline;
}

html.dark table tbody td a:not(.btn):not(.badge):not(.tab-btn),
body.dark-mode table tbody td a:not(.btn):not(.badge):not(.tab-btn),
.dark table tbody td a:not(.btn):not(.badge):not(.tab-btn) {
    color: #38bdf8;
}

html.dark table tbody td a:not(.btn):not(.badge):not(.tab-btn):hover,
body.dark-mode table tbody td a:not(.btn):not(.badge):not(.tab-btn):hover,
.dark table tbody td a:not(.btn):not(.badge):not(.tab-btn):hover {
    color: #7dd3fc;
}

/* ================================================================ */
/* Info Popovers Component (.info-popover-*)                        */
/* ================================================================ */
.info-popover-anchor {
    position: relative;
}

.info-popover-trigger {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #94a3b8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
    padding: 0;
    vertical-align: middle;
}

.info-popover-trigger:hover,
.info-popover-trigger[aria-expanded="true"] {
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
    transform: scale(1.15);
}

html.dark .info-popover-trigger,
.dark .info-popover-trigger,
body.dark-mode .info-popover-trigger {
    color: #94a3b8;
    background: transparent;
}

html.dark .info-popover-trigger:hover,
html.dark .info-popover-trigger[aria-expanded="true"],
.dark .info-popover-trigger:hover,
.dark .info-popover-trigger[aria-expanded="true"],
body.dark-mode .info-popover-trigger:hover,
body.dark-mode .info-popover-trigger[aria-expanded="true"] {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    transform: scale(1.15);
}

.info-popover-card {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 50;
    width: 290px;
    max-width: calc(100vw - 24px);
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    color: #334155;
    font-size: 0.8125rem;
    line-height: 1.5;
    text-align: left;
}

html.dark .info-popover-card,
.dark .info-popover-card,
body.dark-mode .info-popover-card {
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.5);
    color: #f1f5f9;
}

/* Header */
.info-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 8px;
    margin-bottom: 10px;
}

html.dark .info-popover-header,
.dark .info-popover-header,
body.dark-mode .info-popover-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.info-popover-title {
    font-size: 0.75rem;
    font-weight: 800;
    color: #2563eb;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

html.dark .info-popover-title,
.dark .info-popover-title,
body.dark-mode .info-popover-title {
    color: #60a5fa;
}

.info-popover-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.info-popover-close:hover {
    color: #0f172a;
}

html.dark .info-popover-close:hover,
.dark .info-popover-close:hover,
body.dark-mode .info-popover-close:hover {
    color: #ffffff;
}

.info-popover-body p {
    margin: 0 0 8px 0;
    color: #475569;
}

html.dark .info-popover-body p,
.dark .info-popover-body p,
body.dark-mode .info-popover-body p {
    color: #cbd5e1;
}

.info-popover-body p:last-child {
    margin-bottom: 0;
}

.info-popover-body strong {
    color: #0f172a;
}

html.dark .info-popover-body strong,
.dark .info-popover-body strong,
body.dark-mode .info-popover-body strong {
    color: #f1f5f9;
}

@media (max-width: 640px) {
    .info-popover-card {
        position: fixed !important;
        top: auto !important;
        bottom: 16px !important;
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
        max-width: calc(100vw - 24px) !important;
        max-height: 80vh !important;
        overflow-y: auto !important;
        transform: none !important;
        z-index: 100 !important;
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4) !important;
    }
}

/* ================================================================ */
/* Mobile Viewport Safe Areas, Typography & Touch Targets           */
/* ================================================================ */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

header.app-header {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-top: max(1rem, env(safe-area-inset-top));
}

.touch-target-min {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ================================================================ */
/* Mobile Select2 Usability & Auto-Zoom Prevention (iOS)             */
/* ================================================================ */
.select2-search--dropdown .select2-search__field {
    font-size: 16px !important; /* Prevents iOS Safari auto-zoom on focus */
}



