/* ============================================
   LineupIQ Rules Module Styles
   ============================================ */

/* Rule Type Selector - Compact Tabs */
.rule-type-selector {
    margin-bottom: 1.25rem;
}

    .rule-type-selector .form-label {
        font-weight: 500;
        font-size: 0.875rem;
        margin-bottom: 0.5rem;
        display: block;
        color: var(--liq-text-primary);
    }

.rule-type-tabs {
    display: flex;
    background: var(--liq-bg-tertiary);
    border-radius: 0.5rem;
    padding: 0.25rem;
    gap: 0.25rem;
}

.rule-type-tab {
    flex: 1;
    cursor: pointer;
    margin: 0;
}

    .rule-type-tab input[type="radio"] {
        display: none;
    }

.rule-type-tab-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--liq-text-secondary);
    transition: all 0.15s ease;
    position: relative;
}

    .rule-type-tab-content i {
        font-size: 0.875rem;
    }

.rule-type-tab:hover .rule-type-tab-content {
    color: var(--liq-text-primary);
    background: var(--liq-bg-secondary);
}

.rule-type-tab input[type="radio"]:checked + .rule-type-tab-content {
    background: var(--liq-bg-secondary);
    color: var(--liq-accent-green);
    box-shadow: 0 1px 3px var(--liq-shadow);
}

.rule-type-tab.disabled {
    cursor: not-allowed;
}

    .rule-type-tab.disabled .rule-type-tab-content {
        opacity: 0.5;
    }

    .rule-type-tab.disabled:hover .rule-type-tab-content {
        background: transparent;
        color: var(--liq-text-secondary);
    }

.coming-soon-dot {
    width: 6px;
    height: 6px;
    background: var(--liq-accent-yellow);
    border-radius: 50%;
    position: absolute;
    top: 0.375rem;
    right: 0.375rem;
}

/* Rule Name Section */
.rule-name-section {
    margin-bottom: 1.25rem;
}

    .rule-name-section .form-label {
        font-weight: 500;
        font-size: 0.875rem;
        margin-bottom: 0.375rem;
        color: var(--liq-text-primary);
    }

        .rule-name-section .form-label .text-muted {
            color: var(--liq-text-secondary) !important;
        }

    .rule-name-section .form-control {
        background: var(--liq-bg-primary);
        border-color: var(--liq-border-color);
        color: var(--liq-text-primary);
    }

        .rule-name-section .form-control::placeholder {
            color: var(--liq-text-secondary);
        }

/* Rule Configuration Section */
.rule-config-section {
    background: var(--liq-bg-tertiary);
    border-radius: 0.5rem;
    padding: 1rem;
    border: 1px solid var(--liq-border-color);
}

.rule-config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--liq-text-primary);
}

.rule-player-search {
    display: flex;
    align-items: center;
    background: var(--liq-bg-secondary);
    border: 1px solid var(--liq-border-color);
    border-radius: 0.375rem;
    padding: 0.25rem 0.5rem;
}

    .rule-player-search i {
        color: var(--liq-text-secondary);
        margin-right: 0.375rem;
        font-size: 0.875rem;
    }

    .rule-player-search input {
        border: none;
        background: transparent;
        outline: none;
        font-size: 0.8125rem;
        width: 150px;
        color: var(--liq-text-primary);
    }

        .rule-player-search input::placeholder {
            color: var(--liq-text-secondary);
        }

/* Player List */
.rule-player-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--liq-border-color);
    border-radius: 0.375rem;
    background: var(--liq-bg-secondary);
}

.rule-player-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--liq-border-color);
    transition: background 0.15s ease;
}

    .rule-player-item:last-child {
        border-bottom: none;
    }

    .rule-player-item:hover {
        background: var(--liq-bg-tertiary);
    }

    .rule-player-item.selected {
        background: var(--liq-accent-green-active);
    }

        .rule-player-item.selected:hover {
            background: var(--liq-accent-green-active);
        }

.rule-player-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--liq-border-color);
    border-radius: 0.25rem;
    margin-right: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

    .rule-player-checkbox i {
        font-size: 0.75rem;
        color: white;
        opacity: 0;
        transition: opacity 0.15s ease;
    }

.rule-player-item.selected .rule-player-checkbox {
    background: var(--liq-accent-green);
    border-color: var(--liq-accent-green);
}

    .rule-player-item.selected .rule-player-checkbox i {
        opacity: 1;
    }

.rule-player-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.rule-player-name {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--liq-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rule-player-details {
    font-size: 0.75rem;
    color: var(--liq-text-secondary);
}

.rule-player-empty {
    padding: 2rem;
    text-align: center;
    color: var(--liq-text-secondary);
    font-size: 0.875rem;
}

/* Selected Summary */
.rule-selected-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--liq-border-color);
    font-size: 0.875rem;
}

    .rule-selected-summary span {
        color: var(--liq-text-primary);
    }

    .rule-selected-summary strong {
        color: var(--liq-accent-green);
    }

/* Constraint Row */
.rule-constraint-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--liq-border-color);
    font-size: 0.875rem;
    color: var(--liq-text-primary);
}

    .rule-constraint-row .form-select,
    .rule-constraint-row .form-control {
        background: var(--liq-bg-secondary);
        border-color: var(--liq-border-color);
        color: var(--liq-text-primary);
        font-size: 0.875rem;
    }

    .rule-constraint-row.aggregator-row {
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }

/* Aggregator Preview */
.aggregator-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--liq-accent-green-hover);
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    color: var(--liq-accent-green);
}

    .aggregator-preview i {
        flex-shrink: 0;
    }

/* Rules Dropdown Panel Styles */

/* Rule Item in Dropdown - Compact Single Line */
.rule-item {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.625rem;
    border-bottom: 1px solid var(--liq-border-color);
    transition: background 0.15s ease;
    gap: 0.5rem;
}

    .rule-item:last-child {
        border-bottom: none;
    }

    .rule-item:hover {
        background: var(--liq-bg-hover);
    }

    .rule-item.rule-disabled {
        opacity: 0.5;
    }

        .rule-item.rule-disabled .rule-item-name {
            text-decoration: line-through;
        }

.rule-item-toggle {
    flex-shrink: 0;
}

    .rule-item-toggle .form-check {
        margin: 0;
        padding: 0;
        min-height: auto;
    }

    .rule-item-toggle .form-check-input {
        width: 1.75rem;
        height: 0.875rem;
        margin: 0;
        cursor: pointer;
    }

        .rule-item-toggle .form-check-input:checked {
            background-color: var(--liq-accent-green);
            border-color: var(--liq-accent-green);
        }

.rule-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rule-item-icon {
    color: var(--liq-text-secondary);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.rule-item-name {
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--liq-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rule-item-separator {
    color: var(--liq-text-secondary);
    font-size: 0.75rem;
}

.rule-item-description {
    font-size: 0.75rem;
    color: var(--liq-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rule-item-actions {
    display: flex;
    gap: 0.125rem;
    opacity: 0;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
}

.rule-item:hover .rule-item-actions {
    opacity: 1;
}

.rule-item-actions .btn-icon {
    width: 22px;
    height: 22px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--liq-text-secondary);
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

    .rule-item-actions .btn-icon:hover {
        background: var(--liq-bg-tertiary);
        color: var(--liq-text-primary);
    }

.rule-item-actions .rule-delete-btn:hover {
    color: var(--liq-accent-red);
}

/* Empty State */
.rule-empty-message {
    padding: 1rem;
    text-align: center;
    color: var(--liq-text-secondary);
    font-size: 0.8125rem;
    font-style: italic;
}

/* Dropdown Panel Adjustments */
.dropdown-panel-section[data-category="stack"] .dropdown-panel-section-content {
    opacity: 0.6;
}

/* Rules Dropdown Enhancements */
.rules-dropdown-menu {
    min-width: 320px;
    padding: 0;
    border-radius: 8px;
    overflow: hidden;
}

    .rules-dropdown-menu .dropdown-panel-header {
        background: transparent;
        padding: 0.875rem 1rem 0.625rem;
        border-bottom: 1px solid var(--liq-border-color);
    }

    .rules-dropdown-menu .dropdown-panel-title {
        font-size: 0.8rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--liq-text-secondary);
    }

    .rules-dropdown-menu .dropdown-panel-section {
        border-bottom: 1px solid var(--liq-border-color);
    }

        .rules-dropdown-menu .dropdown-panel-section:last-child {
            border-bottom: none;
        }

    .rules-dropdown-menu .dropdown-panel-section-header {
        padding: 0.625rem 1rem;
        background: transparent;
        transition: background 0.15s ease;
    }

        .rules-dropdown-menu .dropdown-panel-section-header:hover {
            background: var(--liq-bg-hover);
        }

    .rules-dropdown-menu .dropdown-panel-section-name {
        font-size: 0.8rem;
        font-weight: 500;
        color: var(--liq-text-primary);
        display: flex;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
    }

.rules-category-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 0.35rem;
    font-size: 0.65rem;
    font-weight: 600;
    background: var(--liq-bg-tertiary);
    color: var(--liq-text-secondary);
    border-radius: 9px;
    margin-left: auto;
}

    .rules-category-count.has-rules {
        background: rgba(16, 185, 129, 0.15);
        color: var(--liq-accent-green);
    }

.rules-dropdown-menu .dropdown-panel-section-content {
    padding: 0.375rem 0.5rem;
    background: var(--liq-bg-primary);
}

.rules-dropdown-menu .rule-empty-message {
    padding: 0.75rem 1rem;
    text-align: center;
    color: var(--liq-text-secondary);
    font-size: 0.8rem;
    font-style: normal;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

    .rules-dropdown-menu .rule-empty-message i {
        font-size: 1.1rem;
        opacity: 0.4;
    }

.rules-dropdown-menu .dropdown-panel-footer {
    padding: 0.625rem 1rem;
    background: var(--liq-bg-tertiary);
    border-top: 1px solid var(--liq-border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.rules-dropdown-menu #addNewRuleBtn {
    flex: 1;
}

.rules-dropdown-menu #deleteAllRulesBtn {
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

    .rules-dropdown-menu #deleteAllRulesBtn:hover {
        opacity: 1;
    }

.rules-dropdown-menu.no-rules #deleteAllRulesBtn {
    display: none;
}

.rules-dropdown-menu .rule-item {
    border-radius: 4px;
    margin: 0.125rem 0;
    border-bottom: none;
}

    .rules-dropdown-menu .rule-item:hover {
        background: var(--liq-bg-hover);
    }

/* Rules Dropdown Styling */
.rules-dropdown-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--liq-border-color);
    background: var(--liq-bg-tertiary);
}

.rules-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--liq-text-primary);
}

.rules-dropdown-body {
    max-height: 300px;
    overflow-y: auto;
}

.rules-category {
    border-bottom: 1px solid var(--liq-border-color);
}

    .rules-category:last-child {
        border-bottom: none;
    }

.rules-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

    .rules-category-header:hover {
        background: var(--liq-bg-hover);
    }

.rules-category-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--liq-text-primary);
}

.rules-chevron {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
    color: var(--liq-text-secondary);
}

.rules-category-header[aria-expanded="true"] .rules-chevron,
.rules-category-header:not(.collapsed) .rules-chevron {
    transform: rotate(90deg);
}

.rules-category-content {
    padding: 0.5rem 1rem 0.75rem 2rem;
    background: var(--liq-bg-primary);
}

    .rules-category-content:empty::before {
        content: 'No rules configured';
        color: var(--liq-text-secondary);
        font-size: 0.85rem;
        font-style: italic;
    }

.rule-item-name {
    font-size: 0.85rem;
    color: var(--liq-text-primary);
}

.rule-item-actions {
    display: flex;
    gap: 0.25rem;
}

    .rule-item-actions .btn {
        padding: 0.15rem 0.35rem;
        font-size: 0.75rem;
    }

.rules-dropdown-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--liq-border-color);
    background: var(--liq-bg-tertiary);
}

/* Rules Player Filter Indicator */
.player-filter-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.75rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--liq-border-color);
}

/* Reset projections button - warning style when visible */
#resetProjectionsBtn {
    transition: opacity 0.15s ease;
}

    #resetProjectionsBtn:hover {
        background-color: var(--bs-warning);
        border-color: var(--bs-warning);
        color: #000;
    }

/* Mobile adjustments */
@media (max-width: 768px) {
    /* Center the rules dropdown in the viewport so it can't be clipped
       by the .panel-left container or pushed off-screen by Popper. */
    .rules-dropdown-menu.dropdown-menu.show {
        position: fixed !important;
        inset: auto !important;
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        bottom: auto !important;
        transform: translate(-50%, -50%) !important;
        width: calc(100vw - 2rem);
        max-width: 420px;
        min-width: 0; /* override the 320px above */
        max-height: 80vh;
        overflow-y: auto;
        margin: 0;
        z-index: 1055;
    }

    /* Existing tweaks — keep these */
    .rules-dropdown-menu .dropdown-panel-section-name span {
        display: none;
    }

    .rules-dropdown-menu .dropdown-panel-section-name {
        justify-content: center;
    }

    .rules-dropdown-menu .dropdown-panel-section-header {
        padding: 0.75rem;
    }
}

/* Library Rule Badge */
.rule-item-library-badge {
    display: inline-block;
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--liq-accent-green, #10b981);
    color: #fff;
    margin-right: 4px;
    vertical-align: middle;
    line-height: 1.2;
}

.rule-disabled .rule-item-library-badge {
    opacity: 0.4;
}

/* ============================================
   Team Stack Modal - Segmented Cards
   ============================================ */

/* Card container: each stage of the stack workflow is its own bordered
   section (primary stack / bring-back), matching the grouped layout of
   the rule item cards elsewhere in the app */
.stack-card {
    border: 1px solid var(--liq-border-color);
    border-radius: 8px;
    background: var(--liq-bg-secondary);
    margin-bottom: 14px;
    overflow: hidden;
}

.stack-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--liq-text-secondary);
    background: var(--liq-bg-tertiary);
    border-bottom: 1px solid var(--liq-border-color);
}

    .stack-card-header i {
        font-size: 0.85rem;
    }

.stack-card-primary {
    border-left: 3px solid var(--liq-accent-green);
}

    .stack-card-primary .stack-card-header i {
        color: var(--liq-accent-green);
    }

.stack-card-bringback {
    border-left: 3px solid var(--liq-accent-yellow);
}

    .stack-card-bringback .stack-card-header i {
        color: var(--liq-accent-yellow);
    }

.stack-card-body {
    padding: 14px;
}

    .stack-card-body .form-label {
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--liq-text-primary);
        margin-bottom: 6px;
    }

/* Checkbox clusters (positions / order spots / teams) share one style */
.stack-check-row {
    display: flex;
    align-items: center;
    gap: 8px 16px;
    flex-wrap: wrap;
    padding: 10px 12px;
    border-radius: 6px;
    background: var(--liq-bg-tertiary);
    border: 1px solid var(--liq-border-color);
}

    .stack-check-row .form-check {
        margin: 0;
        padding-left: 1.4em;
    }

    .stack-check-row .form-check-input:checked {
        background-color: var(--liq-accent-green);
        border-color: var(--liq-accent-green);
    }

/* Teams list can grow (NFL: 32) - cap height and scroll */
.stack-team-row {
    max-height: 96px;
    overflow-y: auto;
}

/* Bring-back activation: a distinct dashed "add a section" affordance
   between the two cards */
.stack-bringback-toggle {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    margin-bottom: 14px;
    border: 1px dashed var(--liq-border-color);
    border-radius: 8px;
    background: var(--liq-bg-secondary);
    transition: border-color 0.15s ease, background 0.15s ease;
}

    .stack-bringback-toggle:hover {
        border-color: var(--liq-accent-green);
        background: var(--liq-bg-hover);
    }

    .stack-bringback-toggle .form-check-label {
        cursor: pointer;
        color: var(--liq-text-primary);
        font-weight: 600;
        font-size: 0.85rem;
        user-select: none;
    }

    .stack-bringback-toggle .form-check-input {
        cursor: pointer;
    }

        .stack-bringback-toggle .form-check-input:checked {
            background-color: var(--liq-accent-green);
            border-color: var(--liq-accent-green);
        }

.stack-toggle-hint {
    color: var(--liq-text-secondary);
    font-weight: 400;
    font-size: 0.8rem;
}

/* Exposure control: slim bordered card so it reads as its own step
   (shared by team and golf stack modes) */
.stack-exposure-card {
    border: 1px solid var(--liq-border-color);
    border-radius: 8px;
    background: var(--liq-bg-secondary);
    padding: 12px 14px;
}

    .stack-exposure-card .form-label {
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--liq-text-primary);
    }

/* ============================================
   Card Layout - All Rule Types
   ============================================ */

/* Flatten the outer config wrapper: the section cards are the visual
   containers now, so the old tertiary-background frame just cost width
   and produced a double-border effect */
.rule-config-section {
    background: transparent;
    border: none;
    padding: 0;
}

/* Connector arrow between IF and THEN cards */
.conditional-connector {
    display: flex;
    justify-content: center;
    margin: 2px 0 10px;
    color: var(--liq-text-secondary);
    font-size: 1.15rem;
}

/* Last card in a section carries no trailing gap (the modal body
   spacing takes over) */
.rule-config-section .stack-card:last-child {
    margin-bottom: 0;
}
