/* ═════════════════════════════════════════════════════════════
   Planes de Producción — Generación Plan Styles
   Premium dark theme matching Consolidado Ventas design language
   ═════════════════════════════════════════════════════════════ */

/* ── KPI Summary Cards ────────────────────────────────────── */

.pp-editor-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.pp-btn-renew {
    padding: 8px 14px;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.32);
    border-radius: 8px;
    color: #fbbf24;
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.18s ease;
}

.pp-btn-renew:hover {
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(251, 191, 36, 0.55);
    color: #fde68a;
}

.pp-kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.pp-kpi-card {
    position: relative;
    padding: 12px 16px;
    border-radius: 0.6rem;
    overflow: hidden;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pp-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.pp-kpi-card::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.7;
    z-index: 0;
    border-radius: inherit;
}

.pp-kpi-1::before {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.25) 0%, rgba(6, 78, 59, 0.35) 50%, rgba(15, 23, 42, 0.5) 100%);
}

.pp-kpi-2::before {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(49, 46, 129, 0.35) 50%, rgba(15, 23, 42, 0.5) 100%);
}

.pp-kpi-3::before {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.25) 0%, rgba(127, 29, 29, 0.35) 50%, rgba(15, 23, 42, 0.5) 100%);
}

.pp-kpi-label {
    position: relative;
    z-index: 1;
    font-size: 0.64rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 2px;
}

.pp-kpi-value {
    position: relative;
    z-index: 1;
    font-size: 1.25rem;
    font-weight: 800;
    color: #f1f5f9;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.pp-kpi-sub {
    position: relative;
    z-index: 1;
    font-size: 0.64rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 2px;
}

@keyframes pp-pulse-critical {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.pp-kpi-critical {
    animation: pp-pulse-critical 2s infinite;
}


/* ── Toolbar ──────────────────────────────────────────────── */

.pp-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    margin-bottom: 8px;
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(51, 65, 85, 0.3);
    border-radius: 0.5rem;
    flex-wrap: wrap;
}

.pp-toolbar-search {
    flex: 1;
    min-width: 180px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(51, 65, 85, 0.45);
    border-radius: 0.4rem;
    transition: border-color 0.2s;
}

.pp-toolbar-search:focus-within {
    border-color: #22c55e;
}

.pp-toolbar-search svg {
    color: #64748b;
    flex-shrink: 0;
}

.pp-toolbar-search input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: #f1f5f9;
    font-size: 0.74rem;
}

.pp-toolbar-search input::placeholder {
    color: #475569;
}

.pp-toolbar-btn {
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 0.35rem;
    border: 1px solid rgba(51, 65, 85, 0.4);
    background: rgba(15, 23, 42, 0.4);
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.pp-toolbar-btn:hover {
    background: rgba(30, 41, 59, 0.8);
    color: #e2e8f0;
    border-color: rgba(71, 85, 105, 0.6);
}

.pp-toolbar-btn.active {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.3);
}

.pp-toolbar-divider {
    width: 1px;
    height: 20px;
    background: rgba(51, 65, 85, 0.4);
    flex-shrink: 0;
}

.pp-toolbar-count {
    font-size: 0.7rem;
    color: #64748b;
    background: rgba(51, 65, 85, 0.25);
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    margin-left: auto;
}

/* Filter dropdown */
.pp-filter-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 50;
    min-width: 220px;
    padding: 12px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.6rem;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.pp-filter-group {
    margin-bottom: 10px;
}

.pp-filter-group:last-child {
    margin-bottom: 0;
}

.pp-filter-group-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 6px;
}

.pp-filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.8rem;
    color: #cbd5e1;
    cursor: pointer;
}

.pp-filter-option input[type="checkbox"] {
    accent-color: #22c55e;
}


/* ── Table Container ──────────────────────────────────────── */

.pp-table-wrap {
    border: 1px solid rgba(51, 65, 85, 0.3);
    border-radius: 0.5rem;
    overflow: auto;
    max-height: calc(100vh - 120px);
    position: relative;
}

.pp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.65rem;
    line-height: 1.3;
}


/* ── Table Head ───────────────────────────────────────────── */

.pp-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.pp-th {
    padding: 6px 8px;
    text-align: left;
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    white-space: nowrap;
    user-select: none;
}

/* Separator before input zone */
.pp-th-input {
    background: rgba(30, 41, 59, 0.95);
    border-left: 2px solid rgba(34, 197, 94, 0.2);
}

/* Sortable headers */
.pp-th-sort {
    cursor: pointer;
    transition: color 0.15s;
}

.pp-th-sort:hover {
    color: #e2e8f0;
}

.pp-th-sort-active {
    color: #60a5fa;
}

.pp-sort-icon {
    font-size: 0.55rem;
    margin-left: 2px;
    opacity: 0.8;
}


/* ── Table Body — Main Rows ───────────────────────────────── */

.pp-td {
    padding: 4px 8px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.2);
    vertical-align: middle;
    color: #cbd5e1;
    font-size: 0.65rem;
}

.pp-row-main {
    cursor: pointer;
    transition: background 0.15s ease;
}

.pp-row-main:hover {
    background: rgba(30, 41, 59, 0.5);
}

.pp-row-main.pp-expanded {
    background: rgba(30, 41, 59, 0.6);
    border-left: 3px solid #22c55e;
}

.pp-td-num {
    color: #475569;
    font-size: 0.65rem;
    text-align: center;
    width: 36px;
}

.pp-td-sku {
    color: #22c55e;
    font-size: 0.65rem;
    white-space: nowrap;
}

.pp-td-prod {
    font-size: 0.65rem;
    color: #e2e8f0;
}

.pp-td-maquila {
    color: #94a3b8;
    font-size: 0.65rem;
}


/* ── Input Zone (Q. Fabricar / Q. Pack) ───────────────────── */

.pp-td-input {
    border-left: 2px solid rgba(34, 197, 94, 0.12);
    background: rgba(15, 23, 42, 0.25);
}

.pp-input {
    width: 68px;
    padding: 3px 6px;
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid rgba(51, 65, 85, 0.45);
    border-radius: 4px;
    font-size: 0.65rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.pp-input:focus {
    border-color: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15);
}

.pp-input:hover:not(:focus) {
    border-color: rgba(71, 85, 105, 0.6);
}

.pp-input-pack {
    width: 60px;
}

.pp-input-derived {
    color: #a78bfa;
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.22);
    cursor: default;
}

.pp-td-total-plan {
    background: rgba(99, 102, 241, 0.08);
    color: #c4b5fd;
    font-size: 0.68rem;
    font-weight: 700;
    text-align: right;
    font-variant-numeric: tabular-nums;
    border-left: 1px solid rgba(99, 102, 241, 0.18);
}


/* ── Badges ───────────────────────────────────────────────── */

.pp-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.64rem;
    font-weight: 600;
    white-space: nowrap;
}

.pp-badge-activo {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.pp-badge-pruebas {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.pp-badge-na {
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
}

.pp-badge-borrador {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.pp-badge-aprobado {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.2);
}


/* ── Numeric Columns ──────────────────────────────────────── */

.pp-td-total-disp {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.pp-td-ddp {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.pp-td-dias {
    text-align: right;
    font-variant-numeric: tabular-nums;
}


/* ── Detail Rows (Expandable Platform Breakdown) ──────────── */

.pp-detail-row {
    animation: pp-slide-in 0.2s ease-out;
}

.pp-detail-row td {
    padding: 4px 8px;
    font-size: 0.65rem;
    border-bottom: 1px solid rgba(51, 65, 85, 0.12);
}

.pp-detail-plat-name {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding-left: 20px;
}

.pp-detail-plat-name svg {
    flex-shrink: 0;
}

.pp-detail-total td {
    border-top: 1px solid #334155;
    font-weight: 700;
    color: #e2e8f0;
}

@keyframes pp-slide-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ── Plan Header / Metadata Form ──────────────────────────── */

.pp-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    padding: 12px;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(51, 65, 85, 0.3);
    border-radius: 0.5rem;
    margin-bottom: 12px;
}

.pp-meta-label {
    font-size: 0.64rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 3px;
    font-weight: 600;
}

.pp-meta-input {
    width: 100%;
    padding: 6px 10px;
    background: #0f172a;
    color: #f1f5f9;
    border: 1px solid rgba(51, 65, 85, 0.45);
    border-radius: 5px;
    font-size: 0.8rem;
    outline: none;
    transition: border-color 0.2s;
}

.pp-meta-input:focus {
    border-color: #22c55e;
}

.pp-meta-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}


/* ── Días Legend Tooltip ──────────────────────────────────── */

.pp-th-dias {
    cursor: help;
    position: relative;
}

.pp-th-dias::after {
    content: 'Cobertura de stock: 🟢 ≥30d · 🟡 ≥15d · 🔴 <15d';
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: #e2e8f0;
    font-size: 0.72rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #334155;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 20;
}

.pp-th-dias:hover::after {
    opacity: 1;
}

/* ── MRP Alerts ──────────────────────────────────────────── */

.pp-td-alerts {
    text-align: center;
    white-space: nowrap;
}

.pp-alert-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
    margin: 0 1px;
    cursor: default;
    position: relative;
}

.pp-alert-quiebre {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
    animation: pp-pulse-critical 1.5s infinite;
}

.pp-alert-caducidad {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}


/* ── Recommended Column ──────────────────────────────────── */

.pp-td-recomendado {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.pp-recomendado-value {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #60a5fa;
}

.pp-btn-apply {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(34, 197, 94, 0.3);
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
    cursor: pointer;
    font-size: 0.6rem;
    transition: all 0.15s;
    flex-shrink: 0;
}

.pp-btn-apply:hover {
    background: rgba(34, 197, 94, 0.25);
    border-color: #22c55e;
    transform: scale(1.1);
}


/* ── MRP Config Form (inside expanded row) ───────────────── */

.pp-mrp-config {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    margin-bottom: 8px;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(96, 165, 250, 0.15);
    border-left: 3px solid rgba(96, 165, 250, 0.5);
    border-radius: 0.5rem;
    flex-wrap: wrap;
}

.pp-mrp-config-title {
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #60a5fa;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
}

.pp-mrp-field {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pp-mrp-field label {
    font-size: 0.64rem;
    color: #94a3b8;
    white-space: nowrap;
}

.pp-mrp-field input {
    width: 44px;
    padding: 2px 5px;
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid rgba(51, 65, 85, 0.45);
    border-radius: 4px;
    font-size: 0.72rem;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

.pp-mrp-field input:focus {
    border-color: #60a5fa;
}

.pp-mrp-field .pp-mrp-unit {
    font-size: 0.6rem;
    color: #64748b;
}

.pp-mrp-divider {
    width: 1px;
    height: 16px;
    background: rgba(51, 65, 85, 0.3);
}

.pp-mrp-save-btn {
    padding: 3px 10px;
    font-size: 0.64rem;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid rgba(96, 165, 250, 0.3);
    background: rgba(96, 165, 250, 0.1);
    color: #60a5fa;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.pp-mrp-save-btn:hover {
    background: rgba(96, 165, 250, 0.2);
    border-color: #60a5fa;
}

.pp-mrp-summary {
    font-size: 0.64rem;
    color: #64748b;
    margin-left: auto;
    white-space: nowrap;
}

.pp-mrp-summary strong {
    color: #94a3b8;
}


/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 1280px) {
    .pp-kpi-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .pp-kpi-value {
        font-size: 1.25rem;
    }

    .pp-toolbar {
        gap: 8px;
    }
}

@media (max-width: 768px) {
    .pp-kpi-row {
        grid-template-columns: 1fr;
    }
}
