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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding: 20px;
    color: #333;
}

a {
    text-decoration: none;
    transition: all 0.3s;
}

button {
    cursor: pointer;
    border: none;
    transition: all 0.3s;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

h1 {
    color: #667eea;
    margin-bottom: 20px;
    text-align: center;
}

/* PAGE D'ACCUEIL */
.home-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.home-container {
    text-align: center;
    max-width: 500px;
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.home-container h1 {
    color: #333;
    font-size: 42px;
    margin-bottom: 15px;
}

.subtitle {
    color: #666;
    font-size: 18px;
    margin-bottom: 50px;
}

.buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.btn {
    padding: 40px 20px;
    background: white;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    font-size: 18px;
    color: #333;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
}

.btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
}

.btn-icon {
    font-size: 50px;
}

.btn-scanner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-creator {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-inventaire {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.btn-fournisseurs {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: #333;
}

.btn-matieres {
    background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
    color: #333;
}

.btn-rangements {
    background: linear-gradient(135deg, #ffa751 0%, #ffe259 100%);
    color: #333;
}

.btn-users {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500 !important;
}

.checkbox-label input[type="checkbox"] {
    width: 18px !important;
    height: 18px;
    cursor: pointer;
}

/* CONTENEURS */
.container {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.stock-container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.result-container {
    max-width: 500px;
    margin: 0 auto;
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    text-align: center;
}

/* SCANNER */
.scanner-body {
    background: #f5f5f5;
}

.info-box {
    background: #e7f3ff;
    border-left: 4px solid #667eea;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    text-align: center;
    color: #0066cc;
}

#reader {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 20px;
}

.product-info {
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
}

.info-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    min-width: 100px;
    color: #555;
}

.info-value {
    color: #333;
    flex: 1;
}

.scanner-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 20px;
}

.btn-remove, .btn-move {
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    border: none;
    transition: background 0.3s;
    width: 100%;
}

.btn-remove {
    background: #dc3545;
    color: white;
}

.btn-remove:hover {
    background: #c82333;
}

.btn-move {
    background: #ffc107;
    color: #333;
}

.btn-move:hover {
    background: #e0a800;
}

/* FORMULAIRES */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: #555;
    font-size: 15px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
    box-sizing: border-box;
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input[disabled] {
    background: #f5f5f5;
}

.creator-form-group {
    margin-bottom: 20px;
}

.creator-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: 15px;
}

.creator-form-group input,
.creator-form-group select,
.creator-form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
    box-sizing: border-box;
    resize: vertical;
}

.creator-form-group input:focus,
.creator-form-group select:focus,
.creator-form-group textarea:focus {
    outline: none;
    border-color: #f093fb;
}

.info-text {
    font-size: 13px;
    color: #999;
    margin-top: 8px;
}

/* ALERTES */
.alert {
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 500;
}

.alert-success {
    background: #d4edda;
    border-left: 4px solid #28a745;
    color: #155724;
}

.alert-info {
    background: #d1ecf1;
    border-left: 4px solid #17a2b8;
    color: #0c5460;
}

.alert-error {
    background: #f8d7da;
    border-left: 4px solid #dc3545;
    color: #721c24;
}

.error {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

/* BOUTONS */
.btn-primary, .btn-back {
    background: #667eea;
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    display: inline-block;
    text-align: center;
    transition: background 0.3s;
    text-decoration: none;
    margin-top: 20px;
}

.btn-primary:hover, .btn-back:hover {
    background: #5568d3;
}

.btn-secondary, .btn-cancel {
    background: #6c757d;
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    display: inline-block;
    text-align: center;
    transition: background 0.3s;
    text-decoration: none;
}

.btn-secondary:hover, .btn-cancel:hover {
    background: #5a6268;
}

.btn-save, .btn-download, .btn-export {
    background: #28a745;
    color: white;
    padding: 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    width: 100%;
    transition: background 0.3s;
}

.btn-save:hover, .btn-download:hover, .btn-export:hover {
    background: #218838;
}

.btn-edit {
    background: #007bff;
    color: white;
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    margin-right: 5px;
}

.btn-edit:hover {
    background: #0056b3;
}

.btn-delete {
    background: #dc3545;
    color: white;
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.btn-delete:hover {
    background: #c82333;
}

.btn-move-small {
    background: #ffc107;
    color: #333;
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
}

.btn-move-small:hover {
    background: #e0a800;
}

.search-btn {
    background: #667eea;
    color: white;
    padding: 12px 25px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

.search-btn:hover {
    background: #5568d3;
}

/* CRÉATEUR QR */
.creator-body {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.creator-container {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    max-width: 450px;
    width: 100%;
}

.creator-container h1 {
    color: #333;
    font-size: 28px;
    margin-bottom: 10px;
}

#qrContainer {
    text-align: center;
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid #eee;
    display: none;
}

#qrContainer.show {
    display: block;
}

#qrCode {
    max-width: 280px;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.url-display {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 6px;
    font-size: 12px;
    margin: 15px 0;
    word-break: break-all;
    color: #666;
    border-left: 4px solid #f093fb;
    display: none;
}

/* STOCK */
.stock-body {
    background: #f5f5f5;
}

.info-bar {
    text-align: center;
    color: #999;
    margin-bottom: 30px;
    font-size: 14px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 13px;
    opacity: 0.9;
}

.controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.search-group {
    display: flex;
    gap: 10px;
}

.search-group input {
    flex: 1;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
}

.search-group input:focus {
    outline: none;
    border-color: #667eea;
}

.sort-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.sort-group label {
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

select {
    flex: 1;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    background: white;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #667eea;
}

.table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 65vh;
    margin-bottom: 30px;
    border: 1px solid #eee;
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: #667eea;
    color: white;
    position: sticky;
    top: 0;
    z-index: 2;
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

td {
    padding: 15px;
    border-bottom: 1px solid #eee;
}

tbody tr:hover {
    background: #f9f9f9;
}

tbody tr:nth-child(even) {
    background: #fafafa;
}

.id-cell {
    font-weight: 600;
    color: #667eea;
}

.action-cell {
    display: flex;
    gap: 8px;
}

.no-results {
    text-align: center;
    padding: 30px;
    color: #999;
}

.stock-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

/* Les 3 boutons (Retour / Historique / Export) alignes et de meme largeur */
.stock-buttons > .btn-back,
.stock-buttons > .btn-export {
    flex: 1 1 0;
    width: auto;
    margin-top: 0;
    padding: 12px 20px;
    text-align: center;
    text-decoration: none;
}

/* GESTION DES RANGEMENTS */
.manage-section {
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 30px;
}

.manage-section h2 {
    color: #333;
    font-size: 22px;
    margin-bottom: 20px;
}

.manage-form {
    max-width: 600px;
}

.lieu-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.lieu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f0f0f0;
    gap: 15px;
    flex-wrap: wrap;
}

.lieu-header h3 {
    color: #667eea;
    font-size: 20px;
    margin: 0;
}

.btn-delete-small {
    background: #dc3545;
    color: white;
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.btn-delete-small:hover {
    background: #c82333;
}

.btn-delete:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

/* RÉSULTAT */
.result-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.result-alert {
    padding: 20px;
    border-radius: 6px;
    margin-bottom: 30px;
    font-size: 18px;
    font-weight: 600;
}

.result-alert.alert-success {
    background: #d4edda;
    border-left: 4px solid #28a745;
    color: #155724;
}

.result-alert.alert-error {
    background: #f8d7da;
    border-left: 4px solid #dc3545;
    color: #721c24;
}

.result-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.result-buttons a {
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    transition: background 0.3s;
}

/* PAGE DE CONNEXION */
.login-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.login-container h1 {
    color: #333;
    font-size: 32px;
    margin-bottom: 10px;
}

.login-container .subtitle {
    color: #666;
    font-size: 14px;
    margin-bottom: 30px;
}

.login-form {
    text-align: left;
}

.login-form .form-group {
    margin-bottom: 18px;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 10px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.login-footer {
    margin-top: 25px;
    font-size: 12px;
    color: #999;
}

.btn-site {
    display: inline-block;
    margin-top: 18px;
    padding: 10px 18px;
    background: transparent;
    color: #667eea;
    border: 1px solid #667eea;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.btn-site:hover {
    background: #667eea;
    color: #fff;
}

/* BARRE UTILISATEUR (accueil) */
.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f5f5f5;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 25px;
    font-size: 14px;
    color: #555;
    flex-wrap: wrap;
    gap: 10px;
}

.btn-logout {
    background: #dc3545;
    color: white;
    padding: 8px 14px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: #c82333;
}

/* BADGES D'ÉTAT */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-stock {
    background: #d4edda;
    color: #155724;
    border: 1px solid #28a745;
}

.badge-temp {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
}

.badge-partiel {
    background: #cce5ff;
    color: #004085;
    border: 1px solid #007bff;
}

/* COLORATION DES LIGNES SELON L'ÉTAT */
tbody tr.row-instance-2 {
    background: #fffbf0 !important;
}

tbody tr.row-instance-2:hover {
    background: #fff3cd !important;
}

tbody tr.row-instance-3 {
    background: #f0f7ff !important;
}

tbody tr.row-instance-3:hover {
    background: #cce5ff !important;
}

/* BOUTON RETOUR STOCK */
.btn-return {
    background: #17a2b8;
    color: white;
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
}

.btn-return:hover {
    background: #138496;
}

/* MODES DE SORTIE (remove.php) */
.mode-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 10px;
}

.mode-option {
    display: grid;
    grid-template-columns: auto auto 1fr;
    grid-template-areas:
        "radio icon title"
        "radio icon desc";
    column-gap: 12px;
    align-items: center;
    padding: 14px 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.mode-option:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.mode-option input[type="radio"] {
    grid-area: radio;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.mode-option:has(input[type="radio"]:checked) {
    border-color: #667eea;
    background: #eef0ff;
}

.mode-icon {
    grid-area: icon;
    font-size: 24px;
}

.mode-title {
    grid-area: title;
    font-weight: 600;
    color: #333;
    font-size: 16px;
}

.mode-desc {
    grid-area: desc;
    font-size: 13px;
    color: #777;
}

.qty-options {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.qty-options label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 500;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .buttons {
        grid-template-columns: 1fr;
    }

    .controls {
        grid-template-columns: 1fr;
    }

    /* Barre de recherche plus compacte */
    .search-group {
        flex-wrap: wrap;
    }

    .search-group input {
        padding: 9px 10px;
        font-size: 13px;
    }

    .search-btn {
        padding: 9px 12px;
        font-size: 13px;
    }

    /* Filtres empilés : "Trier" passe sous "État" */
    .sort-group {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .sort-group label {
        margin-left: 0 !important;
    }

    table {
        font-size: 13px;
    }

    th, td {
        padding: 10px;
    }

    .action-cell {
        flex-direction: column;
    }

    .btn-edit, .btn-delete {
        width: 100%;
        margin-right: 0;
    }

    .stock-buttons {
        flex-direction: column;
    }

    .result-buttons {
        grid-template-columns: 1fr;
    }

    .creator-container {
        padding: 20px;
    }
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 15px;
    }

    .home-container {
        padding: 20px;
    }

    .creator-container {
        padding: 20px;
    }

    .stock-container {
        padding: 15px;
    }

    .result-container {
        padding: 20px;
    }
}

/* BOUTON RETOUR AU SITE (page de connexion) */
.btn-site {
    display: inline-block;
    margin-top: 18px;
    padding: 10px 18px;
    background: transparent;
    color: #667eea;
    border: 1px solid #667eea;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.btn-site:hover {
    background: #667eea;
    color: #fff;
}

/* ===== LIGNES CLIQUABLES (inventaire) ===== */
.row-clickable {
    cursor: pointer;
}

.row-clickable:hover {
    background: #eef1ff;
}

.article-link {
    color: #667eea;
    font-weight: 600;
    text-decoration: none;
}

.article-link:hover {
    text-decoration: underline;
}

/* ===== PAGE DÉTAIL ARTICLE ===== */
.detail-header {
    margin-bottom: 20px;
}

.detail-subtitle {
    margin-top: 8px;
    color: #666;
    font-size: 15px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.detail-card {
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 10px;
    padding: 18px 20px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.detail-card h2 {
    font-size: 16px;
    color: #667eea;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #eef1ff;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    padding: 7px 0;
    border-bottom: 1px dashed #eee;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: #888;
    font-size: 14px;
}

.detail-value {
    font-weight: 600;
    color: #333;
    text-align: right;
}

.detail-empty {
    color: #bbb;
    font-weight: 400;
}

.detail-remarque {
    border-left: 4px solid #667eea;
    background: #f8f9ff;
}

.remarque-text {
    margin: 5px 0;
    font-size: 15px;
    color: #333;
    line-height: 1.6;
    white-space: pre-line;
}

.remarque-vide {
    color: #999;
    font-style: italic;
}
