/* ============================================================
   GESTION DE STOCK - STYLES
   ============================================================ */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --green: #16a34a;
    --green-dark: #15803d;
    --red: #dc2626;
    --red-dark: #b91c1c;
    --orange: #f59e0b;
    --orange-dark: #d97706;
    --blue: #2563eb;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.12);
    --font: 'Segoe UI', -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 24px;
    height: 60px;
}
.brand { flex-shrink: 0; }
.brand a { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand-logo { font-size: 1.4rem; }
.main-nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav-link {
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: .9rem;
    white-space: nowrap;
    text-decoration: none;
}
.nav-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }
.user-menu { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.user-chip { font-size: .9rem; color: var(--text-muted); }

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px;
    flex: 1;
    width: 100%;
}
.footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    margin-top: 40px;
}
.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    color: var(--text-muted);
    font-size: .85rem;
}
.footer-logos { display: flex; align-items: center; gap: 12px; }
.footer-logo-img { height: 32px; width: auto; max-width: 180px; object-fit: contain; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}
.page-header h1 { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.page-header .subtitle { color: var(--text-muted); width: 100%; }
.header-actions { margin-left: auto; display: flex; gap: 8px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none !important;
    transition: all .15s;
    white-space: nowrap;
    line-height: 1.2;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: var(--green-dark); }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-dark); }
.btn-orange { background: var(--orange); color: #fff; }
.btn-orange:hover { background: var(--orange-dark); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); border-color: var(--text-muted); }
.btn-danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-lg { padding: 14px 26px; font-size: 1.05rem; }
.btn-small { padding: 5px 10px; font-size: .8rem; }
.btn-block { width: 100%; }

/* ============================================================
   CARDS / PANELS
   ============================================================ */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.panel-narrow { max-width: 640px; }
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}
.panel-header h2 { font-size: 1.15rem; font-weight: 600; }

/* ============================================================
   QUICK ACTIONS (dashboard)
   ============================================================ */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.qaction {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 12px;
    border-radius: var(--radius);
    color: #fff;
    text-decoration: none !important;
    font-weight: 700;
    transition: transform .15s, box-shadow .15s;
}
.qaction:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.qaction-green { background: linear-gradient(135deg, #22c55e, #15803d); }
.qaction-red { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.qaction-blue { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.qaction-orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.qaction-icon { font-size: 2rem; }
.qaction-label { font-size: 1rem; }
/* Blocs avec image en fond (visuels ENTREE/SORTIE/INVENTAIRE/TRANSFERT) :
   image TOUJOURS entière (contain = aucun recadrage), blocs au rapport 16:9
   ≈ celui des visuels (1211×652) pour un remplissage optimal. */
.qaction-img {
    background-color: #334155;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    min-height: 130px; /* repli navigateurs anciens */
    aspect-ratio: 16 / 9;
}

/* ============================================================
   STATS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: .85rem; }
.stat-danger.stat-alert { border-color: var(--red); }
.stat-warning.stat-alert { border-color: var(--orange); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-type-entree { background: #dcfce7; color: #15803d; }
.badge-type-sortie { background: #fee2e2; color: #b91c1c; }
.badge-type-inventaire { background: #dbeafe; color: #1d4ed8; }
.badge-type-regularisation { background: #f3e8ff; color: #7e22ce; }
.badge-type-transfert { background: #fed7aa; color: #c2410c; }

/* ============================================================
   TEXT COLORS
   ============================================================ */
.text-success { color: var(--green); }
.text-danger { color: var(--red); }
.text-warning { color: var(--orange); }
.text-muted { color: var(--text-muted); }
.muted { color: var(--text-muted); }
.small { font-size: .8rem; }
.ref { font-weight: 600; white-space: nowrap; }

/* ============================================================
   TABLES
   ============================================================ */
.table-responsive { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
.table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table-striped tbody tr:nth-child(even) { background: #f8fafc; }
.table .num { text-align: right; }
.table .actions { text-align: right; white-space: nowrap; }
.article-link { font-weight: 500; }
.inline-form { display: inline; }

/* ============================================================
   FORMS
   ============================================================ */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-weight: 600; font-size: .9rem; color: var(--text); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.form-hint { color: var(--text-muted); font-size: .8rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: var(--font);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
textarea { resize: vertical; }
.filter-select { width: auto; min-width: 160px; }
.input-inline { width: 110px; }
.checkbox-inline { display: flex; align-items: center; gap: 6px; font-size: .9rem; }

/* ============================================================
   SEARCH
   ============================================================ */
.filter-form { display: flex; flex-direction: column; gap: 12px; }
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}
.search-results.show { display: block; }
.search-result-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.search-result-item:hover { background: var(--bg); }
.search-result-item .sr-name { font-weight: 500; }
.search-result-item .sr-detail { color: var(--text-muted); font-size: .8rem; white-space: nowrap; }
.search-shortcut { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

.article-search { font-size: 1.1rem; padding: 12px; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 500;
    border-left: 4px solid;
}
.alert-success { background: #f0fdf4; border-color: var(--green); color: #166534; }
.alert-error { background: #fef2f2; border-color: var(--red); color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: var(--orange); color: #92400e; }
.alert-info { background: #eff6ff; border-color: var(--blue); color: #1e40af; }

/* ============================================================
   ALERTS LIST (dashboard)
   ============================================================ */
.alert-list { display: flex; flex-direction: column; gap: 4px; }
.alert-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
}
.alert-row:hover { background: var(--bg); text-decoration: none; }
.alert-ref { font-weight: 600; min-width: 120px; }
.alert-desig { flex: 1; }
.alert-stock { font-weight: 700; white-space: nowrap; }
.alert-empl { color: var(--text-muted); white-space: nowrap; }

/* ============================================================
   ACTIVITY
   ============================================================ */
.activity-list { display: flex; flex-direction: column; gap: 8px; }
.activity-item {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 8px 10px;
    background: #f8fafc;
    border-radius: 8px;
    font-size: .85rem;
}
.activity-date { color: var(--text-muted); white-space: nowrap; }
.activity-user { font-weight: 600; white-space: nowrap; }
.activity-action { font-weight: 500; }
.activity-details { color: var(--text-muted); }

/* ============================================================
   ARTICLE DETAIL
   ============================================================ */
.article-detail { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.stock-big { font-size: 2.4rem; font-weight: 700; text-align: center; padding: 8px; }
.stock-status { text-align: center; padding: 12px; }
.stock-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.stock-current-value { font-size: 1.6rem; font-weight: 700; color: var(--green); }

/* ============================================================
   ADMIN
   ============================================================ */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.admin-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
    text-decoration: none !important;
    color: var(--text);
    transition: transform .15s, box-shadow .15s;
}
.admin-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.admin-card-icon { font-size: 2rem; margin-bottom: 8px; }
.admin-card-title { font-weight: 700; font-size: 1rem; }
.admin-card-count { color: var(--text-muted); font-size: .85rem; margin-top: 4px; }

/* ============================================================
   IMPORT
   ============================================================ */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--primary); background: #f8fafc; }
.dropzone-icon { font-size: 3rem; margin-bottom: 8px; }
.dropzone input[type="file"] { display: none; }
.summary-boxes { display: flex; gap: 12px; }
.summary-box {
    flex: 1;
    text-align: center;
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.summary-value { font-size: 2.4rem; font-weight: 700; }
.summary-valid { background: #f0fdf4; color: #15803d; }
.summary-error { background: #fef2f2; color: #b91c1c; }
.row-error td { background: #fef2f2; }
.row-error-detail td { background: #fef2f2; font-size: .8rem; }
.error-details { color: #b91c1c; }

/* ============================================================
   AUTH
   ============================================================ */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #eff6ff, #e0f2fe);
}
.auth-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 380px;
    max-width: 92vw;
}
.auth-logos { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 8px; }
.auth-logo-img { max-height: 56px; width: auto; max-width: 100%; object-fit: contain; }
.auth-card h1 { text-align: center; font-size: 1.5rem; margin-top: 8px; }
.auth-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 24px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-hint { text-align: center; color: var(--text-muted); font-size: .75rem; margin-top: 20px; }
.auth-card.center { text-align: center; }

/* ============================================================
   INVENTORY
   ============================================================ */
.stock-reel-input { font-weight: 600; }
.ecart-cell { font-weight: 600; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .article-detail { grid-template-columns: 1fr; }
    .quick-actions { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
    .main-nav { order: 3; width: 100%; }
    .topbar-inner { flex-wrap: wrap; height: auto; padding: 8px 16px; gap: 8px; }
    .quick-actions { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .page-header h1 { font-size: 1.3rem; }
    .filter-row { flex-direction: column; align-items: stretch; }
    .filter-select { width: 100%; }
    .user-menu { margin-left: auto; }
}
