/* SAULX INVENTORY - thème inspiré de GLPI 10 */

:root {
    --sidebar-bg: #25325a;
    --sidebar-bg-2: #1d2849;
    --sidebar-text: #c3cce3;
    --sidebar-active: rgba(255, 255, 255, .10);
    --accent: #f28c28; /* orange du logo */
    --primary: #2f3f64;
    --primary-hover: #24314f;
    --link: #2f5aa8;
    --bg: #f3f5f9;
    --card: #ffffff;
    --border: #e1e6ef;
    --text: #1f2a3d;
    --muted: #6c7a91;
    --success: #2fb344;
    --warning: #f59f00;
    --danger: #d63939;
    --info: #4299e1;
    --radius: 6px;
    --shadow: 0 1px 2px rgba(30, 41, 59, .06);
    --font: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: Consolas, "Cascadia Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; font-weight: 600; }
code, kbd, .mono { font-family: var(--mono); }
code { background: #eef1f7; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
kbd {
    display: inline-block; padding: 0 6px; font-size: 12px; border: 1px solid #cdd4e0;
    border-bottom-width: 2px; border-radius: 4px; background: #fff;
}
.icon { flex-shrink: 0; vertical-align: -3px; }

/* ---------- Structure ---------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
    color: var(--sidebar-text);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.brand {
    display: flex; align-items: center; gap: 10px;
    height: 60px; padding: 0 20px;
    color: #fff; text-decoration: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand-logo {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 8px;
    background: var(--accent); color: var(--sidebar-bg);
}
.brand-img { width: 40px; height: 40px; flex-shrink: 0; border-radius: 8px; }
.brand-text { font-weight: 800; font-size: 18px; letter-spacing: .5px; line-height: 1; }
.brand-text small {
    display: block; font-weight: 500; font-size: 11px; letter-spacing: 2px;
    text-transform: uppercase; color: var(--accent); margin-top: 3px;
}

.menu { padding: 10px 0 20px; }
.menu-section {
    padding: 16px 20px 6px;
    font-size: 11px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase;
    color: rgba(195, 204, 227, .55);
}
.menu-item {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 20px;
    color: var(--sidebar-text);
    border-left: 3px solid transparent;
    text-decoration: none !important;
    transition: background .15s;
}
.menu-item:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.menu-item.active { background: var(--sidebar-active); color: #fff; border-left-color: var(--accent); font-weight: 500; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: 60px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 0 24px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--muted); min-width: 0; }
.breadcrumb a { color: var(--muted); }
.breadcrumb .sep { color: #b3bccb; display: inline-flex; }
.breadcrumb .current { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.user-menu { position: relative; }
.user-menu summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px; border-radius: var(--radius);
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: #f1f4f9; }
.user-info { display: flex; flex-direction: column; line-height: 1.2; }
.user-info small { color: var(--muted); font-size: 12px; }
.dropdown {
    position: absolute; right: 0; top: calc(100% + 6px);
    min-width: 190px; padding: 6px 0;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(30, 41, 59, .12);
}
.dropdown a, .dropdown button {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 8px 14px; border: 0; background: none;
    font: inherit; color: var(--text); text-align: left; cursor: pointer;
    text-decoration: none;
}
.dropdown a:hover, .dropdown button:hover { background: #f1f4f9; }

.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary); color: #fff; font-size: 13px; font-weight: 600;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10px; vertical-align: middle; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }

.content { padding: 24px; flex: 1; }
.footer { padding: 14px 24px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); background: #fff; }

.page-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-header h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 22px; }
.page-header h1 .icon { color: var(--primary); }

/* ---------- Cartes ---------- */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
}
.card-header h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.card-body { padding: 18px; }
.card-highlight { border-top: 3px solid var(--accent); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-sidebar { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.mt { margin-top: 20px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--muted); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }

.empty-state { text-align: center; color: var(--muted); padding: 36px 18px; }
.empty-state p { margin: 10px 0 16px; }

/* ---------- Boutons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px;
    font: inherit; font-weight: 500; line-height: 1.3;
    border: 1px solid transparent; border-radius: var(--radius);
    cursor: pointer; text-decoration: none !important; white-space: nowrap;
    transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: #fff; color: var(--text); border-color: #cfd6e2; }
.btn-outline:hover { background: #f4f6fa; }
.btn-danger { background: #fff; color: var(--danger); border-color: #f0c2c2; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-link { background: none; color: var(--link); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn.copied { background: var(--success); }

/* ---------- Formulaires ---------- */

input[type=text], input[type=password], input[type=search], select {
    width: 100%;
    padding: 8px 11px;
    font: inherit; color: var(--text);
    background: #fff;
    border: 1px solid #cfd6e2; border-radius: var(--radius);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: #6b86c4; box-shadow: 0 0 0 3px rgba(47, 90, 168, .15); }
select:disabled { background: #f3f5f9; color: var(--muted); }
.input-lg { font-size: 16px; padding: 10px 13px; font-weight: 500; }

.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-stack label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; }
.form-stack label.check, label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
legend { padding: 0 6px; color: var(--muted); font-size: 13px; }

.inline-form { display: flex; gap: 10px; max-width: 560px; }
.inline-form input { flex: 1; }
.hint { display: flex; align-items: center; gap: 6px; margin: 12px 0 0; color: var(--muted); font-size: 13px; }

/* Champs d'une fiche (libellé / valeur sur deux colonnes, comme GLPI) */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 32px; }
.field { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px dashed #edf0f5; }
.field .label { color: var(--muted); text-align: right; }
.field .value { font-weight: 500; word-break: break-word; }

dl.details { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 16px; margin: 0; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; font-weight: 500; word-break: break-word; }

/* ---------- Alertes et badges ---------- */

.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 16px; margin-bottom: 16px;
    border-radius: var(--radius); border: 1px solid; border-left-width: 4px;
    background: #fff;
}
.alert .icon { margin-top: 1px; }
.alert-success { border-color: #bfe5c6; border-left-color: var(--success); color: #1d6e2b; background: #f1faf3; }
.alert-danger  { border-color: #f1c4c4; border-left-color: var(--danger);  color: #9b2323; background: #fdf3f3; }
.alert-info    { border-color: #c5ddf3; border-left-color: var(--info);    color: #1f5d95; background: #f2f8fd; }
.alert-warning { border-color: #f6dcaa; border-left-color: var(--warning); color: #8a5a00; background: #fff9ec; }

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 4px;
    font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.badge-success { background: #e3f6e7; color: #1d7a2e; }
.badge-warning { background: #fff1d6; color: #9a6500; }
.badge-info    { background: #e2effb; color: #22609b; }
.badge-primary { background: #e3e7f1; color: var(--primary); }
.badge-muted   { background: #eceff4; color: var(--muted); }

/* ---------- Tableaux ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid #edf0f5; vertical-align: middle; }
.table th {
    background: #f7f8fb; color: var(--muted);
    font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px;
    white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover tbody tr:hover { background: #f8fafd; }
.row-disabled td { color: var(--muted); }
.old-value { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(108, 122, 145, .5); }
.sort { color: inherit; display: inline-flex; align-items: center; gap: 4px; text-decoration: none !important; }
.sort .icon { opacity: .4; }
.sort.active { color: var(--text); }
.sort.active .icon { opacity: 1; }

.search-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.search-input { position: relative; flex: 1; min-width: 240px; }
.search-input .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-input input { padding-left: 34px; }
.table-info { padding: 8px 18px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--border); }

.pagination { display: flex; justify-content: center; gap: 4px; padding: 14px; border-top: 1px solid var(--border); }
.pagination a, .pagination span {
    min-width: 32px; padding: 5px 9px; text-align: center;
    border-radius: var(--radius); color: var(--text);
}
.pagination a:hover { background: #f1f4f9; text-decoration: none; }
.pagination a.active { background: var(--primary); color: #fff; }

/* ---------- Statistiques ---------- */

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.stat {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 18px;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
    color: var(--text); text-decoration: none !important;
}
.stat:hover { border-color: #c5cfdf; }
.stat strong { display: block; font-size: 22px; line-height: 1.1; }
.stat small { color: var(--muted); }
.stat-icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 8px; color: #fff; }
.bg-blue { background: var(--primary); }
.bg-orange { background: var(--warning); }
.bg-green { background: var(--success); }
.bg-red { background: var(--danger); }
.stats-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- Onglets horizontaux (journal) ---------- */

.tabs { display: flex; gap: 4px; margin-bottom: -1px; position: relative; z-index: 1; flex-wrap: wrap; }
.tabs a {
    padding: 9px 16px;
    color: var(--muted); font-weight: 500;
    border: 1px solid transparent; border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0;
    text-decoration: none !important;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { background: #fff; color: var(--text); border-color: var(--border); box-shadow: inset 0 3px 0 var(--accent); }
.tabs + .card { border-top-left-radius: 0; }

.date-field { display: flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
input[type=date] {
    padding: 7px 9px; font: inherit; color: var(--text);
    border: 1px solid #cfd6e2; border-radius: var(--radius); background: #fff;
}
.journal-message { min-width: 320px; }
.journal-message a { margin-left: 6px; font-size: 13px; }
.badge-danger { background: #fbe4e4; color: #a82424; }

/* ---------- Modification depuis la liste ---------- */

.btn-icon { padding: 5px 7px; }
.table tr.editing td { background: #fff7ee; }
.table tr:target td { animation: surligne 2.5s ease-out; }
@keyframes surligne { from { background: #ffe3c4; } to { background: transparent; } }
.edit-row td { background: #fff7ee; border-bottom: 2px solid var(--accent); padding: 12px 14px 16px; }
.edit-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.edit-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; flex: 1; min-width: 170px; }
.edit-title { display: flex; align-items: center; gap: 6px; font-weight: 600; align-self: center; min-width: 140px; }
.edit-actions { display: flex; gap: 8px; }

/* ---------- Fiche objet (onglets verticaux, comme GLPI) ---------- */

.object-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 20px; align-items: start; }
.object-tabs {
    display: flex; flex-direction: column;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; position: sticky; top: 80px;
}
.object-tabs a {
    display: flex; align-items: center; gap: 8px;
    padding: 11px 14px;
    color: var(--text); border-left: 3px solid transparent;
    border-bottom: 1px solid #edf0f5;
    text-decoration: none !important;
}
.object-tabs a:last-child { border-bottom: 0; }
.object-tabs a:hover { background: #f7f8fb; }
.object-tabs a.active { background: #eef2f9; border-left-color: var(--primary); font-weight: 600; }
.object-tabs .count { margin-left: auto; background: #e3e7f1; color: var(--primary); border-radius: 10px; padding: 0 8px; font-size: 12px; font-weight: 600; }
.danger-zone { display: flex; justify-content: flex-end; }

/* ---------- Récupération ---------- */

.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 16px; }
.steps li { padding-left: 4px; }
.steps li::marker { font-weight: 700; color: var(--primary); }
.code-box {
    display: flex; align-items: center; gap: 12px;
    margin-top: 10px; padding: 12px 12px 12px 16px;
    background: #1e2638; border-radius: var(--radius);
}
.code-box code {
    flex: 1; min-width: 0;
    background: none; padding: 0;
    color: #e6edf8; font-size: 13px;
    word-break: break-all; user-select: all;
}
.code-box .btn-primary { background: var(--accent); color: #1e2638; }
.code-box .btn-primary:hover { background: #e07a16; }
.code-box .btn.copied { background: var(--success); color: #fff; }

.waiting {
    display: flex; align-items: center; gap: 12px;
    margin-top: 22px; padding: 14px 16px;
    background: #f2f8fd; border: 1px dashed #b5d3ee; border-radius: var(--radius);
    color: #1f5d95; font-weight: 500;
}
.spinner {
    width: 18px; height: 18px; flex-shrink: 0;
    border: 2px solid #b5d3ee; border-top-color: #1f5d95; border-radius: 50%;
    animation: tourne .8s linear infinite;
}
@keyframes tourne { to { transform: rotate(360deg); } }

.grid-command { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.grid-command > .card { margin-bottom: 0; }
.presaisie {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
    margin-bottom: 18px; padding: 10px 14px;
    background: #f5f7fb; border: 1px solid var(--border); border-radius: var(--radius);
}
.small { font-size: 13px; margin: 0 0 14px; }
.select-auto { width: auto; max-width: 220px; }

.form-grid-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: end; }
.form-grid-inputs label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; }
.form-grid-inputs .form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }

.profile { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }

/* ---------- Connexion ---------- */

.page-login {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, var(--sidebar-bg) 0%, #3b4f82 100%);
}
.login-box { width: 100%; max-width: 400px; }
.login-box-large { max-width: 460px; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 22px; color: #fff; }
.login-logo { width: 170px; height: 170px; filter: drop-shadow(0 8px 20px rgba(0, 0, 0, .35)); }
.login-title { font-size: 18px; text-align: center; margin-bottom: 20px; }
.login-box .card { box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.login-box .card-body { padding: 28px; }
.login-footer { text-align: center; color: rgba(255, 255, 255, .6); font-size: 12px; margin-top: 16px; }

/* ---------- Écrans étroits ---------- */

@media (max-width: 1100px) {
    .form-grid { grid-template-columns: 1fr; }
    .grid-sidebar, .grid-command { grid-template-columns: 1fr; }
    .form-grid-inputs { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .menu { display: flex; flex-wrap: wrap; padding: 0 8px 8px; }
    .menu-section { display: none; }
    .menu-item { border-left: 0; border-radius: var(--radius); padding: 8px 12px; }
    .topbar { padding: 0 16px; }
    .user-info { display: none; }
    .content { padding: 16px; }
    .grid-2, .stats, .stats-4, .object-layout { grid-template-columns: 1fr; }
    .object-tabs { position: static; flex-direction: row; }
    .object-tabs a { flex: 1; border-left: 0; border-bottom: 3px solid transparent; }
    .object-tabs a.active { border-bottom-color: var(--primary); }
    .field { grid-template-columns: 1fr; gap: 2px; }
    .field .label { text-align: left; }
    .inline-form { flex-direction: column; }
    .code-box { flex-direction: column; align-items: stretch; }
}
