﻿/* ══════════════════════════════════════════════════════════════
   ENIX 3.0 — /SN_Commissions
   (Client\Pages\Commissions\SocialNetwork_Commissions.razor)
   --------------------------------------------------------------
   La pantalla es hermana de /SN_Payments: la cáscara (topbar, chips,
   tarjetas, filtros, badges, paginado, botón de Excel) sale toda de
   enix-pay.css, que se carga global. Acá sólo va lo que comisiones
   tiene y cobranzas no: desplegable de plataforma, tabla propia,
   tarjeta de pendiente, donut y tendencia.

   La tabla NO reusa .enix-pay-table a propósito: el mobile de
   enix-pay.css define grid-template-areas con los nombres de las
   celdas de cobranzas, que no son las de acá.
   ══════════════════════════════════════════════════════════════ */

/* 230px es el ancho al que entra "— Todas las plataformas —", pero va como base y no como
   piso: sin shrink el combo no cede y empuja el resto fuera de pantalla. */
.enix-comm-platform-combo {
    flex: 0 1 230px;
    min-width: 0;
}

/* ══════════════════════════════════════════════════════════════
   1. CUERPO — columna principal + sidebar
   ══════════════════════════════════════════════════════════════ */
.enix-comm-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 16px;
    align-items: start;
    padding: 0 24px 24px;
}

.enix-comm-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.enix-comm-sidebar {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-top: 16px;
}

/* La tabla ya trae su propio padding de sección desde enix-pay.css. */
.enix-comm-main > .enix-pay-table-section {
    padding: 16px 0 0;
}

/* ══════════════════════════════════════════════════════════════
   2. SWITCH DE ALCANCE — todas / solo las mías
   Va en la barra de la tabla, al lado del botón de Excel, y solo se renderiza
   para admin general y dueño de agencia.
   ══════════════════════════════════════════════════════════════ */
.enix-comm-scope {
    display: flex;
    align-items: center;
    gap: 9px;
    flex: 0 0 auto;
}

/* Las dos opciones quedan siempre a la vista y la activa en navy: así se lee qué está
   mostrando sin tener que interpretar la posición de la perilla. */
.enix-comm-scope__label {
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    white-space: nowrap;
    transition: color .18s;
}

.enix-comm-scope__label--active {
    color: #0d2240;
}

.enix-comm-scope__switch {
    position: relative;
    flex: 0 0 auto;
    width: 38px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: #cbd5e1;
    cursor: pointer;
    transition: background .18s;
}

    .enix-comm-scope__switch:hover {
        background: #b6c2d1;
    }

.enix-comm-scope__switch--on,
.enix-comm-scope__switch--on:hover {
    background: #4f8ef7;
}

.enix-comm-scope__knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15,23,42,.25);
    transition: transform .18s;
}

.enix-comm-scope__switch--on .enix-comm-scope__knob {
    transform: translateX(18px);
}

/* Separa el switch del botón de Excel, para que no se lea como una opción del export. */
.enix-comm-scope-sep {
    width: 1px;
    height: 20px;
    background: #e2e8f0;
    flex: 0 0 auto;
}

/* ══════════════════════════════════════════════════════════════
   3. TABLA DE COMISIONES
   Mismo look que .enix-pay-table, con celdas propias.
   ══════════════════════════════════════════════════════════════ */
.enix-comm-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

    .enix-comm-tbl th {
        padding: 10px 14px;
        text-align: left;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: #94a3b8;
        font-weight: 600;
        border-bottom: 1px solid #f1f5f9;
        background: #fff;
    }

    .enix-comm-tbl td {
        padding: 12px 14px;
        border-bottom: 1px solid #f8fafc;
        vertical-align: middle;
        color: #374151;
    }

    .enix-comm-tbl tr:last-child td {
        border-bottom: none;
    }

.enix-comm-row--master {
    cursor: pointer;
}

    .enix-comm-row--master:hover td {
        background: #f8fafc;
    }

.enix-comm-row--open td {
    background: #f8fafc;
}

.enix-comm-expander {
    display: inline-block;
    font-size: 10px;
    color: #94a3b8;
    transition: transform 0.15s;
}

.enix-comm-expander--open {
    transform: rotate(90deg);
    color: #4f8ef7;
}

.enix-comm-client-name {
    font-size: 13px;
    font-weight: 600;
    color: #0d2240;
}

.enix-comm-src-icon {
    font-size: 13px;
    margin-right: 3px;
}

.enix-comm-res-num {
    font-weight: 700;
    color: #64748b;
}

/* Localizador del proveedor: monoespaciado porque son codigos alfanumericos que se comparan y se
   copian a mano, y con espacio para que no se corten (es el dato con el que el agente reclama). */
.enix-comm-loc {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
    user-select: all;
}

.enix-comm-source {
    font-weight: 600;
    color: #475569;
}

.enix-comm-pkg {
    font-weight: 600;
    color: #0d2240;
}

.enix-comm-markup {
    font-size: 11px;
    color: #059669;
    margin-top: 2px;
}

.enix-comm-amount {
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: #0d2240;
}

.enix-comm-pct {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
}

/* ── Detalle desplegado ── */
.enix-comm-row--detail > td {
    background: #f8fafc;
    padding: 0 14px 12px;
}

.enix-comm-detail {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 14px;
}

.enix-comm-detail__item--wide {
    grid-column: 1 / -1;
}

.enix-comm-detail__key {
    display: block;
    font-size: 9.5px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 2px;
}

.enix-comm-detail__val {
    font-size: 12.5px;
    color: #374151;
}

.enix-comm-detail__actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

/* ══════════════════════════════════════════════════════════════
   4. SIDEBAR — pendiente / donut / tendencia
   ══════════════════════════════════════════════════════════════ */
.enix-comm-pending-card {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 10px;
    padding: 16px;
}

.enix-comm-pending-card__label {
    font-size: 11px;
    font-weight: 700;
    color: #b45309;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.enix-comm-pending-card__amount {
    font-family: 'Poppins', sans-serif;
    font-size: 26px;
    font-weight: 700;
    color: #d97706;
    line-height: 1.15;
    margin-top: 4px;
}

.enix-comm-pending-card__sub {
    font-size: 11px;
    color: #b45309;
    margin-bottom: 12px;
}

.enix-comm-pending-breakdown {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 10px;
    border-top: 1px solid rgba(217, 119, 6, .25);
}

.enix-comm-pending-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 12.5px;
    color: #475569;
}

/* Same card for "processing payment" (orange) and "collected" (green), see BuildSideCards. */
.enix-comm-pending-card--processing {
    background: #fff7ed;
    border-color: #fdba74;
}

    .enix-comm-pending-card--processing .enix-comm-pending-card__label,
    .enix-comm-pending-card--processing .enix-comm-pending-card__sub {
        color: #c2410c;
    }

    .enix-comm-pending-card--processing .enix-comm-pending-card__amount {
        color: #ea580c;
    }

    .enix-comm-pending-card--processing .enix-comm-pending-breakdown {
        border-top-color: rgba(234, 88, 12, .25);
    }

.enix-comm-pending-card--paid {
    background: #f0fdf4;
    border-color: #86efac;
}

    .enix-comm-pending-card--paid .enix-comm-pending-card__label,
    .enix-comm-pending-card--paid .enix-comm-pending-card__sub {
        color: #15803d;
    }

    .enix-comm-pending-card--paid .enix-comm-pending-card__amount {
        color: #16a34a;
    }

    .enix-comm-pending-card--paid .enix-comm-pending-breakdown {
        border-top-color: rgba(22, 163, 74, .25);
    }

.enix-comm-donut-section,
.enix-comm-trend-section {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px;
}

.enix-comm-donut-title,
.enix-comm-trend-title {
    font-size: 12px;
    font-weight: 700;
    color: #0d2240;
    margin-bottom: 14px;
}

.enix-comm-trend-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

    .enix-comm-trend-head .enix-comm-trend-title {
        margin-bottom: 0;
    }

.enix-comm-trend-tabs {
    display: flex;
    background: #f1f5f9;
    border-radius: 7px;
    padding: 2px;
    flex-shrink: 0;
}

.enix-comm-trend-tab {
    border: none;
    background: transparent;
    color: #64748b;
    font-family: 'Mulish', sans-serif;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 9px;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s;
}

    .enix-comm-trend-tab:hover {
        color: #0d2240;
    }

.enix-comm-trend-tab--active {
    background: #fff;
    color: #0d2240;
    box-shadow: 0 1px 2px rgba(15,23,42,.08);
}

/* Cada renglón manda la torta: se toca y el donut mide ese mes o trimestre. */
.enix-comm-trend-row--selected .enix-comm-trend-label,
.enix-comm-trend-row--selected .enix-comm-trend-amount {
    color: #2563eb;
}

.enix-comm-trend-row--selected .enix-comm-trend-bar-wrap {
    box-shadow: 0 0 0 2px #bfdbfe;
}

.enix-comm-trend-clear {
    margin-top: 10px;
    width: 100%;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 6px;
    padding: 5px 10px;
    font-family: 'Mulish', sans-serif;
    font-size: 11.5px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}

    .enix-comm-trend-clear:hover {
        border-color: #4f8ef7;
        color: #4f8ef7;
    }

.enix-comm-donut-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
}

.enix-comm-donut {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.enix-comm-donut-hole {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10.5px;
    font-weight: 700;
    color: #0d2240;
    text-align: center;
    box-shadow: inset 0 0 0 1px #e2e8f0;
}

.enix-comm-donut-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 12px;
    color: #64748b;
    min-width: 0;
}

    .enix-comm-donut-legend strong {
        color: #0d2240;
    }

.enix-comm-legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.enix-comm-trend-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    cursor: pointer;
}

    .enix-comm-trend-row:hover .enix-comm-trend-label,
    .enix-comm-trend-row:hover .enix-comm-trend-amount {
        color: #2563eb;
    }

.enix-comm-trend-label {
    font-size: 11.5px;
    font-weight: 600;
    color: #94a3b8;
    width: 34px;
    flex-shrink: 0;
    text-transform: capitalize;
}

.enix-comm-trend-bar-wrap {
    flex: 1;
    height: 8px;
    background: #f1f5f9;
    border-radius: 999px;
    overflow: hidden;
}

.enix-comm-trend-bar {
    height: 100%;
    background: linear-gradient(90deg, #4f8ef7, #2dd4bf);
    border-radius: 999px;
}

.enix-comm-trend-amount {
    font-size: 11.5px;
    font-weight: 700;
    color: #0d2240;
    width: 62px;
    flex-shrink: 0;
    text-align: right;
}

/* ══════════════════════════════════════════════════════════════
   4b. MARK AS PAID — base agency only
   Checkbox column, selection bar and the payment modal.
   ══════════════════════════════════════════════════════════════ */
.enix-comm-td--sel {
    width: 34px;
    text-align: center;
}

    .enix-comm-td--sel input[type="checkbox"] {
        width: 16px;
        height: 16px;
        cursor: pointer;
        accent-color: #2563eb;
    }

.enix-comm-selbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 9px 12px;
    margin-bottom: 10px;
    border: 1px solid #bfdbfe;
    border-radius: 9px;
    background: #eff6ff;
    font-size: 12.5px;
    color: #0d2240;
}

    .enix-comm-selbar strong {
        font-weight: 700;
    }

    .enix-comm-selbar .enix-btn-primary {
        margin-left: auto;
    }

.enix-comm-paymodal__summary {
    padding: 10px 12px;
    margin-bottom: 14px;
    border-radius: 8px;
    background: #f8fafc;
    font-size: 13px;
}

.enix-comm-paymodal__field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

    .enix-comm-paymodal__field label {
        font-size: 11px;
        font-weight: 700;
        color: #64748b;
        text-transform: uppercase;
        letter-spacing: .4px;
    }

    .enix-comm-paymodal__field input,
    .enix-comm-paymodal__field select {
        width: 100%;
        padding: 8px 10px;
        border: 1px solid #e2e8f0;
        border-radius: 7px;
        font-size: 13px;
        background: #fff;
    }

.enix-comm-paymodal__hint {
    font-size: 11.5px;
    color: #94a3b8;
}

.enix-comm-paymodal__error {
    padding: 8px 10px;
    border-radius: 7px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 12.5px;
}

/* Receipt viewer */
.enix-modal__dialog.enix-comm-receipt {
    max-width: 900px;
    height: calc(100vh - 40px);
}

.enix-comm-receipt__body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: #f1f5f9;
}

.enix-comm-receipt__img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, .12);
}

.enix-comm-receipt__pdf {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 6px;
    background: #fff;
}

.enix-comm-receipt__name {
    margin-right: auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: #64748b;
}

/* ══════════════════════════════════════════════════════════════
   5. MOBILE
   Mismo criterio que enix-pay.css: sin duplicar markup, la tabla se
   reordena como cards con grid-template-areas y la clave de cada dato
   sale de data-label.
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
    /* El sidebar deja de tener ancho fijo antes de bajar. */
    .enix-comm-body {
        grid-template-columns: minmax(0, 1fr) 260px;
    }
}

@media (max-width: 900px) {
    .enix-comm-body {
        grid-template-columns: minmax(0, 1fr);
        padding: 0 12px 20px;
    }

    .enix-comm-sidebar {
        padding-top: 0;
        padding-bottom: 4px;
    }
}

@media (max-width: 768px) {

    /* El wrap es lo que le permite al desplegable bajar a su propio renglón debajo de los
       chips. Va con :has para no tocar el topbar de cobranzas, que scrollea en vez de
       envolver. */
    .enix-pay-topbar__actions:has(.enix-comm-platform-combo) {
        flex-wrap: wrap;
        overflow-x: visible;
        justify-content: flex-end;
    }

    .enix-pay-topbar__actions .enix-comm-platform-combo {
        flex: 1 1 100%;
        order: 1;
    }

    .enix-pay-table-meta .enix-comm-scope {
        order: 3;
        flex: 1 1 100%;
        justify-content: center;
        gap: 8px;
    }

    /* En renglones separados el divisor no separa nada. */
    .enix-comm-scope-sep {
        display: none;
    }

    /* ── TABLA → CARDS ─────────────────────────────────────────
       Aplica igual a las filas reales y a las del skeleton, porque
       comparten las mismas clases de <td>. */
    .enix-comm-tbl thead {
        display: none;
    }

    .enix-comm-tbl,
    .enix-comm-tbl tbody {
        display: block;
        width: 100%;
        background: transparent;
        box-shadow: none;
    }

    .enix-comm-tbl tbody tr.enix-comm-row--master {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-areas:
            "client  status"
            "loc     source"
            "date    date"
            "hotel   hotel"
            "pkg     comm"
            "exp     exp";
        align-items: start;
        gap: 9px 10px;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 10px;
        margin-bottom: 10px;
        overflow: hidden;
        padding: 11px 12px 0;
        box-shadow: 0 1px 3px rgba(15,23,42,.04), 0 8px 24px -18px rgba(15,23,42,.18);
    }

        .enix-comm-tbl tbody tr.enix-comm-row--master:hover td,
        .enix-comm-tbl tbody tr.enix-comm-row--open td {
            background: transparent;
        }

    .enix-comm-tbl tbody tr.enix-comm-row--master > td {
        display: block;
        border-bottom: none;
        padding: 0;
        text-align: left !important;
        min-width: 0;
        font-size: 12.5px;
        line-height: 1.3;
    }

    /* Clave del dato (FUENTE, PAQUETE, …) arriba de cada valor. */
    .enix-comm-tbl tbody td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 9.5px;
        font-weight: 700;
        color: #94a3b8;
        text-transform: uppercase;
        letter-spacing: .4px;
        margin-bottom: 2px;
    }

        /* En el skeleton la clave se reemplaza por una barra. Necesita el mismo
           prefijo que la regla de arriba para ganarle en especificidad. */
        .enix-comm-tbl tbody tr.enix-comm-row--skel td[data-label]::before {
            content: "";
            display: block;
            height: 9px;
            width: 55%;
            margin-bottom: 4px;
            border-radius: 3px;
            background: #eef1f6;
        }

    .enix-comm-td--client { grid-area: client; }
    .enix-comm-td--status { grid-area: status; text-align: right !important; }
    .enix-comm-td--loc    { grid-area: loc; }
    .enix-comm-td--source { grid-area: source; }
    .enix-comm-td--date   { grid-area: date; }
    .enix-comm-td--hotel  { grid-area: hotel; }
    .enix-comm-td--pkg    { grid-area: pkg; }
    .enix-comm-td--comm   { grid-area: comm; }
    .enix-comm-td--exp    { grid-area: exp; }
    .enix-comm-td--sel    { grid-area: sel; width: auto; }

    /* With a checkbox (base agency, unpaid row) the card gets one more row on top; paid rows
       have the cell empty and keep the usual card. */
    .enix-comm-tbl tbody tr.enix-comm-row--master > td.enix-comm-td--sel:not(:has(input)) {
        display: none;
    }

    .enix-comm-tbl tbody tr.enix-comm-row--master:has(> .enix-comm-td--sel input) {
        grid-template-areas:
            "sel     sel"
            "client  status"
            "loc     source"
            "date    date"
            "hotel   hotel"
            "pkg     comm"
            "exp     exp";
    }

    .enix-comm-tbl tbody tr.enix-comm-row--master > td.enix-comm-td--sel {
        text-align: left !important;
    }

    .enix-comm-tbl tbody tr.enix-comm-row--detail > td.enix-comm-td--sel {
        display: none;
    }

    .enix-comm-td--hotel,
    .enix-comm-td--pkg {
        border-top: 1px solid #f1f5f9;
        padding-top: 9px !important;
    }

    .enix-comm-td--comm {
        border-top: 1px solid #f1f5f9;
        padding-top: 9px !important;
    }

    .enix-comm-tbl tbody tr.enix-comm-row--master > td.enix-comm-td--exp {
        margin: 0 -12px;
        padding: 7px 0;
        text-align: center !important;
        background: #f8fafc;
        border-top: 1px solid #f1f5f9;
    }

    /* La card se toca entera: el triángulo indica abrir / cerrar. */
    .enix-comm-expander {
        font-size: 11px;
        transform: rotate(90deg);
    }

    .enix-comm-expander--open {
        transform: rotate(-90deg);
    }

    /* ── DETALLE: se pega a la card de arriba ── */
    .enix-comm-tbl tbody tr.enix-comm-row--master:has(+ .enix-comm-row--detail) {
        margin-bottom: 0;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }

    .enix-comm-tbl tbody tr.enix-comm-row--detail {
        display: block;
        margin-bottom: 10px;
        border: 1px solid #e2e8f0;
        border-top: none;
        border-radius: 0 0 10px 10px;
        overflow: hidden;
    }

        .enix-comm-tbl tbody tr.enix-comm-row--detail > td {
            display: block;
            padding: 10px 12px;
        }

            .enix-comm-tbl tbody tr.enix-comm-row--detail > td:first-child {
                display: none;
            }

    .enix-comm-detail {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px 12px;
    }

    .enix-comm-detail__actions .enix-pay-action-btn {
        width: 100%;
        text-align: center;
    }

    /* ── DONUT / TENDENCIA ── */
    .enix-comm-donut-wrap {
        gap: 14px;
    }
}

