/**
 * pla.css - Estilos del modulo de Planificacion / Programacion
 * @version 4.0.0
 * @author Equipo ERP
 * @date 2026-05-28
 */

#plaModule {
    --pla-ink: #1f2937;
    --pla-muted: #6b7280;
    --pla-line: #d7dee8;
    --pla-panel: #ffffff;
    --pla-soft: #f6f8fb;
    --pla-blue: #2563eb;
    --pla-cyan: #0891b2;
    --pla-green: #16a34a;
    --pla-amber: #d97706;
    --pla-red: #dc2626;
    --pla-violet: #6d5bd0;
    color: var(--pla-ink);
}

.pla-header .text-muted {
    font-size: 0.9rem;
}

.pla-header-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.pla-filter-panel {
    background: var(--pla-panel);
    border: 1px solid var(--pla-line);
    border-radius: 8px;
    padding: 0.85rem;
    margin-bottom: 0.85rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.pla-filter-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(140px, 1fr));
    gap: 0.75rem;
}

.pla-filter-grid .form-group {
    margin-bottom: 0;
}

.pla-filter-grid label {
    margin-bottom: 0.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--pla-muted);
    text-transform: uppercase;
}

.pla-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.pla-stat-tile {
    min-height: 78px;
    background: var(--pla-panel);
    border: 1px solid var(--pla-line);
    border-left: 4px solid var(--pla-cyan);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.pla-stat-warning {
    border-left-color: var(--pla-amber);
}

.pla-stat-success {
    border-left-color: var(--pla-green);
}

.pla-stat-primary {
    border-left-color: var(--pla-blue);
}

.pla-stat-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--pla-muted);
    text-transform: uppercase;
}

.pla-stat-tile strong {
    display: block;
    margin-top: 0.2rem;
    font-size: 1.65rem;
    line-height: 1;
}

.pla-card {
    border: 1px solid var(--pla-line);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.pla-card > .card-header {
    background: var(--pla-panel);
    border-bottom: 1px solid var(--pla-line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.pla-table-scroll {
    width: 100%;
    overflow: auto;
    max-height: calc(100vh - 240px);
}

.pla-annual-table,
.pla-week-table,
.pla-detail-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.78rem;
}

.pla-annual-table th,
.pla-annual-table td,
.pla-week-table th,
.pla-week-table td {
    white-space: nowrap;
    vertical-align: middle;
}

.pla-annual-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #edf2f7;
    color: #111827;
    text-transform: uppercase;
    font-size: 0.7rem;
    border-color: var(--pla-line);
}

.pla-annual-table thead tr:nth-child(2) th {
    top: 31px;
}

.pla-month-head {
    background: #e6f3f5 !important;
    color: #0f5967 !important;
}

.pla-total-head,
.pla-total-cell {
    background: #f2efff !important;
}

.pla-sticky-col {
    position: sticky !important;
    left: 0;
    z-index: 8;
    background: #ffffff !important;
    box-shadow: 2px 0 4px rgba(15, 23, 42, 0.08);
}

.pla-annual-table thead .pla-sticky-col,
.pla-annual-table tfoot .pla-sticky-col {
    background: #edf2f7 !important;
}

.pla-col-activity {
    min-width: 250px;
    max-width: 250px;
    white-space: normal !important;
}

.pla-meta {
    background: #ecfdf5;
}

.pla-prog {
    background: #eff6ff;
}

.pla-ejec {
    background: #f8fafc;
}

.pla-pct-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 24px;
    border: 0;
    border-radius: 6px;
    overflow: hidden;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.pla-pct-button[disabled] {
    cursor: default;
    opacity: 0.95;
}

.pla-pct-button span {
    position: relative;
    z-index: 2;
}

.pla-pct-button i {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    opacity: 0.28;
    background: #ffffff;
}

.pla-pct-ok {
    background: var(--pla-green);
}

.pla-pct-warn {
    background: var(--pla-amber);
}

.pla-pct-neutral {
    background: #94a3b8;
}

.pla-pct-zero {
    background: #94a3b8;
}

.pla-detail-pct {
    display: inline-flex;
    min-width: 54px;
    min-height: 24px;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    border-radius: 6px;
    font-weight: 800;
}

.pla-annual-table tfoot th,
.pla-annual-table tfoot td,
.pla-detail-table tfoot th {
    position: sticky;
    bottom: 0;
    z-index: 7;
    background: #e5e7eb;
    font-weight: 800;
}

.pla-week-table thead th {
    position: sticky;
    top: 0;
    z-index: 6;
    background: #f3f6fa;
    border-color: var(--pla-line);
    text-align: center;
    font-size: 0.72rem;
}

.pla-week-head {
    background: #dbeafe !important;
    color: #1e3a8a;
}

.pla-day-head,
.pla-day-num {
    width: 34px;
    min-width: 34px;
    max-width: 34px;
    padding: 0.25rem !important;
}

.pla-day-cell {
    width: 34px;
    min-width: 34px;
    max-width: 34px;
    height: 34px;
    padding: 0.15rem !important;
    text-align: center;
    background: #ffffff;
    cursor: pointer;
}

.pla-day-cell:hover {
    background: #eef6ff;
}

.pla-day-empty {
    background: #f8fafc;
    cursor: default;
}

.pla-has-visit {
    background: #f0fdf4;
}

.pla-tech-badge {
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 6px;
    background: var(--pla-violet);
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 800;
    line-height: 1;
    padding: 0;
}

.pla-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    margin-left: 2px;
    border-radius: 6px;
    background: #111827;
    color: #fff;
    font-size: 0.65rem;
}

.pla-week-fixed {
    position: sticky;
    z-index: 7;
    background: #ffffff !important;
    box-shadow: 2px 0 4px rgba(15, 23, 42, 0.08);
}

.pla-week-table thead .pla-week-fixed {
    background: #f3f6fa !important;
}

.pla-w-group {
    left: 0;
    width: 120px;
    min-width: 120px;
    max-width: 120px;
}

.pla-w-zone {
    left: 120px;
    width: 100px;
    min-width: 100px;
    max-width: 100px;
}

.pla-w-client {
    left: 220px;
    width: 160px;
    min-width: 160px;
    max-width: 160px;
}

.pla-w-station {
    left: 380px;
    width: 180px;
    min-width: 180px;
    max-width: 180px;
}

.pla-group-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 22px;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    background: #e0f2fe;
    color: #075985;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pla-modal-header {
    background: linear-gradient(90deg, #2563eb, #0891b2);
    color: #ffffff;
}

.pla-modal-header small {
    display: block;
    color: rgba(255, 255, 255, 0.82);
}

#modalPlan .modal-dialog {
    max-width: min(1540px, 96vw) !important;
}

#modalPlan .modal-content {
    max-height: calc(100vh - 2rem);
    overflow: hidden;
    border: 0;
    border-radius: 8px;
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.22);
}

#modalPlan .modal-footer {
    padding: 0.65rem 0.9rem;
    border-top: 1px solid var(--pla-line);
    background: #f8fafc;
}

.pla-plan-modal-body {
    height: min(76vh, 760px);
    min-height: 540px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f8fafc;
}

#modalPlan .pla-plan-modal-body {
    overflow: hidden;
}

.pla-daily-toolbar {
    display: grid;
    grid-template-columns: 180px minmax(320px, 1fr) auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--pla-line);
    background: #ffffff;
}

.pla-daily-toolbar label {
    margin-bottom: 0.25rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 800;
    color: var(--pla-muted);
}

.pla-selected-tech {
    min-height: 38px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    background: #f0fdf4;
}

.pla-selected-tech span {
    color: var(--pla-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.pla-selected-tech em {
    color: var(--pla-green);
    font-style: normal;
    font-weight: 800;
}

.pla-selected-empty {
    border-color: var(--pla-line);
    background: #ffffff;
}

.pla-modal-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0.25rem 0.65rem;
    border-radius: 8px;
    background: #eef2ff;
    color: #3730a3;
    font-weight: 800;
    white-space: nowrap;
}

.pla-daily-layout {
    display: grid;
    grid-template-columns: minmax(640px, 1fr) minmax(380px, 430px);
    flex: 1 1 auto;
    min-height: 0;
    gap: 0.75rem;
    padding: 0.75rem;
    overflow: hidden;
    background: #f8fafc;
}

.pla-daily-left,
.pla-daily-right {
    min-width: 0;
    min-height: 0;
}

.pla-daily-right {
    display: grid;
    grid-template-rows: minmax(300px, 1fr) 205px;
    gap: 0.75rem;
    overflow: hidden;
    background: transparent;
}

.pla-workspace-fieldset {
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    margin: 0;
    padding: 0.85rem 0.75rem 0.75rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    border: 1px solid #cfd8e6;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    contain: paint;
}

.pla-tech-panel {
    z-index: 1;
}

.pla-route-panel {
    z-index: 2;
}

.pla-fieldset-legend {
    width: auto;
    max-width: calc(100% - 0.75rem);
    margin: 0 0 0.45rem;
    padding: 0 0.45rem;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: #0f172a;
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0;
    line-height: 1.2;
    text-transform: uppercase;
    background: #ffffff;
}

.pla-fieldset-legend span {
    display: inline-flex;
    align-items: center;
    min-width: 0;
}

.pla-fieldset-legend .btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.pla-fieldset-legend em {
    min-width: 28px;
    min-height: 22px;
    padding: 0.15rem 0.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #e0f2fe;
    color: #075985;
    font-size: 0.72rem;
    font-style: normal;
    font-weight: 900;
}

.pla-panel-head {
    min-height: 56px;
    padding: 0.7rem 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    border-bottom: 1px solid var(--pla-line);
    background: #ffffff;
}

.pla-panel-head strong {
    display: block;
    line-height: 1.1;
}

.pla-panel-head small {
    display: block;
    color: var(--pla-muted);
    font-size: 0.76rem;
}

.pla-modal-table {
    max-height: none;
}

.pla-tech-table {
    max-height: none;
}

.pla-route-table {
    max-height: none;
}

.pla-modal-table,
.pla-tech-table,
.pla-route-table {
    flex: 1 1 0;
    height: 0;
    min-height: 0;
    overflow-x: auto;
    overflow-y: auto;
    border: 1px solid #e5eaf2;
    border-radius: 8px;
    background: #ffffff;
    overscroll-behavior: contain;
    position: relative;
    z-index: 1;
}

.pla-tech-table,
.pla-route-table {
    overflow-x: hidden;
}

.pla-tech-panel .pla-tech-table,
.pla-route-panel .pla-route-table {
    max-height: calc(100% - 2.25rem);
}

.pla-modal-table .dataTables_wrapper,
.pla-tech-table .dataTables_wrapper,
.pla-route-table .dataTables_wrapper {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.pla-modal-table .dataTables_scroll,
.pla-tech-table .dataTables_scroll,
.pla-route-table .dataTables_scroll {
    min-height: 0;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
}

.pla-modal-table .dataTables_scrollHead,
.pla-tech-table .dataTables_scrollHead,
.pla-route-table .dataTables_scrollHead {
    flex: 0 0 auto;
}

.pla-modal-table .dataTables_scrollBody,
.pla-tech-table .dataTables_scrollBody,
.pla-route-table .dataTables_scrollBody {
    min-height: 0;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

.pla-modal-table .dataTables_scrollBody table,
.pla-tech-table .dataTables_scrollBody table,
.pla-route-table .dataTables_scrollBody table {
    margin-top: 0 !important;
}

.pla-modal-table .dataTables_scrollHead table,
.pla-modal-table .dataTables_scrollBody table,
.pla-tech-table .dataTables_scrollHead table,
.pla-tech-table .dataTables_scrollBody table,
.pla-route-table .dataTables_scrollHead table,
.pla-route-table .dataTables_scrollBody table {
    width: 100% !important;
    table-layout: fixed;
}

.pla-modal-table .dataTables_scrollHead th,
.pla-tech-table .dataTables_scrollHead th {
    background: #eef4fb;
    color: #334155;
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    border-bottom: 1px solid #d7dee8;
}

.pla-route-table .dataTables_scrollHead th {
    background: #eef4fb;
    color: #334155;
    font-size: 0.68rem;
    font-weight: 900;
    text-transform: uppercase;
    border-bottom: 1px solid #d7dee8;
}

.pla-route-table .dataTables_empty {
    height: 98px;
    color: var(--pla-muted);
    vertical-align: middle;
}

#tblAct,
#tblTec,
#tblAsignacionesPendientes {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.74rem;
}

#tblAct col.pla-col-act {
    width: 31%;
}

#tblAct col.pla-col-group {
    width: 21%;
}

#tblAct col.pla-col-zone {
    width: 18%;
}

#tblAct col.pla-col-meta {
    width: 9%;
}

#tblAct col.pla-col-prog {
    width: 11%;
}

#tblAct col.pla-col-action {
    width: 10%;
}

#tblTec col.pla-col-tech-name {
    width: 52%;
}

#tblTec col.pla-col-tech-count {
    width: 18%;
}

#tblTec col.pla-col-tech-cupos {
    width: 15%;
}

#tblTec col.pla-col-tech-action {
    width: 15%;
}

#tblAsignacionesPendientes col.pla-col-route-station {
    width: 44%;
}

#tblAsignacionesPendientes col.pla-col-route-act {
    width: 42%;
}

#tblAsignacionesPendientes col.pla-col-route-action {
    width: 14%;
}

#tblAct thead th,
#tblTec thead th,
#tblAsignacionesPendientes thead th,
.pla-detail-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #eef4fb;
    color: #334155;
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    vertical-align: middle;
    border-top: 0;
    border-bottom: 1px solid #d7dee8;
}

#tblAct td,
#tblTec td,
#tblAsignacionesPendientes td {
    vertical-align: middle;
    border-top: 0;
    border-bottom: 1px solid #edf2f7;
    overflow-wrap: anywhere;
}

#tblAsignacionesPendientes td {
    padding: 0.28rem 0.35rem;
    line-height: 1.14;
}

#tblAct td small,
#tblAsignacionesPendientes td small {
    display: block;
    color: var(--pla-muted);
    font-size: 0.7rem;
}

#tblAsignacionesPendientes td small {
    margin-top: 0.05rem;
    font-size: 0.64rem;
    line-height: 1.08;
}

#tblAsignacionesPendientes td:nth-child(2) {
    font-size: 0.68rem;
    line-height: 1.18;
}

.pla-activity-row td {
    background: #e6f3f5 !important;
    color: #0f5967;
    font-weight: 800;
    text-transform: uppercase;
}

.pla-row-selected td {
    background: #ecfdf5 !important;
}

#tblTec td:first-child strong,
#tblAct td:first-child strong,
#tblAsignacionesPendientes td:first-child strong {
    display: block;
    line-height: 1.18;
}

#tblTec .badge {
    min-width: 30px;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-weight: 900;
}

.btn-add-station,
.btn-seleccionar-tecnico,
.btn-remove-station {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

#tblAsignacionesPendientes .btn-remove-station {
    width: 28px;
    height: 28px;
}

.pla-mini-progress {
    width: 54px;
    height: 5px;
    margin: 2px auto 0;
    overflow: hidden;
    border-radius: 999px;
    background: #e5e7eb;
}

.pla-mini-progress i {
    display: block;
    height: 100%;
    background: var(--pla-green);
}

.pla-detail-wrap {
    max-height: 68vh;
}

@media (max-width: 1200px) {
    .pla-filter-grid {
        grid-template-columns: repeat(3, minmax(160px, 1fr));
    }

    .pla-stat-grid {
        grid-template-columns: repeat(2, minmax(160px, 1fr));
    }

    .pla-daily-layout {
        grid-template-columns: 1fr;
        overflow: auto;
    }

    .pla-daily-right {
        grid-template-rows: minmax(300px, 360px) 205px;
    }
}

@media (max-width: 768px) {
    .pla-filter-grid,
    .pla-stat-grid,
    .pla-daily-toolbar {
        grid-template-columns: 1fr;
    }

    .pla-header-actions,
    .pla-card > .card-header {
        align-items: stretch;
        flex-direction: column;
    }

    #modalPlan .modal-dialog {
        max-width: 100vw !important;
        margin: 0;
    }

    #modalPlan .modal-content {
        min-height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .pla-plan-modal-body {
        height: calc(100vh - 128px);
        min-height: 0;
    }

    .pla-daily-layout {
        padding: 0.55rem;
        gap: 0.55rem;
    }

    .pla-workspace-fieldset {
        padding: 0.75rem 0.55rem 0.55rem;
    }
}
