/* ============================================================
   Admin - Catalogue impressions 3D
   Thème : papier technique / atelier. Police mono réservée aux
   valeurs chiffrées (dimensions, prix) pour les distinguer du texte.
   ============================================================ */

:root {
    --bg: #F4F6F8;
    --surface: #FFFFFF;
    --border: #D8DCE2;
    --text: #1A1D23;
    --text-muted: #5C6470;
    --accent: #E8631C;
    --accent-dark: #C8500F;
    --success: #2F7D52;
    --success-bg: #E7F3EC;
    --error: #C23B3B;
    --error-bg: #FBEAEA;

    --font-body: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 32px 40px 80px;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
}

h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 24px;
    padding-bottom: 0;
    border-bottom: none;
    color: var(--text);
}

.page-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 24px;
    color: var(--text);
}
.page-title svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    stroke: var(--accent);
}
.page-title h1 {
    margin: 0;
    padding: 0;
    color: var(--text);
}

/* ------------------------------------------------------------
   Messages flash
   ------------------------------------------------------------ */
.flash {
    padding: 12px 16px;
    margin-bottom: 20px;
    border-left: 3px solid;
    font-size: 14px;
}
.flash-success { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.flash-error   { background: var(--error-bg); border-color: var(--error); color: var(--error); }

/* ------------------------------------------------------------
   Boutons
   ------------------------------------------------------------ */
.btn-add, .btn-submit, .btn-edit, .btn-view, .btn-delete, .btn-cancel,
#btn-add-fichier3d, .btn-remove-row {
    display: inline-block;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.btn-add, .btn-submit { background: var(--text); color: var(--surface); border-color: var(--text); margin-bottom: 20px; }
.btn-add:hover, .btn-submit:hover { background: var(--accent); border-color: var(--accent); }

.btn-edit:hover, .btn-view:hover, #btn-add-fichier3d:hover { border-color: var(--accent); color: var(--accent); }
.btn-delete, .btn-remove-row { color: var(--error); }
.btn-delete:hover, .btn-remove-row:hover { background: var(--error-bg); border-color: var(--error); }
.btn-cancel { color: var(--text-muted); margin-left: 8px; }

.form-delete { display: inline; }

/* ------------------------------------------------------------
   Table liste items
   ------------------------------------------------------------ */
.items-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
}
.items-table th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 10px 14px;
    border-bottom: 2px solid var(--text);
}
.items-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text);
}
.items-table tr:hover { background: #FAFAFA; }
.items-table td.cell-reference {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

/* Tableau catalogue complet (admin/index.php) */
.table-scroll {
    overflow-x: auto;
    width: 100%;
}
.items-table-full {
    min-width: 1400px;
}
.items-table-full th,
.items-table-full td {
    white-space: nowrap;
    padding: 8px 10px;
}
.items-table-full .cell-nom {
    white-space: normal;
    min-width: 140px;
    max-width: 200px;
    font-weight: 700;
}
.items-table-full .cell-tags {
    white-space: normal;
    min-width: 100px;
    max-width: 160px;
}

.thumb-small {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border: 1px solid var(--border);
}
.no-photo {
    font-size: 12px;
    color: var(--text-muted);
}
.actions { white-space: nowrap; }
.action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    padding: 0;
    margin-right: 4px;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.action-icon svg {
    width: 15px;
    height: 15px;
    display: block;
}
.action-icon:hover { border-color: var(--accent); color: var(--accent); }
.action-icon-delete:hover { border-color: var(--error); color: var(--error); background: var(--error-bg); }

/* ------------------------------------------------------------
   Formulaire
   ------------------------------------------------------------ */
fieldset {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 20px 24px;
    margin-bottom: 20px;
}
legend {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    padding: 0 6px;
}

label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin: 14px 0 6px;
    color: var(--text-muted);
}
label:first-of-type { margin-top: 0; }

input[type="text"], input[type="number"], input[type="url"],
input[type="file"], select {
    width: 100%;
    max-width: 420px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 3px;
    font-family: var(--font-body);
    font-size: 14px;
    background: #FCFCFD;
}
input[type="number"] { font-family: var(--font-mono); }

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232, 99, 28, 0.12);
}

.field-readonly {
    background: #EFF1F3 !important;
    color: var(--text-muted);
    font-family: var(--font-mono);
    cursor: not-allowed;
}

.dimensions-group {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 420px;
}
.dimensions-group input { font-family: var(--font-mono); }
.dimensions-group span { color: var(--text-muted); font-weight: 600; }

.checkbox-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
}
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 400;
    color: var(--text);
    margin: 0;
}
.checkbox-item input { width: auto; }

.hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.hint span { font-family: var(--font-mono); font-weight: 700; color: var(--text); }

/* ------------------------------------------------------------
   Lignes fichiers 3D dynamiques
   ------------------------------------------------------------ */
.fichier3d-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px dashed var(--border);
    border-radius: 3px;
}
.fichier3d-row input { max-width: none; flex: 1; margin: 0; }

/* ------------------------------------------------------------
   Listes réordonnables (drag and drop)
   ------------------------------------------------------------ */
.reorder-list {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.reorder-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #FCFCFD;
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: grab;
}
.reorder-list li.dragging { opacity: 0.4; }
.reorder-list li input[type="text"],
.reorder-list li input[type="url"] {
    margin: 0;
    max-width: 200px;
    font-size: 14px;
    padding: 5px 8px;
}
.drag-handle {
    color: var(--text-muted);
    font-size: 16px;
    cursor: grab;
    user-select: none;
}
.delete-label {
    margin-left: auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--error);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.delete-label input { width: auto; }

.photo-list .thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border: 1px solid var(--border);
}

.back-link {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}
.back-link:hover { color: var(--accent); }

/* --- Layout 2 colonnes dans le fieldset Informations générales --- */
.form-infos-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}
.form-infos-fields {
    flex: none;
    width: 440px;
}
.form-infos-photo {
    flex: 1;
    height: 920px;
    align-self: flex-start;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: #F4F6F8;
    overflow: hidden;
}
.form-preview-photo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.form-preview-placeholder {
    width: 120px;
    height: 120px;
    overflow: hidden;
    opacity: 0.5;
}
.form-preview-placeholder svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* --- Badge état annonce dans le tableau admin --- */
.annonce-etat-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    white-space: nowrap;
}
.annonce-etat-initiée   { background: #E8F0FE; color: #3B6FD4; border-color: #3B6FD4; }
.annonce-etat-postée    { background: #E7F3EC; color: #2F7D52; border-color: #2F7D52; }
.stock-zero     { background: #FBEAEA; color: #C23B3B; }
.stock-positive { background: #E7F3EC; color: #2F7D52; }

/* --- Toolbar catalogue (boutons ajouter + exporter) --- */
.catalogue-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}
.catalogue-toolbar .btn-add { margin-bottom: 0; }

.btn-export {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.btn-export svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-export:hover { border-color: var(--accent); color: var(--accent); }

/* --- Tri des colonnes --- */
.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
    justify-content: center;
}
.sort-link:hover { color: var(--accent); }
.sort-icon { font-size: 11px; line-height: 1; }
.sort-inactive { color: var(--border); }
.sort-active   { color: var(--accent); }

/* --- Centrage colonnes tableau --- */
.items-table-full th,
.items-table-full td { text-align: center; }
.items-table-full th:first-child,
.items-table-full td:first-child,
.items-table-full td.cell-nom,
.items-table-full td.cell-tags { text-align: left; }

/* --- Stock éditable inline --- */
.cell-stock {
    cursor: pointer;
    position: relative;
    min-width: 60px;
}
.cell-stock:hover .stock-value {
    text-decoration: underline dotted;
    color: var(--accent);
}
.stock-input {
    width: 60px;
    padding: 3px 6px;
    border: 1px solid var(--accent);
    border-radius: 3px;
    font-size: 14px;
    font-family: var(--font-body);
    text-align: center;
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(232, 99, 28, 0.12);
    outline: none;
}

/* --- Bouton dupliquer --- */


/* --- Homepage admin : grille de tuiles --- */
.home-tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    max-width: 640px;
    margin-top: 8px;
}
.home-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 2.5rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-body);
    transition: border-color 0.15s ease, color 0.15s ease;
}
.home-tile svg {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}
.home-tile:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* --- Barre de recherche (admin/catalogue.php) --- */
.search-bar-wrap { margin-bottom: 16px; }
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 12px;
    transition: border-color 0.15s ease;
}
.search-bar:focus-within { border-color: var(--accent); }
.search-icon { width: 16px; height: 16px; flex-shrink: 0; stroke: var(--text-muted); }
.search-bar input[type="text"].search-input,
.search-bar .search-input {
    flex: 1;
    width: auto !important;
    max-width: none !important;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    font-size: 14px;
    font-family: var(--font-body);
    color: var(--text);
    padding: 11px 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}
.search-input::placeholder { color: var(--text-muted); }
.search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    flex-shrink: 0;
}
.search-clear svg { width: 13px; height: 13px; }
.search-clear:hover { color: var(--accent); }

/* --- Pagination admin --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 24px 0 12px;
    flex-wrap: wrap;
}
.pagination-btn {
    display: inline-flex;
    align-items: center;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.pagination-btn:not(.pagination-disabled):hover { border-color: var(--accent); color: var(--accent); }
.pagination-disabled { opacity: 0.4; cursor: default; }
.pagination-pages { display: flex; gap: 4px; }
.pagination-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.pagination-page:hover { border-color: var(--accent); color: var(--accent); }
.pagination-current { border-color: var(--accent); background: var(--accent); color: #fff; cursor: default; }
.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: var(--text-muted);
    font-size: 13px;
}
.pagination-footer {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
    width: 100%;
}
.per-page-form { display: flex; align-items: baseline; gap: 6px; flex-shrink: 0; }
.per-page-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.pagination-footer .per-page-select {
    padding: 2px 6px !important;
    width: auto !important;
    max-width: none !important;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    font-size: 12px !important;
    font-family: var(--font-body);
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.15s ease;
    line-height: 1.4;
    height: auto !important;
}
.per-page-select:focus { outline: none; border-color: var(--accent); }
.result-count-pager { font-size: 12px; color: var(--text-muted); margin: 0; }

/* --- Icônes lien Vinted dans le tableau catalogue --- */
.action-icon-vinted {
    text-decoration: none;
}
.action-icon-vinted:hover { border-color: #3B6FD4; color: #3B6FD4; background: #E8F0FE; }
.action-icon-no-vinted {
    opacity: 0.35;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    pointer-events: none;
}

/* --- Bouton Vendu --- */
.action-icon-vendu:hover:not(:disabled) { border-color: #2F7D52; color: #2F7D52; background: #E7F3EC; }
.action-icon-disabled { opacity: 0.3; cursor: not-allowed; }
.cell-ventes { font-weight: 600; color: var(--text-muted); text-align: center; }

/* --- Icône QR --- */
.action-icon-qr:hover { border-color: #b8860b; color: #b8860b; background: #fdf8e1; }

/* --- Modale QR Code --- */
.modal-qr-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}
.modal-qr-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 340px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-qr-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-qr-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}
.modal-qr-ref {
    font-size: 12px;
    color: var(--text-muted);
}
.modal-qr-close {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.modal-qr-close:hover { color: var(--text); }
.modal-qr-close svg { width: 16px; height: 16px; }
.modal-qr-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #fff;
}
.modal-qr-body canvas { display: block; }
.modal-qr-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.modal-qr-url {
    font-size: 11px;
    color: var(--text-muted);
    word-break: break-all;
    margin: 0;
}
.modal-qr-footer .btn-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
}
