/* Front-end pieces only (the My Account tab, the standalone
 * [mlm_dashboard] page, and the [mlm_genealogy] shortcode) pick up the
 * active theme's Elementor Global Fonts/Colors via CSS custom
 * properties, each with a fallback equal to the previous hardcoded
 * value. That fallback is what actually renders in two cases: a site
 * without Elementor (nothing changes), and the wp-admin Members/
 * Genealogy pages — Elementor never defines these variables inside
 * wp-admin, so admin screens keep their native WordPress styling
 * automatically, with no extra code needed to exclude them.
 *
 * Elementor's four Global Colors/Fonts (Primary, Secondary, Text,
 * Accent) are applied by their common convention: Primary for the
 * brand's main accent (headings, key numbers), Text for body copy.
 * Structural chrome (card borders/backgrounds, table lines) and status
 * colors (the suspended badge, the destructive Reset link) are left as
 * plain neutral/semantic colors on purpose — those communicate state,
 * not brand, and shouldn't shift with the color palette. */
.mlm-dashboard,
.mlm-orgchart {
    font-family: var(--e-global-typography-text-font-family, inherit);
}

.mlm-dashboard .mlm-stats {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Welcome header — member's avatar sits inline with the greeting text
 * itself (not a separate block above/beside it), shown above the stats no
 * matter which tab is active. */
.mlm-welcome {
    margin: 0 0 1.25rem;
    font-size: 1.05rem;
    line-height: 40px; /* matches the avatar's height so text centers on it */
}

.mlm-welcome-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #e2e2e2;
    vertical-align: middle;
    margin-right: 0.6rem;
}

.mlm-welcome-greeting {
    color: var(--e-global-color-primary, #6b7280);
}

.mlm-welcome-name {
    font-weight: 700;
    font-family: var(--e-global-typography-primary-font-family, inherit);
    color: var(--e-global-color-text, #1d2327);
}

.mlm-stat-card {
    background: #f7f7f7;
    border: 1px solid #e2e2e2;
    border-radius: 6px;
    padding: 1rem 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.mlm-stat-label {
    font-size: 0.85rem;
    color: #666;
}

.mlm-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 0.25rem;
    color: var(--e-global-color-primary, inherit);
}

/* Wallet balance stat card, before the member has purchased anything
 * this month — the amount is withheld and this "Locked" placeholder plus
 * a short hint show in its place instead. */
.mlm-stat-value-locked {
    color: #9aa0a6;
}

.mlm-stat-hint {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.2rem;
}

.mlm-referral-input {
    width: 100%;
    max-width: 480px;
    padding: 0.5rem;
    border: 1px solid var(--e-global-color-secondary, #ccc);
    border-radius: 4px;
    font-family: monospace;
}

/* Profile photo block, shown inside its own "Profile Photo" tab next to
 * "Payout Details". */
.mlm-profile-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.mlm-avatar-preview {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #e2e2e2;
    flex-shrink: 0;
}

.mlm-avatar-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.mlm-avatar-file-input {
    font-size: 0.85rem;
    max-width: 220px;
}

.mlm-btn-remove {
    background: none;
    color: #b32d2e;
    border: 1px solid #e6b3ae;
    border-radius: 4px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.mlm-btn-remove:hover {
    background: #fdf3f2;
}

/* Horizontal tabs grouping the dashboard's data sections (referral link,
 * commission plan, recent commissions, genealogy). Tab labels take over
 * the heading role the old per-section <h3>s used to play, so they pick
 * up the same Elementor Primary typography/color treatment those headings
 * had. */
.mlm-tabs-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    border-bottom: 1px solid #e2e2e2;
    margin-bottom: 1.25rem;
}

.mlm-tab-link {
    appearance: none;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--e-global-typography-primary-font-family, inherit);
    color: #6b7280;
    cursor: pointer;
}

.mlm-tab-link:hover {
    color: var(--e-global-color-text, #1d2327);
}

.mlm-tab-link.is-active {
    color: var(--e-global-color-primary, #1d2327);
    border-bottom-color: var(--e-global-color-primary, #1d2327);
}

.mlm-tab-panel {
    display: none;
}

.mlm-tab-panel.is-active {
    display: block;
}

/* "Payout Details" tab — editing the customer's own GCash number. */
.mlm-detail-field {
    margin-bottom: 1rem;
    max-width: 480px;
}

.mlm-detail-field label {
    font-weight: 600;
    font-size: 0.85rem;
}

.mlm-notice {
    padding: 0.6rem 0.9rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.mlm-notice-success {
    background: #eaf7ed;
    color: #1e7b34;
    border: 1px solid #bfe6c8;
}

.mlm-notice-error {
    background: #fdf3f2;
    color: #a23b32;
    border: 1px solid #e6b3ae;
}

.mlm-btn-save {
    background: var(--e-global-color-primary, #2271b1);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.55rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.mlm-btn-save:hover {
    opacity: 0.9;
}

.mlm-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

.mlm-table th,
.mlm-table td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #eee;
}

.mlm-link-danger {
    color: #b32d2e;
}

/* Graphical genealogy tree (org-chart style), shared by the customer
 * dashboard/shortcode and the admin Genealogy page. */
.mlm-orgchart {
    overflow-x: auto;
    padding: 1rem 0.5rem 1.5rem;
}

.mlm-org-tree,
.mlm-org-tree ul {
    display: flex;
    justify-content: center;
    list-style: none;
    margin: 0;
    padding: 0;
}

.mlm-org-tree ul {
    position: relative;
    padding-top: 2rem;
}

.mlm-org-tree li {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 0 0.9rem;
}

/* Horizontal connector between siblings. */
.mlm-org-tree li::before,
.mlm-org-tree li::after {
    content: '';
    position: absolute;
    top: 0;
    width: 50%;
    height: 2rem;
    border-top: 2px solid #c9ccd1;
}
.mlm-org-tree li::before {
    right: 50%;
    border-right: 2px solid #c9ccd1;
}
.mlm-org-tree li::after {
    left: 50%;
    border-left: 2px solid #c9ccd1;
}

/* Only child: no sideways connector, no extra top gap needed. */
.mlm-org-tree li:only-child {
    padding-top: 0;
}
.mlm-org-tree li:only-child::before,
.mlm-org-tree li:only-child::after {
    display: none;
}

/* First/last child: trim the connector that would otherwise stick out
 * past the edge of the row. */
.mlm-org-tree li:first-child::before,
.mlm-org-tree li:last-child::after {
    border-color: transparent;
}

/* Root level: nothing above it to connect to. */
.mlm-org-tree.mlm-org-tree--root > li::before,
.mlm-org-tree.mlm-org-tree--root > li::after {
    display: none;
}
.mlm-org-tree.mlm-org-tree--root > li {
    padding-top: 0;
}

/* Trunk connecting a card down to its children's horizontal bar. */
.mlm-org-tree li > ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 0;
    height: 2rem;
    border-left: 2px solid #c9ccd1;
}

.mlm-org-card {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    min-width: 130px;
    background: #fff;
    border: 1px solid #d8dade;
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Avatar sits inline right before the name, on the same line. */
.mlm-org-card-header {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.mlm-org-card-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #e2e2e2;
    flex-shrink: 0;
}

.mlm-org-card-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--e-global-color-text, #1d2327);
    white-space: nowrap;
}

.mlm-org-card-meta {
    font-size: 0.72rem;
    color: #6b7280;
    font-family: monospace;
    white-space: nowrap;
}

.mlm-org-card-referrals {
    font-size: 0.7rem;
    color: #6b7280;
    white-space: nowrap;
}

.mlm-org-card-downline {
    font-size: 0.7rem;
    color: #6b7280;
    white-space: nowrap;
}

.mlm-org-card.is-suspended {
    border-color: #e6b3ae;
    background: #fdf3f2;
}

.mlm-org-card-badge {
    font-size: 0.65rem;
    color: #a23b32;
    background: #fbe4e1;
    border-radius: 4px;
    padding: 0.05rem 0.35rem;
    margin-top: 0.1rem;
}

/* Admin Genealogy page chrome. */
.mlm-genealogy-search {
    margin: 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Commissions Log's Day/Month/Year filter. */
.mlm-log-filter {
    margin: 1rem 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.mlm-genealogy-matches {
    margin: 1rem 0;
    padding-left: 1.2rem;
}

.mlm-search-status {
    margin-left: 0.5rem;
    color: #6b7280;
    font-size: 0.85rem;
}

/* Sortable Members table column headers. */
th.mlm-sortable {
    cursor: pointer;
    user-select: none;
}

th.mlm-sortable a.mlm-sort-link {
    color: inherit;
    text-decoration: none;
    display: inline-block;
}

th.mlm-sortable:hover a.mlm-sort-link {
    text-decoration: underline;
}

th.mlm-sortable.mlm-sorted {
    color: #2271b1;
}

.mlm-sort-indicator {
    font-size: 0.75em;
}

/* Dim the neutral "sortable but not currently sorted" hint so the active
 * column's arrow still stands out. */
th.mlm-sortable:not(.mlm-sorted) .mlm-sort-indicator {
    opacity: 0.35;
}
