/*
|--------------------------------------------------------------------------
| FromApp — Registres de fabrication
| Style aligné sur le module Ressources humaines
|--------------------------------------------------------------------------
*/

:root {
    --prod-blue: #1d4ed8;
    --prod-blue-dark: #1e3a8a;
    --prod-blue-soft: #eff6ff;
    --prod-blue-border: #bfdbfe;
    --prod-ink: #172033;
    --prod-muted: #64748b;
    --prod-bg: #f3f6fb;
    --prod-surface: #ffffff;
    --prod-surface-soft: #f8fafc;
    --prod-line: #dbe3ee;
    --prod-success: #15803d;
    --prod-success-soft: #ecfdf3;
    --prod-warning: #b45309;
    --prod-warning-soft: #fff7ed;
    --prod-danger: #b91c1c;
    --prod-danger-soft: #fef2f2;
    --prod-radius: 20px;
    --prod-radius-control: 11px;
    --prod-shadow: 0 16px 38px rgba(15, 23, 42, 0.08);
    --prod-transition: 160ms ease;
}

/* Base */

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
}

body {
    background:
        radial-gradient(
            circle at 10% 0%,
            rgba(37, 99, 235, 0.09),
            transparent 30rem
        ),
        var(--prod-bg);
    color: var(--prod-ink);
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

[hidden] {
    display: none !important;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    outline: 3px solid rgba(59, 130, 246, 0.20);
    outline-offset: 2px;
}

/* Structure et en-tête */

.prod-wrap {
    width: min(1500px, calc(100% - 30px));
    margin: 0 auto;
    padding: 24px 0 52px;
}

.prod-head {
    position: sticky;
    top: 12px;
    z-index: 70;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 24px;
    padding: 18px 21px;
    border: 1px solid rgba(203, 213, 225, 0.82);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.07);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.prod-head > div {
    min-width: 0;
}

.prod-head h1 {
    margin: 9px 0 4px;
    color: var(--prod-blue);
    font-size: clamp(1.55rem, 3vw, 2.15rem);
    font-weight: 850;
    line-height: 1.08;
    letter-spacing: -0.035em;
}

.prod-head h1::before {
    display: block;
    margin-bottom: 7px;
    color: var(--prod-blue-dark);
    content: "PRODUCTION";
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.11em;
}

.prod-head p {
    max-width: 720px;
    margin: 6px 0 0;
    color: var(--prod-muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.prod-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--prod-blue-dark);
    font-size: 0.82rem;
    font-weight: 800;
    text-decoration: none;
}

.prod-back:hover {
    color: var(--prod-blue);
}

.prod-head nav {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
    padding: 5px;
    border: 1px solid var(--prod-line);
    border-radius: 14px;
    background: var(--prod-surface-soft);
}

.prod-head nav a {
    min-height: 38px;
    padding: 9px 13px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: #475569;
    font-size: 0.8rem;
    font-weight: 800;
    text-decoration: none;
    transition:
        background var(--prod-transition),
        border-color var(--prod-transition),
        color var(--prod-transition),
        transform var(--prod-transition);
}

.prod-head nav a:hover {
    border-color: var(--prod-blue-border);
    background: var(--prod-blue-soft);
    color: var(--prod-blue-dark);
    transform: translateY(-1px);
}

body[data-page="home"] .prod-head nav a[href="./index.html"],
body[data-page="record"] .prod-head nav a[href="./index.html"],
body[data-page="records"] .prod-head nav a[href="./liste.html"],
body[data-page="recipes"] .prod-head nav a[href="./recettes.html"],
body[data-page="recipe"] .prod-head nav a[href="./recettes.html"] {
    border-color: var(--prod-blue);
    background: linear-gradient(145deg, #2563eb, #1d4ed8);
    color: #ffffff;
    box-shadow: 0 7px 16px rgba(29, 78, 216, 0.20);
}

/* Cartes et sections */

.prod-panel {
    overflow: hidden;
    margin-bottom: 20px;
    padding: clamp(18px, 3vw, 28px);
    border: 1px solid var(--prod-line);
    border-radius: var(--prod-radius);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--prod-shadow);
}

.prod-panel > section {
    margin-top: 26px;
    padding-top: 25px;
    border-top: 1px solid var(--prod-line);
}

.prod-panel > section:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.prod-panel h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 13px;
    color: var(--prod-ink);
    font-size: 1.22rem;
    font-weight: 850;
    letter-spacing: -0.02em;
}

.prod-panel h2::before {
    width: 9px;
    height: 28px;
    border-radius: 999px;
    background: linear-gradient(180deg, #60a5fa, var(--prod-blue));
    content: "";
    flex: 0 0 auto;
}

.prod-panel h3 {
    margin: 0 0 9px;
    font-size: 1.05rem;
    font-weight: 800;
}

.prod-panel p {
    color: var(--prod-muted);
    line-height: 1.5;
}

.prod-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
    gap: 15px;
}

.prod-card {
    position: relative;
    min-height: 142px;
    padding: 19px;
    border: 1px solid var(--prod-line);
    border-radius: 15px;
    background:
        linear-gradient(
            145deg,
            rgba(255, 255, 255, 0.98),
            rgba(248, 250, 252, 0.94)
        );
    transition:
        border-color var(--prod-transition),
        box-shadow var(--prod-transition),
        transform var(--prod-transition);
}

.prod-card::before {
    position: absolute;
    top: 0;
    right: 18px;
    left: 18px;
    height: 3px;
    border-radius: 0 0 999px 999px;
    background: linear-gradient(90deg, #60a5fa, var(--prod-blue));
    content: "";
}

.prod-card:hover {
    border-color: var(--prod-blue-border);
    box-shadow: 0 14px 26px rgba(15, 23, 42, 0.09);
    transform: translateY(-2px);
}

.prod-card a,
.prod-panel td a {
    color: var(--prod-blue);
    font-weight: 750;
}

#recipeList .prod-card + .prod-card {
    margin-top: 12px;
}

#recentRecords p {
    margin: 0;
    padding: 12px 2px;
    border-bottom: 1px solid #edf1f5;
}

#recentRecords p:last-child {
    border-bottom: 0;
}

/* Formulaires */

.prod-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px 18px;
}

.prod-panel label {
    display: block;
    margin: 12px 0;
    color: #334155;
    font-size: 0.85rem;
    font-weight: 800;
}

.prod-panel label input,
.prod-panel label select,
.prod-panel label textarea,
.prod-panel > label input,
.prod-actions select {
    display: block;
    width: 100%;
    min-height: 43px;
    margin-top: 7px;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: var(--prod-radius-control);
    background: #ffffff;
    color: var(--prod-ink);
    font-size: 0.92rem;
    transition:
        border-color var(--prod-transition),
        box-shadow var(--prod-transition),
        background var(--prod-transition);
}

.prod-panel label input:hover,
.prod-panel label select:hover,
.prod-panel label textarea:hover,
.prod-actions select:hover {
    border-color: #94a3b8;
}

.prod-panel label input:focus,
.prod-panel label select:focus,
.prod-panel label textarea:focus,
.prod-actions select:focus {
    border-color: #60a5fa;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.11);
    outline: none;
}

.prod-panel input:disabled,
.prod-panel select:disabled,
.prod-panel textarea:disabled {
    background: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
}

.prod-panel textarea {
    min-height: 92px;
    resize: vertical;
    line-height: 1.45;
}

.prod-panel input[type="checkbox"] {
    display: inline-block;
    width: 18px;
    min-height: 18px;
    margin: 0 8px 0 0;
    accent-color: var(--prod-blue);
    vertical-align: middle;
}

.prod-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.prod-actions select {
    width: min(420px, 100%);
    margin: 0;
}

.prod-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 15px;
    border: 1px solid var(--prod-line);
    border-radius: var(--prod-radius-control);
    background: #ffffff;
    color: #334155;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 850;
    text-decoration: none;
    transition:
        border-color var(--prod-transition),
        background var(--prod-transition),
        box-shadow var(--prod-transition),
        color var(--prod-transition),
        transform var(--prod-transition);
}

.prod-button:hover:not(:disabled) {
    border-color: var(--prod-blue-border);
    background: var(--prod-blue-soft);
    color: var(--prod-blue-dark);
    transform: translateY(-1px);
}

.prod-button.primary {
    border-color: var(--prod-blue);
    background: linear-gradient(145deg, #2563eb, #1d4ed8);
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(29, 78, 216, 0.20);
}

.prod-button.primary:hover:not(:disabled) {
    background: linear-gradient(145deg, #1d4ed8, #1e40af);
    color: #ffffff;
}

.prod-button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

/* Choix de produits et champs de fabrication */

.prod-choices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
}

#recipeProducts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

#recipeProducts .prod-choice {
    display: inline-flex !important;
}

#recipeProducts .prod-choice button {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    margin-left: 9px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #dbeafe;
    color: var(--prod-blue-dark);
    cursor: pointer;
    font-weight: 900;
}

.prod-choice {
    display: flex !important;
    align-items: center;
    min-height: 48px;
    margin: 0 !important;
    padding: 11px 14px;
    border: 2px solid var(--prod-line);
    border-radius: 12px;
    background: #ffffff;
    cursor: pointer;
    transition:
        border-color var(--prod-transition),
        background var(--prod-transition),
        box-shadow var(--prod-transition),
        transform var(--prod-transition);
}

.prod-choice:hover {
    border-color: var(--prod-blue-border);
    transform: translateY(-1px);
}

.prod-choice:has(input:checked) {
    border-color: var(--prod-blue);
    background: var(--prod-blue-soft);
    box-shadow: 0 7px 16px rgba(29, 78, 216, 0.10);
    color: var(--prod-blue-dark);
}

.prod-field {
    padding: 15px 0;
    border-bottom: 1px solid #edf1f5;
}

.prod-field:last-child {
    border-bottom: 0;
}

.prod-field label {
    margin: 0 0 6px;
}

.prod-field small {
    display: block;
    margin-top: 5px;
    color: var(--prod-muted);
    line-height: 1.4;
}

.prod-target {
    display: inline-block;
    margin-top: 8px;
    padding: 5px 9px;
    border: 1px solid var(--prod-blue-border);
    border-radius: 8px;
    background: var(--prod-blue-soft);
    color: var(--prod-blue-dark);
    font-size: 0.78rem;
    font-weight: 750;
}

.prod-deviation {
    display: block;
    min-height: 20px;
    margin-top: 5px;
    color: var(--prod-warning);
    font-size: 0.8rem;
    font-weight: 750;
}

.prod-procedure {
    margin: 21px 0;
    padding: 14px 16px;
    border: 1px solid var(--prod-blue-border);
    border-radius: 13px;
    background: var(--prod-blue-soft);
}

.prod-procedure summary {
    color: var(--prod-blue-dark);
    cursor: pointer;
    font-weight: 850;
}

.prod-procedure div {
    margin-top: 14px;
    color: #334155;
    line-height: 1.55;
    white-space: pre-wrap;
}

/* Constructeur de recettes */

.prod-section-editor {
    margin: 15px 0;
    padding: 18px;
    border: 1px solid var(--prod-line);
    border-radius: 15px;
    background: var(--prod-surface-soft);
}

.prod-field-editor {
    margin: 13px 0;
    padding: 15px;
    border: 1px solid #e2e8f0;
    border-radius: 13px;
    background: #ffffff;
    box-shadow: 0 5px 14px rgba(15, 23, 42, 0.04);
}

.prod-field-editor .prod-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

/* Tableaux, messages et rendement */

.prod-table-wrap {
    overflow: auto;
    margin-top: 17px;
    border: 1px solid var(--prod-line);
    border-radius: 14px;
}

.prod-panel table {
    width: 100%;
    min-width: 720px;
    border-collapse: separate;
    border-spacing: 0;
}

.prod-panel th,
.prod-panel td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--prod-line);
    text-align: left;
    vertical-align: top;
}

.prod-panel th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #eef4fb;
    color: #334155;
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.prod-panel td {
    background: #ffffff;
    color: #334155;
    font-size: 0.88rem;
}

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

.prod-panel tbody tr:hover td {
    background: #f8fbff;
}

.prod-panel tr.prod-pending td {
    background: var(--prod-warning-soft);
}

.prod-alert {
    color: var(--prod-warning);
    font-weight: 750;
}

#prodMessage:not(:empty) {
    margin: 0 0 18px;
    padding: 13px 16px;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    background: var(--prod-success-soft);
    color: #166534;
    font-size: 0.88rem;
    font-weight: 750;
}

#prodMessage.error {
    border-color: #fecaca;
    background: var(--prod-danger-soft);
    color: var(--prod-danger);
}

.prod-yield {
    margin: 18px 0;
    padding: 17px;
    border: 1px solid var(--prod-blue-border);
    border-radius: 14px;
    background: linear-gradient(145deg, #eff6ff, #f8fbff);
    color: var(--prod-blue-dark);
}

.prod-yield strong {
    font-size: 1.08rem;
}

#qualityAudit details,
#yieldPanel details {
    margin-top: 10px;
    padding: 11px 13px;
    border: 1px solid var(--prod-line);
    border-radius: 11px;
    background: var(--prod-surface-soft);
}

#qualityAudit summary,
#yieldPanel summary {
    color: #334155;
    cursor: pointer;
    font-weight: 800;
}

/* Adaptation mobile */

@media (max-width: 820px) {
    .prod-wrap {
        width: min(100% - 22px, 1500px);
        padding-top: 12px;
    }

    .prod-head {
        position: static;
        display: block;
        padding: 17px;
    }

    .prod-head nav {
        justify-content: stretch;
        margin-top: 15px;
    }

    .prod-head nav a {
        flex: 1 1 auto;
        text-align: center;
    }

    .prod-panel {
        padding: 17px;
        border-radius: 16px;
    }
}

@media (max-width: 560px) {
    .prod-grid,
    .prod-choices,
    .prod-cards {
        grid-template-columns: 1fr;
    }

    .prod-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .prod-actions > *,
    .prod-actions select {
        width: 100%;
    }
}

/* Impression */

@media print {
    body {
        background: #ffffff;
    }

    .prod-wrap {
        width: 100%;
        padding: 0;
    }

    .prod-head {
        position: static;
        border: 0;
        box-shadow: none;
    }

    .prod-head nav,
    .prod-actions,
    .prod-back,
    #prodMessage {
        display: none !important;
    }

    .prod-panel {
        border: 0;
        box-shadow: none;
    }
}

