/* =========================
   GLOBAL
========================= */

body {
    font-family: 'Segoe UI', sans-serif;
    background: #f5f6fa;
    margin: 0;
}


/* =========================
   TABLE
========================= */

.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
}

.table thead {
    background: #f7f9fc;
}

.table th {
    text-align: left;
    padding: 14px;
    font-size: 13px;
    color: #888;
    text-transform: uppercase;
}

.table td {
    padding: 14px;
    border-top: 1px solid #f0f0f0;
}

.table tbody tr {
    transition: background 0.15s;
}

.table tbody tr:hover {
    background: #f9fbff;
}


/* =========================
   TABLE COMPACT
========================= */

.table.compact th,
.table.compact td {
    padding: 6px 10px;
    font-size: 14px;
}

.table.compact td.label {
    font-weight: 500;
    color: #333;
}


/* =========================
   SUB TABLE (DETAIL)
========================= */

.sub-table {
    width: 100%;
    margin-top: 5px;
    font-size: 14px;
}

.sub-table td {
    padding: 4px 8px;
}

.main-row {
    background: white;
}

.detail-row {
    background: #f9f9f9;
}


/* =========================
   EDITABLE
========================= */

td[contenteditable="true"] {
    background: transparent;
}

td[contenteditable="true"]:focus {
    outline: none;
    background: #eef6ff;
    border-radius: 6px;
}

.editable {
    display: inline-block;
    min-width: 36px;
    padding: 4px 8px;

    background: #f1f2f6;
    border: 1px solid #dcdde1;
    border-radius: 6px;

    text-align: center;
    font-weight: 600;
    font-size: 14px;

    cursor: text;
    transition: all 0.15s ease;
}

.editable:empty:before {
    content: "0";
    color: #aaa;
}

.editable:hover {
    background: #e6e9ef;
}

.editable:focus {
    outline: none;
    background: white;
    border-color: #00a8ff;
    box-shadow: 0 0 0 2px rgba(0,168,255,0.2);
}

/* état sauvegardé */
.saved .editable {
    background: #e6fffa;
}


/* =========================
   SELECT
========================= */

select {
    border: none;
    background: transparent;
    font-size: 14px;
}


/* =========================
   BADGES
========================= */

.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    color: white;
}

.badge-yes {
    background: #9edcff;
    color: #00365f;
}

.badge-no {
    background: #ff9d9d;
    color: #3d0000;
}

.badge-location {
    background: #eef2f7;
    color: #333;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
}


/* =========================
   STATUS / ALERTS
========================= */

.error-banner {
    background: #ffe6e6;
    color: #c0392b;

    padding: 12px;
    margin: 10px 20px;
    border-radius: 6px;

    font-weight: 500;
}

.alert {
    background: #ffe6e6;
}

.expired {
    background: #ffe6e6;
}

.warning {
    background: #fff4e6;
}


/* =========================
   ACTIONS
========================= */

.actions {
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: 0.2s;
}

tr:hover .actions {
    opacity: 1;
}


/* =========================
   CATEGORY FILTERS
========================= */

.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.cat-btn {
    padding: 5px 14px;
    border-radius: 20px;
    border: 2px solid transparent;
    background: #eef0f5;
    color: #555;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.1s;
}

.cat-btn:hover {
    background: #e1e4ea;
    color: #333;
}

.cat-btn.active {
    background: var(--cat-color, #00a8ff);
    color: white;
}


/* =========================
   PAGE ACTIONS (add + filter)
========================= */

.page-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.filter-input {
    flex: 1;
    max-width: 320px;
    padding: 7px 12px;
    border: 1px solid #dcdde1;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    color: #333;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.filter-input:focus {
    outline: none;
    border-color: #00a8ff;
    box-shadow: 0 0 0 3px rgba(0, 168, 255, 0.12);
}


/* =========================
   CRUD ADD BAR
========================= */

.crud-add {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.crud-add input,
.crud-add select {
    padding: 8px 10px;
    font-size: 14px;
    border: 1px solid #dcdde1;
    border-radius: 6px;
    background: white;
}


/* =========================
   BUTTONS
========================= */

.icon-btn {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 16px;
}

.btn {
    padding: 6px 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
}

.btn-primary {
    background: #00a8ff;
    color: white;
}

.btn-danger {
    background: #e84118;
    color: white;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-secondary {
    background: #bdc3c7;
    color: #333;
}

.btn:hover {
    opacity: 0.85;
}

.add-btn {
    margin-bottom: 15px;
}


/* =========================
   STATES / FEEDBACK
========================= */

.saving {
    background: #fff8e1 !important;
}

.saved {
    background: #e6fffa !important;
    transition: background 0.5s;
}

.fade-out {
    animation: fadeOut 1s forwards;
}

@keyframes fadeOut {
    from { background: #e6fffa; }
    to { background: transparent; }
}


/* =========================
   LAYOUT
========================= */

.grid {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    flex: 1;
}

.card.small {
    max-width: 500px;
}

.highlight {
    text-align: center;
}

.big-number {
    font-size: 40px;
    font-weight: bold;
    color: #00a8ff;
}


/* =========================
   THRESHOLDS
========================= */

.threshold-box {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 10px;
}

.threshold-item {
    display: flex;
    flex-direction: column;
    font-size: 12px;
    color: #666;
}

.product-type-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

/* LEFT */
.info-block {
    flex: 1;
}

/* RIGHT */
.image-block {
    text-align: center;
}

/* image */
.product-image {
    width: 120px;
    height: 120px;
    object-fit: cover;

    border-radius: 10px;
    border: 1px solid #eee;
    margin-bottom: 10px;
}

/* bouton upload discret */
.upload-btn {
    display: inline-block;
    background: #f1f2f6;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: 0.2s;
}

.upload-btn:hover {
    background: #e1e4ea;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;

    background: rgba(0,0,0,0.5);

    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.close {
    float: right;
    cursor: pointer;
}

.label-header {
    margin-bottom: 10px;
}

.label-logo {
    height: 30px;
    object-fit: contain;
}

.health-grid {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* chaque card prend 50% */
.health-grid .card {
    flex: 1;
    min-width: 0; /* évite overflow */
}

.big-number.ok {
    color: #00a8ff; /* bleu */
}

.big-number.danger {
    color: #e84118; /* rouge */
}

.sub-info {
    font-size: 12px;
    color: #888;
    margin-top: 5px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.kit-card {
    text-align: center;
    padding: 20px;
    border-radius: 10px;
    transition: 0.2s;
}

/* NOM */
.kit-name {
    font-weight: bold;
    margin-bottom: 10px;
}

/* STATUS */
.kit-status {
    font-size: 18px;
    font-weight: bold;
}

/* OK */
.kit-card.ok {
    background: #e6fffa;
    color: #065f46;
}

/* KO */
.kit-card.danger {
    background: #ffe6e6;
    color: #7f1d1d;
}

/* hover */
.kit-card:hover {
    transform: translateY(-2px);
    cursor: pointer;
}

/* tableau ultra compact */
.table.ultra-compact td {
    padding: 4px 8px;
    font-size: 13px;
}

/* enlever header inutile */
.table.ultra-compact thead {
    display: none;
}

/* nom kit plus lisible */
.kit-name {
    font-weight: 500;
}

/* badge plus petit */
.table.ultra-compact .badge {
    font-size: 11px;
    padding: 2px 6px;
}

/* ligne hover légère */
.table.ultra-compact tr:hover {
    background: #f5f7fa;
}

.badge-warning {
    background: #ffeaa7;
    color: #7a5c00;
}
/* ═══════════════════════════════════════════════
   SORTABLE HEADERS
   ═══════════════════════════════════════════════ */
.th-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.th-sortable::after {
    content: ' ⇅';
    opacity: 0.25;
    font-size: 10px;
}
.th-sortable[data-sort-dir="asc"]::after {
    content: ' ▲';
    opacity: 1;
    color: #00a8ff;
}
.th-sortable[data-sort-dir="desc"]::after {
    content: ' ▼';
    opacity: 1;
    color: #00a8ff;
}
.th-sortable:hover { color: #00a8ff; }

/* ═══════════════════════════════════════════════
   PAGINATION
   ═══════════════════════════════════════════════ */
.table-pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px 2px 2px;
    font-size: 13px;
    min-height: 38px;
}
.page-info { color: #999; }
.page-btns { display: flex; gap: 3px; align-items: center; }
.page-btn {
    min-width: 30px;
    height: 28px;
    padding: 0 7px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.12s, border-color 0.12s;
}
.page-btn:hover:not(:disabled):not(.page-btn-active) {
    background: #f0f4ff;
    border-color: #00a8ff;
}
.page-btn-active {
    background: #00a8ff;
    border-color: #00a8ff;
    color: #fff;
    font-weight: 600;
    cursor: default;
}
.page-btn:disabled { opacity: 0.3; cursor: default; }
.page-ellipsis { color: #bbb; padding: 0 3px; font-size: 13px; }

/* Rows masquées par le filtre */
.row-filtered { display: none; }

/* ═══════════════════════════════════════════════
   BREADCRUMB
   ═══════════════════════════════════════════════ */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.breadcrumb a {
    color: #00a8ff;
    text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }
.bc-sep    { color: #ccc; font-size: 15px; }
.bc-current { color: #444; font-weight: 500; }

/* ═══════════════════════════════════════════════
   PROGRESS BAR (top)
   ═══════════════════════════════════════════════ */
#nprogress {
    position: fixed;
    top: 0; left: 0;
    width: 0;
    height: 3px;
    z-index: 10000;
    pointer-events: none;
    background: linear-gradient(90deg, #00a8ff, #0055cc);
    box-shadow: 0 0 8px rgba(0, 168, 255, 0.55);
    opacity: 0;
    will-change: width, opacity;
}

/* ═══════════════════════════════════════════════
   CONFIRMATION MODAL
   ═══════════════════════════════════════════════ */
#confirm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}
#confirm-overlay.open { display: flex; }
#confirm-dialog {
    background: #fff;
    border-radius: 10px;
    padding: 28px 32px;
    min-width: 320px;
    max-width: 460px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .22);
}
#confirm-dialog p {
    margin: 0 0 22px;
    font-size: .98rem;
    line-height: 1.55;
    color: #1a1a2e;
}
.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.confirm-actions .btn-cancel {
    padding: 8px 18px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: .88rem;
    color: #444;
}
.confirm-actions .btn-cancel:hover { background: #f5f5f5; }
.confirm-actions .btn-danger-confirm {
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    background: #e53e3e;
    color: #fff;
    cursor: pointer;
    font-size: .88rem;
    font-weight: 600;
}
.confirm-actions .btn-danger-confirm:hover { background: #c53030; }
