/* ==========================================================================
   UPP COMMON STYLES - THE CATHEDRAL SYSTEM (Master V13: Final Contrast Fix)
   "Symmetry is Trust. Consistency is Power."
   ========================================================================== */

/* ==========================================================================
   0. RESET & CONTAINER OVERRIDES
   ========================================================================== */
/* Let BuddyBoss grid handle layout — only remove max-width caps on inner content */
.bb-profile-grid.bb-grid:has(.upp-life-container) .item-body-inner {
    max-width: 100% !important;
}

/* 1. GLOBAL TYPOGRAPHY */
.upp-life-container,
.upp-common-container {
    width: 100% !important;
    max-width: none !important;
    font-family: inherit !important;
    color: var(--bb-body-text-color);
    line-height: 1.6;
}

.upp-section-title,
.upp-modal-header h4,
.upp-canvas-heading,
.upp-settings-heading {
    margin: 0;
    font-family: var(--bb-headings-font-family) !important;
    font-size: var(--bb-h3-line-height, 24px);
    font-weight: 700;
    color: var(--bb-headings-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.upp-header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    font-size: 14px;
    white-space: nowrap;
}

/* ==========================================================================
   2. THE "GOLD THREAD" INPUTS (Global Configuration)
   ========================================================================== */

/* 1. INPUTS (Standard Fields) - Excludes WP Admin */
body:not(.wp-admin) input[type="text"],
body:not(.wp-admin) input[type="number"]:not(.upp-card-number):not(.upp-item-number), 
body:not(.wp-admin) input[type="email"],
body:not(.wp-admin) input[type="password"],
body:not(.wp-admin) input[type="url"],
body:not(.wp-admin) textarea { 
    background-color: var(--bb-body-background-color) !important;
    border: 1px solid color-mix(in srgb, var(--bb-primary-color) 80%, transparent) !important;
    color: var(--bb-body-text-color) !important;
    border-radius: 4px !important;
    padding: 8px 12px !important;
    font-size: 14px !important;
    min-height: 38px;
    box-sizing: border-box;
    transition: all 0.2s ease-in-out;
    width: 100%;
}

/* 2. THE DROPDOWN WRAPPER (Shell Only) - Excludes WP Admin */
body:not(.wp-admin) select,
body:not(.wp-admin) .select-wrap {
    background-color: var(--bb-body-background-color) !important;
    border: 1px solid color-mix(in srgb, var(--bb-primary-color) 80%, transparent) !important;
    border-radius: 4px !important;
    box-sizing: border-box;
    position: relative;
    padding: 8px 12px !important;
    min-height: 38px;
    width: auto;
}

/* Reset padding for wrapper (inner select will have its own padding) */
body:not(.wp-admin) .select-wrap {
    padding: 0 !important;
    width: 100%;
}

/* 3. THE GHOST SELECT (Inner Logic) */
.select-wrap select,
#members-order-by,
#groups-order-by,
#blogs-order-by {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    height: 36px !important;
    padding: 8px 35px 8px 12px !important; 
    width: auto;
    color: var(--bb-body-text-color) !important;
    cursor: pointer;
    z-index: 10;
    position: relative;
}

/* 4. THE BUDDYBOSS ARROW */
.select-wrap .select-arrow {
    color: var(--bb-body-text-color) !important;
    z-index: 1;
    display: block !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    right: 12px !important;
    position: absolute !important;
    pointer-events: none;
}

/* 5. DROPDOWN OPTIONS (Dark Theme Fix) - Excludes WP Admin */
body:not(.wp-admin) select option,
body:not(.wp-admin) #members-order-by option,
body:not(.wp-admin) #groups-order-by option,
body:not(.wp-admin) #blogs-order-by option {
    background-color: var(--bb-content-background-color) !important;
    color: var(--bb-body-text-color) !important;
    padding: 10px;
}

/* HOVER & FOCUS STATES - Excludes WP Admin */
body:not(.wp-admin) input:hover, 
body:not(.wp-admin) textarea:hover, 
body:not(.wp-admin) select:hover, 
body:not(.wp-admin) .select-wrap:hover,
body:not(.wp-admin) input:focus, 
body:not(.wp-admin) textarea:focus, 
body:not(.wp-admin) select:focus, 
body:not(.wp-admin) .select-wrap:focus-within {
    border-color: var(--bb-primary-color) !important;
    box-shadow: 0 0 0 1px var(--bb-primary-color) !important;
    outline: none;
}

/* STANDARD LABELS */
.upp-add-wrapper label,
.upp-input-wrapper label {
    display: block !important;
    width: 100%;
    margin-bottom: 8px !important;
    font-weight: 600;
    color: var(--bb-body-text-color);
    font-size: 14px;
}

/* ==========================================================================
   3. THE CATHEDRAL CHECKBOX
   ========================================================================== */
.upp-header-actions label, 
.upp-control-row label,    
.upp-inline-form label {   
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    cursor: pointer;
    font-size: 14px;
    width: auto !important;
    margin-bottom: 0 !important;
    font-weight: 500;
}

input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0;
    background-color: var(--bb-body-background-color);
    border: 1px solid color-mix(in srgb, var(--bb-primary-color) 80%, transparent) !important;
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    vertical-align: middle;
    transition: all 0.2s;
}

input[type="checkbox"]:checked {
    background-color: var(--bb-primary-button-background-regular) !important;
    border-color: transparent !important;
}

input[type="checkbox"]::before {
    content: "";
    position: absolute;
    top: 2px; left: 6px;
    width: 4px; height: 9px;
    border: solid var(--bb-primary-button-text-regular);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}

input[type="checkbox"]:checked::before {
    transform: rotate(45deg) scale(1);
    opacity: 1;
}

/* ==========================================================================
   4. CARD ARCHITECTURE
   ========================================================================== */
.upp-card {
    background: var(--bb-content-background-color);
    border: 1px solid var(--bb-content-border-color);
    border-left: 4px solid var(--bb-primary-button-background-regular);
    border-radius: 4px;
    padding: 20px;
    position: relative;
    margin-bottom: 15px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.upp-card:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 5px 15px rgba(0,0,0,0.1); 
}

.upp-card-actions {
    position: absolute; top: 15px; right: 15px;
    display: flex; gap: 8px;
    opacity: 0; transition: opacity 0.2s; z-index: 10;
}
.upp-card:hover .upp-card-actions { opacity: 1; }

.upp-card-number, .upp-item-number {
    background-color: var(--bb-primary-button-background-regular) !important;
    color: var(--bb-primary-button-text-regular) !important;
    border: none !important;
    border-radius: 50%;
    width: 32px; 
    height: 32px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-weight: bold; 
    padding: 0;
    flex-shrink: 0;
    text-align: center;
    -moz-appearance: textfield;
    appearance: textfield;
}

.upp-card-number::-webkit-outer-spin-button,
.upp-card-number::-webkit-inner-spin-button,
.upp-item-number::-webkit-outer-spin-button,
.upp-item-number::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ==========================================================================
   5. BUTTONS
   ========================================================================== */
.upp-btn-primary, button.button-primary, input[type="submit"].button-primary {
    background-color: var(--bb-primary-button-background-regular) !important;
    color: var(--bb-primary-button-text-regular) !important;
    border: 1px solid transparent !important;
    border-radius: 4px;
    font-weight: 600;
    padding: 0 20px;
    height: 38px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex; align-items: center; justify-content: center;
}
.upp-btn-primary:hover, button.button-primary:hover {
    background-color: var(--bb-primary-button-background-hover) !important;
    transform: translateY(-1px);
}

.upp-btn-ghost, .upp-dialog-cancel {
    background-color: transparent !important;
    border: 1px solid var(--bb-content-border-color) !important;
    color: var(--bb-body-text-color) !important;
    border-radius: 4px;
    font-weight: 600;
    padding: 0 20px;
    height: 38px;
    cursor: pointer;
    transition: all 0.2s;
}
.upp-btn-ghost:hover, .upp-dialog-cancel:hover {
    border-color: var(--bb-primary-color) !important;
    color: var(--bb-primary-color) !important;
    box-shadow: 0 0 0 1px var(--bb-primary-color) inset;
}

/* ==========================================================================
   6. MODALS
   ========================================================================== */
.upp-modal, .upp-dialog-overlay { 
    position: fixed; z-index: 99999; left: 0; top: 0; width: 100%; height: 100%; 
    background-color: rgba(0,0,0,0.6); display: flex; justify-content: center; 
    align-items: center; backdrop-filter: blur(2px); 
    opacity: 0; animation: uppFadeIn 0.2s forwards;
}

.upp-modal-content, .upp-dialog-container { 
    background-color: var(--bb-content-background-color) !important; 
    border: 1px solid var(--bb-content-border-color);
    border-radius: 4px; 
    box-shadow: 0 20px 50px rgba(0,0,0,0.4); 
    color: var(--bb-body-text-color);
    display: flex; flex-direction: column; 
    width: 500px; max-width: 90%; max-height: 85vh;
}
.upp-modal-large { width: 700px; }

.upp-modal-header, .upp-dialog-header { 
    border-bottom: 1px solid var(--bb-content-border-color); 
    padding: 20px; display: flex; justify-content: space-between; align-items: center; 
}

.upp-modal-body, .upp-dialog-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
}

.upp-modal-footer, .upp-dialog-footer { 
    border-top: 1px solid var(--bb-content-border-color); 
    background-color: var(--bb-content-background-color);
    padding: 20px; display: flex; justify-content: flex-end; gap: 15px; 
}

.upp-modal-close, .upp-dialog-close {
    display: none; /* Hidden - use Cancel button instead */
}
.upp-modal-close:hover, .upp-dialog-close:hover { color: var(--bb-danger-color); }
@keyframes uppFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ==========================================================================
   7. UTILITIES
   ========================================================================== */
.upp-spinner {
    width: 40px; height: 40px; margin: 20px auto;
    border: 3px solid var(--bb-content-border-color);
    border-top: 3px solid var(--bb-primary-button-background-regular);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.upp-hidden { display: none !important; }

/* Drag & Drop Placeholder */
.ui-sortable-placeholder, .upp-tag-placeholder {
    border: 2px dashed var(--bb-primary-button-background-regular) !important;
    background: rgba(0,0,0,0.05) !important;
    visibility: visible !important;
    height: 60px;
    border-radius: 4px;
    margin-bottom: 15px;
}

/* Notification System */
.upp-notification {
    position: fixed; top: 80px; right: 20px; z-index: 999999;
    max-width: 400px; min-width: 300px;
    background: var(--bb-content-background-color);
    border: 1px solid var(--bb-content-border-color);
    border-left: 4px solid var(--bb-primary-button-background-regular);
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    border-radius: 4px; padding: 15px 40px 15px 20px;
    opacity: 0; transform: translateX(420px); transition: all 0.3s ease-in-out;
}
.upp-notification-show { opacity: 1; transform: translateX(0); }
.upp-notification p { margin: 0; font-size: 14px; color: var(--bb-body-text-color); }

/* Profile Completion Widget */
.widget_bp_core_completion_widget, .bb-profile-completion-widget {
    border: 1px solid var(--bb-primary-color) !important;
    background-color: var(--bb-content-background-color) !important;
    border-radius: 4px;
}
.bb-profile-completion-ring .percentage-label span {
    color: var(--bb-primary-color) !important;
    font-family: var(--bb-headings-font-family) !important;
    font-weight: 700 !important;
}

/* ==========================================================================
   8. GLOBAL NAVIGATION OVERRIDES (The Floating Menus)
   Forces BuddyBoss header menus & Admin Bar flyouts to match the Gold aesthetic.
   ========================================================================== */
.site-header .sub-menu,
.bb-user-nav-wrap .sub-menu,
.bp-navs ul li .sub-menu,
.sub-menu .sub-menu,
#wpadminbar .ab-sub-wrapper,
.ab-sub-wrapper {
    background-color: var(--bb-content-background-color) !important;
    border: 1px solid color-mix(in srgb, var(--bb-primary-color) 80%, transparent) !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3) !important;
    border-radius: 4px !important;
}

/* Hover for Floating Menus */
.site-header .sub-menu li a:hover,
.bb-user-nav-wrap .sub-menu li a:hover,
.sub-menu .sub-menu li a:hover,
#wpadminbar .ab-submenu li a:hover {
    background-color: var(--bb-body-background-color) !important;
    color: var(--bb-primary-color) !important;
    padding-left: 20px !important; /* Slide Effect */
    transition: all 0.2s;
}

/* ==========================================================================
   9. STATIC SUB-NAVIGATION (The Edit Profile Menu)
   Handles the vertical list of tabs inside profile/settings pages.
   ========================================================================== */
.subnav li a {
    transition: all 0.2s ease-in-out;
    border-radius: 4px;
    display: block; /* Ensures the hover box fills the width */
}

.subnav li a:hover {
    /* FIX: Used CONTENT background (Lighter) because this menu sits on the BODY background (Darker) */
    background-color: var(--bb-content-background-color) !important;
    
    color: var(--bb-primary-color) !important;
    padding-left: 15px !important; /* The Slide Effect */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* Subtle depth */
}

/* ==========================================================================
   10. PROFILE SETTINGS TABLES (Profile Visibility Page)
   Applies to both BuddyBoss and UPP privacy settings tables.
   ========================================================================== */
.profile-settings.bp-tables-user tbody tr {
    background-color: transparent !important;
}

.profile-settings.bp-tables-user tbody tr:hover {
    background-color: var(--bb-content-background-color) !important;
}

.profile-settings.bp-tables-user tbody tr td {
    border-bottom: 1px solid var(--bb-content-border-color);
}

/* ==========================================================================
   11. SIDEBAR WIDGET TITLE LINKS (Consistent White Color)
   Makes linked widget titles (like Members) match non-linked ones (like Groups).
   ========================================================================== */
body:not(.wp-admin) .widget-title a,
body:not(.wp-admin) h2.widget-title a {
    color: inherit !important;
    text-decoration: none;
    transition: color 0.2s;
}

body:not(.wp-admin) .widget-title a:hover,
body:not(.wp-admin) h2.widget-title a:hover {
    color: var(--bb-primary-color) !important;
}

/* ==========================================================================
   12. PROFILE IDENTITY (Wisdom Quote & Nicename)
   Ensures the profile header quote and username are readable in both modes.
   ========================================================================== */
#buddypress #item-header-content .user-nicename,
#buddypress #item-header-content .activity-update {
    color: var(--bb-body-text-color) !important;
    font-style: italic;
    opacity: 0.9;
    font-size: 1.1em;
}

/* ==========================================================================
   13. MOBILE: SCROLLABLE CODEX SUB-TABS WITH ARROW INDICATORS
   A wrapper div (.upp-scroll-wrapper) is injected by JS on mobile.
   Arrow indicators (‹ ›) sit outside the wrapper to signal more tabs.
   ========================================================================== */

/* Desktop: arrows hidden */
.upp-scroll-hint-left,
.upp-scroll-hint-right {
    display: none;
}

@media screen and (max-width: 768px) {

    /* Make nav a flex row so wrapper + arrows sit side by side */
    #subnav {
        display: flex !important;
        align-items: center;
        gap: 0;
    }

    /* Scroll container = our wrapper div (no BB CSS baggage) */
    .upp-scroll-wrapper {
        flex: 1;
        min-width: 0;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .upp-scroll-wrapper::-webkit-scrollbar {
        display: none;
    }

    /* The <ul> extends beyond the wrapper → creates scroll */
    .upp-scroll-wrapper > ul.subnav {
        display: flex !important;
        flex-wrap: nowrap !important;
        width: max-content !important;
        gap: 4px;
    }

    .upp-scroll-wrapper > ul.subnav > li {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        display: inline-flex !important;
    }

    /* Arrow indicators — non-interactive, gold, subtle */
    .upp-scroll-hint-left,
    .upp-scroll-hint-right {
        display: none; /* hidden by default, JS adds .visible */
        flex-shrink: 0;
        width: 20px;
        text-align: center;
        font-size: 18px;
        color: #DAA520;
        opacity: 0.7;
        user-select: none;
        pointer-events: none;
    }

    .upp-scroll-hint-left.visible,
    .upp-scroll-hint-right.visible {
        display: block;
    }
}

