/* مخزن الأعلاف */

.fwh-workspace {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}

.fwh-hero {
    background: linear-gradient(135deg, #78350f 0%, #b45309 45%, #d97706 100%);
    border: none;
    color: #fff;
    border-radius: 16px;
    overflow: hidden;
}

.fwh-hero-top {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 20px 10px;
}

.fwh-hero-top h2 { margin: 0 0 4px; font-size: 1.25rem; }
.fwh-hero-top p { margin: 0; font-size: 0.82rem; opacity: 0.92; }

.fwh-hero-grid,
.fwh-hero-summary {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 0 16px 18px;
}

.fwh-metric-group {
    background: rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    padding: 12px;
}

.fwh-metric-group-head {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 10px;
}

.fwh-metric-group-head h3 {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 700;
}

.fwh-metric-group-head p {
    margin: 0;
    font-size: 0.72rem;
    opacity: 0.85;
}

.fwh-metric-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}

.fwh-metric {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    text-align: right;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.12);
    color: inherit;
    border-radius: 12px;
    padding: 10px 12px;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.15s ease, background 0.15s ease;
}

.fwh-metric:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.fwh-metric-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.16);
    flex-shrink: 0;
}

.fwh-metric-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.fwh-metric-label {
    font-size: 0.72rem;
    opacity: 0.9;
}

.fwh-metric-value {
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.2;
}

.fwh-metric-hint {
    font-size: 0.68rem;
    opacity: 0.82;
    line-height: 1.35;
}

.fwh-metric.is-ok {
    border-color: rgba(187, 247, 208, 0.55);
    background: rgba(22, 101, 52, 0.22);
}

.fwh-metric.is-warn {
    border-color: rgba(253, 230, 138, 0.7);
    background: rgba(146, 64, 14, 0.28);
}

.fwh-metric.is-danger {
    border-color: rgba(254, 202, 202, 0.75);
    background: rgba(153, 27, 27, 0.3);
}

.fwh-metric.is-muted {
    opacity: 0.88;
}

.fwh-stat {
    background: rgba(255,255,255,0.13);
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 10px;
    padding: 8px 10px;
    text-align: center;
}

.fwh-stat .val { display: block; font-size: 1.05rem; font-weight: 700; }
.fwh-stat .lbl { display: block; font-size: 0.65rem; opacity: 0.88; margin-top: 2px; }

.fwh-guide {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 14px;
    padding: 14px 16px;
    color: #78350f;
}

.fwh-guide h3 {
    margin: 0 0 8px;
    font-size: 0.95rem;
}

.fwh-guide ol {
    margin: 0;
    padding-inline-start: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.84rem;
    line-height: 1.45;
}

.fwh-next-card .fwh-next-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fwh-next-step {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 12px;
    padding: 12px 14px;
    text-align: right;
    cursor: pointer;
    font-family: inherit;
    color: #0f172a;
}

.fwh-next-step span {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.fwh-next-step strong { font-size: 0.92rem; }
.fwh-next-step small { color: #64748b; font-size: 0.78rem; line-height: 1.4; }
.fwh-next-step > .fa-solid:first-child { color: #b45309; font-size: 1.1rem; }
.fwh-next-arrow { color: #94a3b8; }

.fwh-next-step.warn { background: #fffbeb; border-color: #fde68a; }
.fwh-next-step.danger { background: #fef2f2; border-color: #fecaca; }
.fwh-next-step.ok { background: #f0fdf4; border-color: #bbf7d0; }
.fwh-next-step.ok > .fa-solid:first-child { color: #15803d; }
.fwh-next-step.danger > .fa-solid:first-child { color: #b91c1c; }

@media (max-width: 900px) {
    .fwh-metric-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
    .fwh-metric-row { grid-template-columns: 1fr; }
}

.fwh-subtabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
}

.fwh-subtab {
    border: none;
    background: transparent;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #64748b;
    white-space: nowrap;
}

.fwh-subtab.active {
    background: linear-gradient(135deg, #b45309, #d97706);
    color: #fff;
    font-weight: 600;
}

.fwh-module-body { display: flex; flex-direction: column; gap: 12px; }

.fwh-card {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    padding: 14px 16px;
}

.fwh-card h3 {
    margin: 0 0 12px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fwh-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.fwh-form-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.78rem;
    color: #64748b;
}

.fwh-form-grid label span { font-weight: 600; }

.fwh-table-wrap { overflow-x: auto; }

.fwh-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.fwh-table th, .fwh-table td {
    border: 1px solid #e2e8f0;
    padding: 8px 10px;
    text-align: right;
    white-space: nowrap;
}

.fwh-table th { background: #f8fafc; font-weight: 600; }

.fwh-table .fwh-row-actions {
    white-space: nowrap;
    text-align: center;
}

.fwh-table .fwh-row-actions .btn {
    margin-inline: 2px;
    padding: 4px 8px;
}

.fwh-table .fwh-row-actions .fa-trash {
    color: #b91c1c;
}

.fwh-table .fwh-row-actions .btn.is-disabled,
.fwh-table .fwh-row-actions .btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.fwh-alert {
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    font-size: 0.84rem;
}

.fwh-alert.danger { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.fwh-alert.warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }

.fwh-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
}

.fwh-badge.pending { background: #fef3c7; color: #92400e; }
.fwh-badge.ok { background: #dcfce7; color: #166534; }
.fwh-badge.expired { background: #fee2e2; color: #991b1b; }

.fwh-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.fwh-chart-box {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.fwh-chart-body {
    min-height: 180px;
}

/* أعمدة يومية / شهرية */
.fwh-col-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 6px;
    height: 200px;
    padding: 8px 4px 0;
    border-bottom: 2px solid #e2e8f0;
}

.fwh-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    gap: 4px;
}

.fwh-col-bar {
    width: 100%;
    max-width: 36px;
    min-height: 4px;
    border-radius: 6px 6px 2px 2px;
    background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
    transition: height 0.3s ease;
}

.fwh-col-val {
    font-size: 0.65rem;
    font-weight: 700;
    color: #92400e;
    white-space: nowrap;
}

.fwh-col-lbl {
    font-size: 0.65rem;
    color: #64748b;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* قوائم أفقية */
.fwh-bar-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fwh-bar-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fwh-bar-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.fwh-bar-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
    text-align: right;
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.fwh-bar-amount {
    font-size: 0.82rem;
    font-weight: 700;
    color: #92400e;
    white-space: nowrap;
}

.fwh-bar-amount small {
    font-weight: 500;
    color: #94a3b8;
    font-size: 0.72rem;
}

.fwh-bar-track {
    height: 10px;
    background: #f1f5f9;
    border-radius: 999px;
    overflow: hidden;
}

.fwh-bar-fill {
    height: 100%;
    border-radius: 999px;
    min-width: 4px;
    transition: width 0.35s ease;
}

/* شهر واحد */
.fwh-single-stat {
    text-align: center;
    padding: 24px 12px;
}

.fwh-single-val {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    color: #b45309;
    line-height: 1.2;
}

.fwh-single-val small {
    font-size: 0.9rem;
    font-weight: 500;
    color: #94a3b8;
}

.fwh-single-lbl {
    display: block;
    margin-top: 6px;
    font-size: 0.95rem;
    color: #475569;
    font-weight: 600;
}

.fwh-single-hint {
    margin: 12px 0 0;
    font-size: 0.75rem;
    color: #94a3b8;
}

.fwh-chart-box h4 {
    margin: 0 0 4px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
}

.fwh-chart-sub {
    margin: 0 0 14px;
    font-size: 0.78rem;
    color: #94a3b8;
}

.fwh-empty i { margin-left: 6px; opacity: 0.7; }

.fwh-empty { text-align: center; padding: 32px; color: #64748b; }

@media (max-width: 1100px) {
    .fwh-hero-grid { grid-template-columns: repeat(3, 1fr); }
    .fwh-chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .fwh-hero-grid { grid-template-columns: repeat(2, 1fr); }
    .fwh-subtab span { display: none; }
}

@media print {
    body.printing-fwh > *:not(#fwhPrintSheet) { display: none !important; }
    body.printing-fwh #fwhPrintSheet {
        display: block !important;
        position: static !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        color: #111 !important;
    }

    body.printing-feed-request > *:not(#feedRequestPrintSheet) { display: none !important; }
    body.printing-feed-request #feedRequestPrintSheet {
        display: block !important;
        position: static !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    body.printing-feed-po > *:not(#feedPoPrintSheet) { display: none !important; }
    body.printing-feed-po #feedPoPrintSheet {
        display: block !important;
        position: static !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    #feedPoPrintSheet .frp-table.rf-print-table th,
    #feedPoPrintSheet .frp-table.rf-print-table td {
        text-align: right;
    }

    #feedPoPrintSheet .frp-table.rf-print-table th {
        background: #f8fafc !important;
        color: #111 !important;
        width: 35%;
        font-weight: 600;
    }

    @page { size: A4 portrait; margin: 12mm 14mm; }

    #feedRequestPrintSheet .frp-table.rf-print-table th,
    #feedRequestPrintSheet .frp-table.rf-print-table td {
        text-align: right;
    }

    #feedRequestPrintSheet .frp-table.rf-print-table th {
        background: #f8fafc !important;
        color: #111 !important;
        width: 35%;
        font-weight: 600;
    }

    #fwhPrintSheet .fwh-print-table td:first-child {
        text-align: right;
        font-weight: 600;
    }
}

/* ─── طباعة طلب صرف أعلاف ─── */
#feedRequestPrintSheet,
#feedPoPrintSheet { display: none; }

.fwh-badge.technical { background: #dbeafe; color: #1d4ed8; }
.fwh-badge.warehouse { background: #fef3c7; color: #b45309; }
.fwh-badge.approved { background: #d1fae5; color: #047857; }
.fwh-badge.rejected { background: #fee2e2; color: #b91c1c; }

.fwh-pending-actions { display: flex; gap: 4px; flex-wrap: wrap; }

.frp-doc {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    color: #111;
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
    direction: rtl;
}

#feedRequestPrintSheet .rf-print-doc {
    max-width: none;
    padding: 0;
    margin: 0;
}

#feedPoPrintSheet .rf-print-doc {
    max-width: none;
    padding: 0;
    margin: 0;
}

.frp-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.frp-table th, .frp-table td { border: 1px solid #cbd5e1; padding: 10px 12px; text-align: right; }
.frp-table th { background: #f8fafc; width: 35%; font-weight: 600; }

.frp-workflow h3 { font-size: 15px; margin: 0 0 10px; }
.frp-steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 24px; flex-wrap: wrap; }
.frp-steps li {
    flex: 1;
    min-width: 120px;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    text-align: center;
    font-size: 13px;
    background: #f8fafc;
}
.frp-steps li.done { background: #d1fae5; border-color: #6ee7b7; color: #047857; font-weight: 600; }
.frp-steps li.active { background: #fef3c7; border-color: #fbbf24; color: #b45309; font-weight: 600; }

.frp-sign-line-block {
    min-height: 74px;
}

.frp-sign-line-title {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 6px;
}

.frp-sign-line-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
}

.frp-sign-line-rule {
    border-bottom: 1px dotted #64748b;
    height: 18px;
    margin-bottom: 4px;
}

.frp-sign-line-meta {
    font-size: 11px;
    color: #64748b;
}

.frp-po-layout {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.frp-po-top {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.frp-committee {
    margin-top: 10px;
    border-top: 1px solid #e2e8f0;
    padding-top: 8px;
}

.frp-committee h3 {
    margin: 0 0 10px;
    font-size: 15px;
}

.frp-committee-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.frp-committee-grid .frp-sign-line-block {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 10px 8px;
    min-height: 84px;
    background: #fff;
}

.frp-committee-grid .frp-sign-line-title {
    font-size: 12px;
    margin-bottom: 4px;
}

.frp-committee-grid .frp-sign-line-name {
    font-size: 12.5px;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.frp-committee-grid .frp-sign-line-rule {
    height: 12px;
    margin-bottom: 3px;
}

.frp-sign-footer {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.frp-sign-manager {
    margin-top: 4px;
}

.frp-note {
    margin-top: 10px;
    text-align: center;
    font-size: 11px;
    color: #64748b;
}

@media (max-width: 900px) {
    .frp-committee-grid,
    .frp-sign-footer {
        grid-template-columns: 1fr;
    }
}

@media print {
    #feedPoPrintSheet .rf-print-main,
    #feedPoPrintSheet .frp-po-layout {
        min-height: auto !important;
        height: auto !important;
    }

    .frp-committee-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }

    .frp-committee-grid .frp-sign-line-block {
        min-height: 70px;
        padding: 8px 8px 6px;
    }

    .frp-sign-manager {
        padding-inline: 3cm;
    }

    .frp-sign-manager { margin-top: 8px; }

    .frp-note {
        margin-top: 6px;
    }

    .frp-sign-footer {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
}
