/* =========================================================
   VASE · Historial de producciones
   Rediseño integral 2026-08-27
   ========================================================= */

:root {
    --ph-ink: #132238;
    --ph-muted: #66758c;
    --ph-border: #dfe7f1;
    --ph-border-soft: #edf2f7;
    --ph-surface: #ffffff;
    --ph-soft: #f7f9fc;
    --ph-accent: #6f35e8;
    --ph-accent-dark: #5622c6;
    --ph-accent-soft: #f2edff;
    --ph-green: #0f9f6e;
    --ph-green-soft: #eaf9f3;
    --ph-amber: #d4820a;
    --ph-amber-soft: #fff7e8;
    --ph-red: #dc3d5e;
    --ph-red-soft: #fff0f3;
    --ph-blue: #1479b8;
    --ph-blue-soft: #edf8ff;
    --ph-shadow: 0 12px 30px rgba(34, 55, 86, .07);
}

.ph-page {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 18px 14px 42px;
    color: var(--ph-ink);
}

body.ph-modal-open { overflow: hidden; }

/* ---------- Encabezado ---------- */
.ph-hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    overflow: hidden;
    margin-bottom: 16px;
    padding: 24px 28px;
    border: 1px solid var(--ph-border);
    border-radius: 22px;
    background: linear-gradient(120deg, #ffffff 0%, #fbfcff 66%, #f5f1ff 100%);
    box-shadow: var(--ph-shadow);
}

.ph-hero::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: linear-gradient(180deg, #7c3aed, #4f46e5);
}

.ph-hero::after {
    content: "";
    position: absolute;
    right: -52px;
    top: -84px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: rgba(111, 53, 232, .055);
    pointer-events: none;
}

.ph-hero-copy,
.ph-hero > .ph-btn { position: relative; z-index: 1; }

.ph-kicker {
    margin: 0 0 5px;
    color: var(--ph-accent);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.ph-hero h1 {
    margin: 0 0 7px;
    color: #0f1f36;
    font-size: clamp(28px, 2.25vw, 37px);
    font-weight: 900;
    line-height: 1.08;
    letter-spacing: -.025em;
}

.ph-hero p {
    max-width: 850px;
    margin: 0;
    color: var(--ph-muted);
    font-size: 14px;
    line-height: 1.55;
}

/* ---------- Botones ---------- */
.ph-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: 11px;
    font-size: 13px;
    font-weight: 900;
    line-height: 1.2;
    cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.ph-btn:hover { transform: translateY(-1px); }
.ph-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.ph-btn-primary {
    color: #fff;
    background: linear-gradient(135deg, #7137e8, #4f46e5);
    box-shadow: 0 9px 20px rgba(86, 34, 198, .19);
}

.ph-btn-primary:hover { box-shadow: 0 12px 25px rgba(86, 34, 198, .25); }

.ph-btn-light {
    color: #42516a;
    border-color: #dce4ee;
    background: #f8fafc;
    box-shadow: none;
}

.ph-btn-block { width: 100%; }

/* ---------- Paneles ---------- */
.ph-panel,
.ph-stat-card,
.ph-production-card,
.ph-recipe-card {
    border: 1px solid var(--ph-border);
    background: var(--ph-surface);
    box-shadow: var(--ph-shadow);
}

.ph-panel {
    padding: 20px 22px;
    border-radius: 22px;
}

/* ---------- Filtros ---------- */
.ph-filters-panel {
    margin-bottom: 14px;
    padding: 15px 18px;
}

.ph-filters-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(155px, 1fr)) minmax(250px, 1.35fr);
    gap: 11px;
    align-items: end;
}

.ph-filters-grid .form-group {
    min-width: 0;
    margin: 0;
}

.ph-filters-grid label {
    display: block;
    margin: 0 0 5px;
    color: #40516a;
    font-size: 11px;
    font-weight: 900;
}

.ph-filters-grid .form-control {
    width: 100%;
    height: 42px;
    border: 1px solid #d7e0eb;
    border-radius: 11px;
    background: #fff;
    color: #23344c;
    box-shadow: none;
}

.ph-filters-grid .form-control:focus {
    border-color: #9874ef;
    box-shadow: 0 0 0 3px rgba(111, 53, 232, .09);
}

.ph-search-field { min-width: 0; }

.ph-period-label {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 13px;
    padding-top: 12px;
    border-top: 1px solid var(--ph-border-soft);
    color: var(--ph-muted);
    font-size: 12px;
}

.ph-period-label strong {
    display: inline-flex;
    align-items: center;
    min-height: 27px;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--ph-accent-soft);
    color: var(--ph-accent-dark);
    font-weight: 900;
}

/* ---------- Indicadores ---------- */
.ph-stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 11px;
    margin-bottom: 14px;
}

.ph-stat-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 86px;
    overflow: hidden;
    padding: 13px 15px;
    border-radius: 17px;
    box-shadow: 0 8px 22px rgba(34, 55, 86, .055);
}

.ph-stat-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 13px;
    bottom: 13px;
    width: 4px;
    border-radius: 0 999px 999px 0;
    background: var(--ph-accent);
}

.ph-stat-icon {
    display: grid;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 12px;
    background: var(--ph-accent-soft);
    color: var(--ph-accent);
    font-size: 18px;
}

.ph-stat-card > div { min-width: 0; }
.ph-stat-card span,
.ph-mini-grid span,
.ph-production-numbers span,
.ph-modal-stats span {
    display: block;
    margin-bottom: 4px;
    color: #728096;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .045em;
    text-transform: uppercase;
}

.ph-stat-card strong {
    display: block;
    color: #0f1f36;
    font-size: 22px;
    font-weight: 900;
    line-height: 1.05;
}

.ph-stat-applied::before { background: var(--ph-green); }
.ph-stat-applied .ph-stat-icon { background: var(--ph-green-soft); color: var(--ph-green); }
.ph-stat-draft::before { background: var(--ph-amber); }
.ph-stat-draft .ph-stat-icon { background: var(--ph-amber-soft); color: var(--ph-amber); }
.ph-stat-waste::before { background: var(--ph-red); }
.ph-stat-waste .ph-stat-icon { background: var(--ph-red-soft); color: var(--ph-red); }
.ph-stat-cost::before { background: var(--ph-blue); }
.ph-stat-cost .ph-stat-icon { background: var(--ph-blue-soft); color: var(--ph-blue); }

/* ---------- Contenido principal ---------- */
.ph-main-grid { display: block; }
.ph-hidden-period-summary { display: none !important; }

.ph-panel-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
    padding-bottom: 13px;
    border-bottom: 1px solid var(--ph-border-soft);
}

.ph-panel-head h3 {
    margin: 0 0 4px;
    color: #102039;
    font-size: 23px;
    font-weight: 900;
    letter-spacing: -.015em;
}

.ph-panel-head p {
    margin: 0;
    color: var(--ph-muted);
    font-size: 12px;
}

.ph-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 88px;
    padding: 16px;
    border: 1px dashed #cfd9e6;
    border-radius: 14px;
    background: #fafcff;
    color: var(--ph-muted);
    text-align: center;
}

.ph-empty-small { min-height: 56px; }

/* ---------- Lista de recetas ---------- */
.ph-recipe-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
}

.ph-recipe-card {
    position: relative;
    display: flex !important;
    align-items: center;
    gap: 18px;
    min-height: 104px;
    overflow: hidden;
    padding: 14px 16px 14px 18px;
    border-radius: 15px;
    box-shadow: none;
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.ph-recipe-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 12px;
    bottom: 12px;
    width: 4px;
    border-radius: 0 999px 999px 0;
    background: linear-gradient(180deg, #7c3aed, #4f46e5);
}

.ph-recipe-card:hover {
    transform: translateY(-1px);
    border-color: #d7c9fa;
    box-shadow: 0 9px 24px rgba(76, 51, 139, .07);
}

.ph-recipe-main {
    flex: 1 1 430px;
    min-width: 300px;
    padding-left: 3px;
}

.ph-card-top {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 6px;
}

.ph-card-top span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--ph-accent);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.ph-card-top strong {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef1ff;
    color: #4f46c8;
    font-size: 10px;
    font-weight: 900;
}

.ph-recipe-card h4 {
    margin: 0 0 4px;
    color: #102039;
    font-size: 19px;
    font-weight: 900;
    line-height: 1.2;
    overflow-wrap: break-word;
}

.ph-recipe-card p {
    margin: 0;
    color: var(--ph-muted);
    font-size: 12px;
    line-height: 1.4;
}

.ph-recipe-card p b { color: #53637a; }

.ph-mini-grid {
    display: grid !important;
    flex: 0 1 520px;
    width: min(520px, 44%);
    min-width: 390px;
    grid-template-columns: repeat(4, minmax(82px, 1fr));
    gap: 7px;
    margin: 0 !important;
}

.ph-mini-grid div,
.ph-production-numbers div,
.ph-modal-stats div {
    min-width: 0;
    padding: 8px 9px;
    border: 1px solid #e6edf5;
    border-radius: 11px;
    background: #f8fafc;
}

.ph-mini-grid span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ph-mini-grid strong,
.ph-production-numbers strong,
.ph-modal-stats strong {
    display: block;
    color: #11213a;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.ph-recipe-action {
    display: flex;
    flex: 0 0 138px;
    justify-content: flex-end;
}

.ph-recipe-action .ph-btn {
    width: 100%;
    min-width: 0;
    white-space: nowrap;
}

/* ---------- Paginación ---------- */
.ph-pagination {
    display: grid;
    grid-template-columns: 120px 1fr 120px;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding-top: 13px;
    border-top: 1px solid var(--ph-border-soft);
    color: #62728a;
    font-size: 12px;
    font-weight: 900;
    text-align: center;
}

.ph-pagination .ph-btn:last-child { justify-self: end; }

/* ---------- Producciones dentro de modal ---------- */
.ph-date-groups,
.ph-modal-history { display: grid; gap: 14px; }

.ph-date-group h4 {
    margin: 0 0 9px;
    color: #3f5068;
    font-size: 14px;
    font-weight: 900;
    text-transform: capitalize;
}

.ph-production-list { display: grid; gap: 10px; }

.ph-production-card {
    padding: 14px;
    border-radius: 15px;
    box-shadow: none;
}

.ph-production-main {
    display: grid;
    grid-template-columns: minmax(230px, .9fr) minmax(420px, 1.35fr);
    gap: 14px;
    align-items: start;
}

.ph-status-row {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.ph-status-row small { color: var(--ph-muted); }

.ph-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 900;
}

.ph-status.is-ok { background: var(--ph-green-soft); color: #08794f; }
.ph-status.is-warning { background: var(--ph-amber-soft); color: #9b6105; }
.ph-status.is-danger { background: var(--ph-red-soft); color: #b92848; }

.ph-production-card h5 {
    margin: 0 0 4px;
    color: #102039;
    font-size: 16px;
    font-weight: 900;
}

.ph-production-card p {
    margin: 0;
    color: var(--ph-muted);
    font-size: 12px;
}

.ph-production-numbers {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
}

.ph-production-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 11px;
    padding-top: 11px;
    border-top: 1px solid var(--ph-border-soft);
}

.ph-details { margin-top: 11px; }

.ph-details summary {
    color: var(--ph-accent);
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
}

.ph-table-wrap {
    overflow-x: auto;
    margin-top: 9px;
    border: 1px solid var(--ph-border);
    border-radius: 13px;
    background: #fff;
}

.ph-table {
    min-width: 720px;
    margin: 0;
}

.ph-table thead th {
    background: #f6f8fb;
    color: #64748b;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    border-bottom: 1px solid var(--ph-border) !important;
}

.ph-table tbody td {
    vertical-align: middle !important;
    border-top: 1px solid #edf2f7 !important;
}

/* ---------- Modales ---------- */
.ph-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
}

.ph-modal.is-open { display: block; }

.ph-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(18, 31, 51, .58);
    backdrop-filter: blur(4px);
}

.ph-modal-panel {
    position: relative;
    width: min(1040px, calc(100vw - 30px));
    max-height: calc(100vh - 30px);
    margin: 15px auto;
    overflow: hidden;
    border: 1px solid #d8e1ec;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 28px 80px rgba(15, 23, 42, .28);
}

.ph-modal-panel-wide { width: min(1180px, calc(100vw - 30px)); }

.ph-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--ph-border-soft);
    background: #fff;
}

.ph-modal-header h3 {
    margin: 0 0 4px;
    color: #102039;
    font-size: 22px;
    font-weight: 900;
}

.ph-modal-header p {
    margin: 0;
    color: var(--ph-muted);
    font-size: 12px;
}

.ph-modal-close {
    display: grid;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid #dce4ee;
    border-radius: 12px;
    background: #f8fafc;
    color: #42516a;
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
}

.ph-modal-body {
    max-height: calc(100vh - 165px);
    overflow-y: auto;
    padding: 17px 20px;
    background: #fbfcfe;
}

.ph-modal-panel-wide .ph-modal-body { max-height: calc(100vh - 185px); }

.ph-modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 12px 20px;
    border-top: 1px solid var(--ph-border-soft);
    background: #fff;
}

.ph-modal-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

/* ---------- Alertas ---------- */
.ph-alert {
    margin-bottom: 12px;
    padding: 11px 13px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 900;
}

.ph-alert-success { border: 1px solid #a9e6cd; background: var(--ph-green-soft); color: #08794f; }
.ph-alert-warning { border: 1px solid #f2d59e; background: var(--ph-amber-soft); color: #925a00; }
.ph-alert-danger { border: 1px solid #f1c0ca; background: var(--ph-red-soft); color: #b92848; }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
    .ph-filters-grid { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
    .ph-stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

    .ph-recipe-card {
        flex-wrap: wrap;
        align-items: stretch;
    }

    .ph-recipe-main { flex: 1 1 430px; }
    .ph-mini-grid { flex: 1 1 500px; width: auto; min-width: 420px; }
    .ph-recipe-action { flex: 1 0 100%; }
    .ph-recipe-action .ph-btn { width: 100%; }
}

@media (max-width: 900px) {
    .ph-hero { align-items: stretch; flex-direction: column; padding: 20px; }
    .ph-hero > .ph-btn { width: 100%; }
    .ph-filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ph-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ph-production-main { grid-template-columns: 1fr; }
    .ph-production-numbers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ph-modal-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .ph-page { padding: 10px 6px 28px; }
    .ph-hero,
    .ph-panel { border-radius: 16px; }
    .ph-hero { padding: 17px 16px; }
    .ph-filters-panel,
    .ph-panel { padding: 14px; }
    .ph-filters-grid { grid-template-columns: 1fr; }
    .ph-stats-grid { grid-template-columns: 1fr; gap: 8px; }
    .ph-stat-card { min-height: 75px; }

    .ph-recipe-card {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 12px;
        min-height: 0;
    }

    .ph-recipe-main,
    .ph-mini-grid,
    .ph-recipe-action {
        width: 100%;
        min-width: 0;
        flex: none;
    }

    .ph-mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ph-pagination { grid-template-columns: 1fr; }
    .ph-pagination .ph-btn { width: 100%; justify-self: stretch !important; }
    .ph-modal-panel { width: calc(100vw - 12px); margin: 6px auto; max-height: calc(100vh - 12px); border-radius: 16px; }
    .ph-modal-header { flex-direction: row; padding: 14px; }
    .ph-modal-body { padding: 14px; max-height: calc(100vh - 145px); }
    .ph-modal-footer { padding: 10px 14px; }
    .ph-modal-stats { grid-template-columns: 1fr; }
}
