// =============================================================================
//  Plans / packages
//
//  Deliberately a table rather than a grid of cards: an operator on this page is
//  comparing plans against each other — price against subscribers against what
//  each earned — and cards make columns impossible to scan down.
// =============================================================================

.plans { --plans-accent: #34d399; }

.plans-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.plans-title {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--bs-emphasis-color);

    em { font-style: normal; color: var(--plans-accent); }
}

.plans-lead {
    margin: 0.25rem 0 0;
    color: var(--bs-secondary-color);
    font-size: 0.85rem;
}

.plans-new {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.95rem;
    border-radius: 999px;
    background: var(--plans-accent);
    color: #04231a;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;

    &:hover { filter: brightness(1.08); color: #04231a; }
}

.plans-flash {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
    padding: 0.65rem 0.9rem;
    border-radius: 0.6rem;
    border: 1px solid color-mix(in srgb, var(--plans-accent) 40%, transparent);
    background: color-mix(in srgb, var(--plans-accent) 10%, transparent);
    font-size: 0.85rem;

    &.is-bad {
        border-color: rgba(244, 63, 94, 0.4);
        background: rgba(244, 63, 94, 0.1);
    }

    span { flex: 1; }

    button {
        border: 0;
        background: transparent;
        color: inherit;
        font-size: 1.15rem;
        line-height: 1;
        cursor: pointer;
    }
}

// --- Summary strip -----------------------------------------------------------
.plans-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    margin-bottom: 1.1rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 12px;
    overflow: hidden;
}

.plans-stat {
    padding: 0.85rem 1rem;
    border-right: 1px solid var(--bs-border-color);

    &:last-child { border-right: 0; }
}

.plans-stat__k {
    display: block;
    color: var(--bs-secondary-color);
    font-size: 0.72rem;
    font-weight: 600;
}

.plans-stat__v {
    display: block;
    margin-top: 0.2rem;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--bs-emphasis-color);
}

.plans-stat__s {
    display: block;
    color: var(--bs-secondary-color);
    font-size: 0.72rem;
}

// --- Filter bar --------------------------------------------------------------
.plans-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}

.plans-pills { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.plans-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.8rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 999px;
    background: transparent;
    color: var(--bs-secondary-color);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;

    span {
        padding: 0.05rem 0.4rem;
        border-radius: 999px;
        background: var(--bs-tertiary-bg);
        font-size: 0.72rem;
    }

    &:hover { color: var(--bs-emphasis-color); }

    &.is-on {
        border-color: var(--bs-emphasis-color);
        background: var(--bs-emphasis-color);
        color: var(--bs-body-bg);

        span { background: rgba(0, 0, 0, 0.18); color: inherit; }
    }
}

.plans-search {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 15rem;
    flex: 0 1 20rem;

    i {
        position: absolute;
        left: 0.75rem;
        color: var(--bs-secondary-color);
        font-size: 0.85rem;
        pointer-events: none;
    }

    input {
        width: 100%;
        padding: 0.45rem 0.75rem 0.45rem 2rem;
        border: 1px solid var(--bs-border-color);
        border-radius: 999px;
        background: var(--bs-body-bg);
        color: inherit;
        font-size: 0.83rem;
        outline: none;

        &:focus { border-color: var(--plans-accent); }
    }
}

// --- Table -------------------------------------------------------------------
.plans-table-wrap {
    border: 1px solid var(--bs-border-color);
    border-radius: 12px;
    overflow-x: auto;
}

.plans-table {
    width: 100%;
    min-width: 46rem;
    margin: 0;
    border-collapse: collapse;
    font-size: 0.86rem;

    thead th {
        padding: 0.65rem 0.9rem;
        border-bottom: 1px solid var(--bs-border-color);
        background: var(--bs-tertiary-bg);
        color: var(--bs-secondary-color);
        font-size: 0.7rem;
        font-weight: 600;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        white-space: nowrap;
    }

    tbody td {
        padding: 0.6rem 0.9rem;
        border-bottom: 1px solid var(--bs-border-color);
        vertical-align: middle;
    }

    tbody tr:last-child td { border-bottom: 0; }

    .ta-r { text-align: right; }
}

.plans-row:hover { background: var(--bs-tertiary-bg); }

.plans-name {
    display: block;
    color: inherit;
    text-decoration: none;
}

.plans-name__t {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    color: var(--bs-emphasis-color);
}

.plans-name__m {
    display: block;
    margin-top: 0.1rem;
    color: var(--bs-secondary-color);
    font-size: 0.74rem;

    b { font-weight: 600; }
}

.plans-tag {
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
    font-size: 0.58rem;
    font-style: normal;
    font-weight: 700;
    letter-spacing: 0.06em;

    &--pop { background: rgba(251, 191, 36, 0.18); color: #fbbf24; }
    &--offer { background: rgba(168, 85, 247, 0.18); color: #c084fc; }
}

.plans-devices {
    margin-left: 0.35rem;
    padding: 0.05rem 0.3rem;
    border-radius: 0.25rem;
    background: var(--bs-tertiary-bg);
    font-size: 0.68rem;
    font-style: normal;
}

// A plan with no length cannot be enforced, so it says so where it is read.
.plans-warn {
    margin-left: 0.35rem;
    padding: 0.05rem 0.35rem;
    border-radius: 0.25rem;
    background: rgba(244, 63, 94, 0.16);
    color: #fb7185;
    font-size: 0.68rem;
    font-style: normal;
    font-weight: 600;
}

.plans-price { font-weight: 600; color: var(--bs-emphasis-color); white-space: nowrap; }

.plans-type {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border-radius: 0.3rem;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    background: var(--bs-tertiary-bg);
    color: var(--bs-secondary-color);

    &--hotspot { background: rgba(52, 211, 153, 0.16); color: #34d399; }
    &--pppoe { background: rgba(59, 130, 246, 0.16); color: #60a5fa; }
    &--bundle { background: rgba(168, 85, 247, 0.16); color: #c084fc; }
    &--tv { background: rgba(251, 191, 36, 0.16); color: #fbbf24; }
    &--trial { background: rgba(148, 163, 184, 0.18); color: #94a3b8; }
}

.plans-status {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border-radius: 0.3rem;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.05em;

    &--live { background: rgba(52, 211, 153, 0.16); color: #34d399; }
    &--hidden { background: rgba(148, 163, 184, 0.18); color: #94a3b8; }
    &--off { background: rgba(244, 63, 94, 0.16); color: #fb7185; }
}

.plans-dots {
    padding: 0.15rem 0.45rem;
    border: 0;
    border-radius: 0.35rem;
    background: transparent;
    color: var(--bs-secondary-color);
    cursor: pointer;

    &:hover { background: var(--bs-tertiary-bg); color: var(--bs-emphasis-color); }
}

.plans-menu {
    --bs-dropdown-min-width: 11rem;
    font-size: 0.85rem;
}

.plans-menu__danger { color: #fb7185; }

.plans-empty {
    padding: 2.25rem 1rem !important;
    text-align: center;
    color: var(--bs-secondary-color);
}

// --- Delete confirmation -----------------------------------------------------
.plans-scrim {
    position: fixed;
    inset: 0;
    z-index: 1060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(2, 6, 23, 0.6);
}

.plans-dialog {
    width: 100%;
    max-width: 25rem;
    padding: 1.25rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 12px;
    background: var(--bs-body-bg);

    h6 { margin: 0 0 0.5rem; font-size: 1rem; font-weight: 700; }
    p { margin: 0; color: var(--bs-secondary-color); font-size: 0.85rem; line-height: 1.5; }
}

.plans-dialog__foot {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.1rem;
}

// =============================================================================
//  Create / edit a package
//
//  Sectioned rather than one long form: most of these controls are optional
//  refinements (burst, fair use, schedule, which routers) and only four fields
//  are actually needed to sell something. Grouping them lets an operator fill in
//  the top and stop.
// =============================================================================

.pform { max-width: 46rem; }

.pform-head { margin-bottom: 1.25rem; }

.pform-title {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--bs-emphasis-color);

    em { font-style: normal; color: var(--plans-accent); }
}

.pform-lead {
    margin: 0.25rem 0 0;
    color: var(--bs-secondary-color);
    font-size: 0.85rem;
}

.pform-sec {
    margin-bottom: 0.9rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 12px;
    overflow: hidden;
}

.pform-sec__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1.05rem;
    background: var(--bs-tertiary-bg);
    border-bottom: 1px solid var(--bs-border-color);

    h6 {
        margin: 0;
        font-size: 0.82rem;
        font-weight: 600;
        color: var(--bs-emphasis-color);
    }

    // "optional" — says which sections can be skipped without reading them.
    > span {
        color: var(--bs-secondary-color);
        font-size: 0.72rem;
    }
}

.pform-sec__body { padding: 1.05rem; }

.pform-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 0.9rem 1rem;
}

.pform-field {
    min-width: 0;

    &--full { grid-column: 1 / -1; }
}

.pform-label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.82rem;
    font-weight: 600;

    // Required is marked on the field, not explained in a legend nobody reads.
    b { color: #fb7185; font-weight: 700; }
}

.pform-hint {
    display: block;
    margin-top: 0.25rem;
    color: var(--bs-secondary-color);
    font-size: 0.72rem;
    line-height: 1.4;
}

.pform-warn {
    display: block;
    margin-top: 0.25rem;
    color: #fb7185;
    font-size: 0.72rem;
    line-height: 1.4;
}

// --- Availability segmented control ------------------------------------------
.pform-seg { display: inline-flex; border: 1px solid var(--bs-border-color); border-radius: 0.5rem; overflow: hidden; }

.pform-seg button {
    padding: 0.35rem 0.85rem;
    border: 0;
    border-right: 1px solid var(--bs-border-color);
    background: transparent;
    color: var(--bs-secondary-color);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;

    &:last-child { border-right: 0; }
    &:hover { color: var(--bs-emphasis-color); }

    &.is-on { background: var(--plans-accent); color: #04231a; }
}

// --- Toggle rows (FUP, schedule) ---------------------------------------------
.pform-toggle {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
}

.pform-toggle__body { flex: 1; min-width: 0; }

.pform-toggle__label { display: block; font-size: 0.85rem; font-weight: 600; }

.pform-toggle__hint {
    display: block;
    margin-top: 0.1rem;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    line-height: 1.4;
}

.pform-toggle__state {
    flex: none;
    align-self: center;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    font-weight: 600;
}

.pform-switch {
    flex: none;
    align-self: center;
    width: 2.4rem;
    height: 1.35rem;
    accent-color: var(--plans-accent);
    cursor: pointer;
}

// --- NAS picker ---------------------------------------------------------------
.pform-nas {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    gap: 0.5rem;
}

.pform-nas__item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    cursor: pointer;

    &:hover { border-color: var(--bs-secondary-color); }

    input { flex: none; accent-color: var(--plans-accent); }

    b { flex: 1; font-size: 0.82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    span { color: var(--bs-secondary-color); font-size: 0.72rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
}

// --- Footer -------------------------------------------------------------------
.pform-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 0.25rem;
}
