/* ─── Nellca Inköp – Frontend CSS ────────────────────────────── */

/* ─── Generellt ─── */
.npo-fe-wrap {
    max-width: 1100px;
    margin: 0 auto;
    font-family: inherit;
}

.npo-fe-error {
    color: #c62828;
    padding: 12px 16px;
    background: #fce4ec;
    border-radius: 6px;
}

.npo-fe-empty {
    text-align: center;
    color: #888;
    padding: 32px 16px;
    background: #f9f9f9;
    border-radius: 8px;
}

/* ─── Header ─── */
.npo-fe-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.npo-fe-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.npo-fe-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ─── Knappar ─── */
.npo-fe-btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: opacity .15s;
    line-height: 1.4;
}
.npo-fe-btn:hover { opacity: .85; text-decoration: none; }

.npo-fe-btn--primary    { background: #2e7d32; color: #fff; border-color: #2e7d32; }
.npo-fe-btn--secondary  { background: #fff; color: #333; border-color: #ccc; }
.npo-fe-btn--xs         { padding: 4px 10px; font-size: 12px; }
.npo-fe-btn--full       { width: 100%; box-sizing: border-box; text-align: center; }

/* ─── Statustabbar (lista) ─── */
.npo-fe-tabs {
    display: flex;
    gap: 0;
    flex-wrap: wrap;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 16px;
}

.npo-fe-tab {
    padding: 8px 14px;
    font-size: 13px;
    color: #555;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
}
.npo-fe-tab:hover { color: #2e7d32; text-decoration: none; }
.npo-fe-tab--active { color: #2e7d32; border-bottom-color: #2e7d32; font-weight: 600; }

.npo-fe-tab-count {
    display: inline-block;
    background: #e0e0e0;
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 11px;
    margin-left: 4px;
}

/* ─── Sök ─── */
.npo-fe-search-row { margin-bottom: 16px; }
.npo-fe-search-input {
    width: 100%;
    max-width: 360px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}

/* ─── Tabell ─── */
.npo-fe-table-wrap { overflow-x: auto; }
.npo-fe-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.npo-fe-table th,
.npo-fe-table td {
    padding: 10px 12px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid #e5e5e5;
}
.npo-fe-table thead th {
    background: #f5f5f5;
    font-weight: 600;
    font-size: 13px;
    color: #444;
}
.npo-fe-table tbody tr:hover { background: #f9f9f9; }

.npo-fe-po-link { font-weight: 600; text-decoration: none; color: #1a73e8; }
.npo-fe-po-link:hover { text-decoration: underline; }
.npo-fe-late { color: #c62828; font-weight: 600; }

/* ─── Status-badges ─── */
.npo-fe-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.npo-fe-badge--npo-draft     { background: #f0f0f0; color: #555; }
.npo-fe-badge--npo-ordered   { background: #e8f5e9; color: #1b5e20; }
.npo-fe-badge--npo-confirmed { background: #e3f2fd; color: #0d47a1; }
.npo-fe-badge--npo-sent      { background: #fff3e0; color: #e65100; }
.npo-fe-badge--npo-partial   { background: #fff8e1; color: #f57f17; }
.npo-fe-badge--npo-received  { background: #e8f5e9; color: #2e7d32; }
.npo-fe-badge--npo-cancelled { background: #fce4ec; color: #b71c1c; }

/* ─── Formulär-layout ─── */
.npo-fe-breadcrumb {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 13px;
    color: #888;
    margin-bottom: 20px;
}
.npo-fe-breadcrumb a { color: #1a73e8; text-decoration: none; }
.npo-fe-breadcrumb a:hover { text-decoration: underline; }

.npo-fe-form-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 20px;
    align-items: start;
}
@media (max-width: 768px) {
    .npo-fe-form-layout { grid-template-columns: 1fr; }
}

/* ─── Kort ─── */
.npo-fe-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
}
.npo-fe-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    background: #fafafa;
}
.npo-fe-card__title {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #333;
}
.npo-fe-card__body { padding: 16px; }

/* ─── Artikeltabell ─── */
.npo-fe-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.npo-fe-items-table th,
.npo-fe-items-table td {
    padding: 6px 8px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid #eee;
}
.npo-fe-items-table thead th { font-weight: 600; font-size: 12px; color: #555; }
.npo-fe-items-table tfoot td { border-top: 2px solid #ddd; border-bottom: none; }

.npo-fe-total-label { text-align: right; font-weight: 600; color: #555; }
.npo-fe-total-value { font-weight: 700; font-size: 15px; }

.npo-fe-row-sum { font-weight: 600; }

/* ─── Formulärfält ─── */
.npo-fe-input {
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 13px;
    line-height: 1.4;
    box-sizing: border-box;
}
.npo-fe-input:focus { outline: none; border-color: #2e7d32; box-shadow: 0 0 0 2px rgba(46,125,50,.15); }

.npo-fe-input-sm {
    padding: 5px 7px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    box-sizing: border-box;
    width: 100%;
}
.npo-fe-input-sm:focus { outline: none; border-color: #2e7d32; }

/* ─── Detalj-grid ─── */
.npo-fe-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 20px;
}
@media (max-width: 600px) { .npo-fe-details-grid { grid-template-columns: 1fr; } }

.npo-fe-field { display: flex; flex-direction: column; gap: 4px; }
.npo-fe-field label { font-size: 12px; font-weight: 600; color: #555; }
.npo-fe-field .npo-fe-input,
.npo-fe-field textarea.npo-fe-input { width: 100%; }
.npo-fe-field--full { grid-column: 1 / -1; }

/* ─── Leverantörsinfo ─── */
.npo-fe-supplier-info {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: #555;
}
.npo-fe-supplier-info a { color: #1a73e8; text-decoration: none; }

/* ─── Åtgärder (sidebar) ─── */
.npo-fe-action-stack { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.npo-fe-order-ext { border: 1px solid #e0e0e0; border-radius: 6px; padding: 10px; }
.npo-fe-label-sm { font-size: 12px; color: #666; margin: 0 0 4px; }

/* ─── Spårning ─── */
.npo-fe-tracking-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.npo-fe-track-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    background: #e3f2fd;
    color: #1565c0;
    margin-left: 8px;
}

/* ─── Inleveranstabell ─── */
.npo-fe-recv-table { font-size: 13px; width: 100%; border-collapse: collapse; }
.npo-fe-recv-table th,
.npo-fe-recv-table td { padding: 6px 8px; border-bottom: 1px solid #eee; vertical-align: middle; }
.npo-fe-recv-table th { font-weight: 600; font-size: 12px; }

.npo-fe-recv-done td    { color: #aaa; }
.npo-fe-recv-cell-done  { color: #2e7d32 !important; font-weight: 600; }
.npo-fe-recv-cell-partial { color: #e65100 !important; font-weight: 600; }
.npo-fe-recv-table code { font-size: 11px; background: #f5f5f5; padding: 1px 4px; border-radius: 3px; color: #555; }

/* ─── Leveranshistorik ─── */
.npo-fe-receipt-entry {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}
.npo-fe-receipt-entry:last-child { border-bottom: none; }
.npo-fe-receipt-entry ul { margin: 4px 0 0 16px; padding: 0; }
.npo-fe-receipt-entry li { list-style: disc; }

/* ─── Spinner ─── */
.npo-fe-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ccc;
    border-top-color: #2e7d32;
    border-radius: 50%;
    animation: npo-fe-spin .7s linear infinite;
    vertical-align: middle;
    margin-left: 8px;
}
@keyframes npo-fe-spin { to { transform: rotate(360deg); } }

/* ─── Meddelanden (inline result) ─── */
#npo-fe-action-result,
#npo-fe-recv-result,
#npo-fe-track-result {
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 13px;
}
#npo-fe-action-result.success,
#npo-fe-recv-result.success,
#npo-fe-track-result.success { background: #e8f5e9; color: #2e7d32; }
#npo-fe-action-result.error,
#npo-fe-recv-result.error,
#npo-fe-track-result.error   { background: #fce4ec; color: #b71c1c; }

/* ─── Produktsök autocomplete ─── */
.npo-fe-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 999;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
    min-width: 260px;
    max-height: 260px;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 0;
}
.npo-fe-suggestions li {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.npo-fe-suggestions li:hover,
.npo-fe-suggestions li.npo-fe-active { background: #e8f5e9; }

.npo-fe-stock-info {
    font-size: 11px;
    color: #888;
    margin-left: 8px;
}

/* ─── Ta bort-knapp (rad) ─── */
.npo-fe-remove-row {
    background: none;
    border: none;
    color: #c62828;
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.npo-fe-remove-row:hover { color: #b71c1c; }

/* ─── Kanban ─── */
.npo-fe-kanban-board {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
    align-items: flex-start;
}

.npo-fe-column {
    flex: 0 0 260px;
    background: #f5f5f5;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: border-color .15s;
    min-height: 200px;
}
.npo-fe-column--over { border-color: #2e7d32; }

.npo-fe-column__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    font-weight: 700;
    font-size: 13px;
    border-bottom: 1px solid #e0e0e0;
}
.npo-fe-column__count {
    background: #2e7d32;
    color: #fff;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
}
.npo-fe-column__body { padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.npo-fe-column__empty { text-align: center; color: #aaa; padding: 20px 0; font-size: 13px; }

/* Kanban-kort (återanvänder .npo-fe-card men med dra-stöd) */
.npo-fe-kanban-board .npo-fe-card {
    margin-bottom: 0;
    cursor: grab;
    padding: 10px 12px;
    user-select: none;
}
.npo-fe-kanban-board .npo-fe-card.npo-fe-dragging { opacity: .4; }
.npo-fe-kanban-board .npo-fe-card__body { padding: 0; }

.npo-fe-card__number { font-weight: 700; font-size: 13px; color: #1a73e8; text-decoration: none; }
.npo-fe-card__number:hover { text-decoration: underline; }
.npo-fe-card__supplier { font-size: 12px; color: #666; margin-top: 2px; }
.npo-fe-card__date { font-size: 12px; color: #555; margin-top: 4px; }
.npo-fe-card__date--late { color: #c62828; font-weight: 600; }
.npo-fe-card__date--today { color: #e65100; font-weight: 600; }
.npo-fe-card__tracking { font-size: 12px; color: #1565c0; margin-top: 4px; }
.npo-fe-card__tracking a { color: inherit; text-decoration: none; }
.npo-fe-card__tracking a:hover { text-decoration: underline; }
.npo-fe-card__meta { display: flex; gap: 10px; font-size: 11px; color: #888; margin-top: 6px; }

.npo-fe-progress { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.npo-fe-progress__bar { flex: 1; height: 5px; background: #e0e0e0; border-radius: 3px; overflow: hidden; }
.npo-fe-progress__fill { height: 100%; background: #2e7d32; border-radius: 3px; }
.npo-fe-progress span { font-size: 11px; color: #555; white-space: nowrap; }

/* ─── Kanban toast ─── */
#npo-fe-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #333;
    color: #fff;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    z-index: 9999;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .2s, transform .2s;
    pointer-events: none;
}
#npo-fe-toast.npo-fe-toast--visible { opacity: 1; transform: translateY(0); }
#npo-fe-toast.npo-fe-toast--error { background: #b71c1c; }

/* ─── Dashboard-kort (nd-card kompatibilitet) ─── */
.nd-card--purchase { }

.nd-purchase-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.nd-purchase-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    flex-wrap: wrap;
    font-size: 13px;
}
.nd-purchase-item:last-child { border-bottom: none; }
.nd-purchase-item__number { font-weight: 700; color: #1a73e8; text-decoration: none; }
.nd-purchase-item__number:hover { text-decoration: underline; }
.nd-purchase-item__supplier { color: #666; flex: 1; min-width: 80px; }

.nd-card__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-top: 1px solid #f0f0f0;
    margin-top: 8px;
    flex-wrap: wrap;
    gap: 6px;
}
.nd-card__footer-link { font-size: 13px; color: #1a73e8; text-decoration: none; }
.nd-card__footer-link:hover { text-decoration: underline; }

/* ─── Inventering & Lageretiketter – frontend ─── */

.npo-fe-notice {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
}
.npo-fe-notice--info    { background: #e8f5e9; border: 1px solid #c8e6c9; color: #2e7d32; }
.npo-fe-notice--error   { background: #fce4ec; border: 1px solid #f8bbd0; color: #c62828; }

.npo-fe-select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    min-width: 220px;
    background: #fff;
}
.npo-fe-select:focus { outline: none; border-color: #2e7d32; }

/* Inventering – start-kort */
.npo-fe-inv-start-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 28px;
    align-items: flex-start;
}
.npo-fe-inv-box {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 16px 20px;
    min-width: 260px;
}
.npo-fe-inv-box--wide { flex: 1; min-width: 320px; }
.npo-fe-inv-box h3 { margin: 0 0 8px; font-size: 15px; }
.npo-fe-inv-box p  { font-size: 13px; color: #555; margin: 0 0 12px; }

/* Filterrutnät i formuläret */
.npo-fe-filter-table { border-collapse: collapse; width: 100%; }
.npo-fe-filter-table th {
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    padding: 5px 10px 5px 0;
    white-space: nowrap;
    vertical-align: top;
    padding-top: 10px;
    color: #444;
}
.npo-fe-filter-table td { padding: 5px 0; }

/* Kategoriträd i formuläret */
.npo-fe-cat-tree-box {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 10px;
    max-height: 190px;
    overflow-y: auto;
    min-width: 240px;
    background: #fff;
}

/* Inventerings-sessionstabell */
.npo-fe-table-wrap { overflow-x: auto; margin-top: 20px; }

/* Inventering – wrap utan WP-admin-klass */
.npo-fe-wrap .npo-inv-value-cell { text-align: right; }
.npo-fe-wrap #npo-inv-cat-filter {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px 14px;
    margin-bottom: 14px;
    display: inline-block;
    min-width: 220px;
    max-width: 540px;
}

/* Print-stöd (lageretiketter) */
@media print {
    .npo-labels-toolbar.no-print { display: none !important; }
}
