* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #2c3e50;
    min-height: 100vh;
    padding: 20px;
}

/* ============================================================================
   VALIDATION FLAG — bandeau drapeau en haut à gauche
   ============================================================================ */
.validation-flag {
    position: fixed;
    top: 80px;
    left: 12px;
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: linear-gradient(135deg, #e67e22, #f39c12);
    color: white;
    padding: 10px 20px 10px 16px;
    border-radius: 8px 8px 8px 0;
    font-size: 0.88em;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(230, 126, 34, 0.4);
    animation: flagPulse 2s ease-in-out infinite;
    max-width: 480px;
    transition: all 0.3s ease;
}

.validation-flag.flag-success {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.4);
    animation: none;
}

.validation-flag.flag-error {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
    animation: none;
}

.validation-flag::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 0;
    height: 0;
    border-left: 8px solid #c0652a;
    border-bottom: 8px solid transparent;
}

.validation-flag.flag-success::after {
    border-left-color: #1e8449;
}

.validation-flag.flag-error::after {
    border-left-color: #a93226;
}

@keyframes flagPulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(230, 126, 34, 0.4); }
    50% { box-shadow: 0 4px 25px rgba(230, 126, 34, 0.7); }
}

.validation-flag .flag-icon {
    font-size: 1.1em;
    flex-shrink: 0;
    margin-top: 2px;
}

.validation-flag .flag-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.validation-flag .flag-title {
    font-weight: 700;
}

.validation-flag .flag-message {
    font-weight: 400;
    font-size: 0.9em;
    opacity: 0.95;
    white-space: pre-line;
    line-height: 1.4;
}

.validation-flag .flag-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85em;
    transition: background 0.2s ease;
    margin-top: -2px;
}

.validation-flag .flag-close:hover {
    background: rgba(255, 255, 255, 0.4);
}

.app-wrapper {
    max-width: 1600px;
    margin: 0 auto;
}

.app-header {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    padding: 20px 30px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.app-header h1 {
    font-size: 1.8em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95em;
}

.user-info .separator {
    color: rgba(255, 255, 255, 0.5);
    margin: 0 5px;
}

.filters-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.section-header {
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 1.3em;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
}

.filters-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-select, .form-control {
    padding: 10px 14px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
    font-family: inherit;
}

.form-select:focus, .form-control:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-select:disabled {
    background: #e9ecef;
    cursor: not-allowed;
    opacity: 0.7;
}

.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9em;
}

.btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    box-shadow: 0 2px 10px rgba(52, 152, 219, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
}

.btn-secondary {
    background: #ecf0f1;
    color: #2c3e50;
    border: 2px solid #bdc3c7;
}

.btn-secondary:hover {
    background: #d5dbdb;
    border-color: #95a5a6;
}

.btn-success {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    box-shadow: 0 2px 10px rgba(39, 174, 96, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    box-shadow: 0 2px 10px rgba(231, 76, 60, 0.3);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

/* Icon-only buttons */
.btn.btn-icon {
    width: 42px;
    height: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 1.1em;
    flex-shrink: 0;
}

.toolbar {
    background: white;
    border-radius: 12px;
    padding: 20px 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.toolbar-left, .toolbar-right {
    display: flex;
    gap: 15px;
    align-items: center;
}

.search-box {
    position: relative;
    width: 300px;
}

.search-box input {
    width: 100%;
    padding-right: 40px;
}

.search-box i {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    pointer-events: none;
}

.grid-container {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    height: calc(100vh - 280px);
    min-height: 500px;
}

#inventoryGrid {
    height: 100%;
    width: 100%;
}

.loading-overlay {
    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;
    z-index: 9999;
}

.spinner {
    background: white;
    padding: 40px 60px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.spinner i {
    font-size: 3em;
    color: #3498db;
    margin-bottom: 15px;
}

.spinner p {
    font-size: 1.2em;
    color: #2c3e50;
    margin: 0;
}

/* AG Grid Custom Styles */
.ag-theme-alpine {
    --ag-font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --ag-font-size: 14px;
    --ag-header-background-color: #2c3e50;
    --ag-header-foreground-color: white;
    --ag-odd-row-background-color: #f8f9fa;
    --ag-row-hover-color: #e3f2fd;
    --ag-border-color: #dee2e6;
}

.ag-header-cell-label {
    justify-content: center;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ag-cell {
    display: flex;
    align-items: center;
}

/* Action Button Styles in Grid */
.action-btn-grid {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85em;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 40px;
    height: 36px;
}

.action-btn-grid i {
    font-size: 1em;
}

.btn-view-grid {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: white;
}

.btn-view-grid:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(155, 89, 182, 0.4);
}

.btn-edit-grid {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.btn-edit-grid:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.btn-delete-grid {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.btn-delete-grid:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.actions-cell {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    height: 100%;
}

/* Status Badge */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85em;
    text-align: center;
    display: inline-block;
}

.status-0 {
    background: #fff3cd;
    color: #856404;
}

.status-1 {
    background: #cfe2ff;
    color: #084298;
}

.status-2 {
    background: #d1e7dd;
    color: #0f5132;
}

.status-3 {
    background: #f8d7da;
    color: #842029;
}

/* Tags container */
.tags-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 0;
    align-items: center;
}

/* Selection & Team Tags */
.selection-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.4;
}

.tag-default {
    background: #e9ecef;
    color: #495057;
}

.tag-family {
    background: #dbeafe;
    color: #1e40af;
}

.tag-subfamily {
    background: #ede9fe;
    color: #5b21b6;
}

.tag-location {
    background: #d1fae5;
    color: #065f46;
}

.tag-range {
    background: #fef3c7;
    color: #92400e;
}

.tag-team {
    background: #fce7f3;
    color: #9d174d;
}

/* ============================================================================
   MODAL - Création inventaire
   ============================================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.15s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 92%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: visible;
    animation: modalSlideUp 0.2s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
}

.modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1em;
    font-weight: 600;
}

.modal-title i {
    font-size: 1.1em;
    opacity: 0.85;
}

.modal-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-body {
    padding: 24px 20px;
    overflow: visible;
    flex: 1;
}

.modal-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group-full {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.88em;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-group .required {
    color: #e74c3c;
}

.form-input {
    padding: 10px 14px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 0.95em;
    color: #2c3e50;
    background: #f8f9fa;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
}

.form-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
    background: white;
}

.form-hint {
    font-size: 0.82em;
    color: #95a5a6;
    font-style: italic;
}

/* Checkbox group for collaborators */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #f8f9fa;
    max-height: 160px;
    overflow-y: auto;
}

.checkbox-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 6px;
    background: white;
    border: 1px solid #e9ecef;
    cursor: pointer;
    font-size: 0.88em;
    transition: all 0.15s ease;
    user-select: none;
}

.checkbox-item:hover {
    border-color: #3498db;
    background: #e8f4fd;
}

.checkbox-item input[type="checkbox"] {
    accent-color: #3498db;
    cursor: pointer;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

@media (max-width: 600px) {
    .modal-container {
        width: 98%;
    }

    .modal-form-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
   CUSTOM MULTI-SELECT DROPDOWN (avec checkboxes, Shift, Ctrl)
   Partagé entre les pages Index (modale création) et View (édition)
   ============================================================================ */
.custom-multiselect {
    position: relative;
    width: 100%;
    font-size: 0.9em;
}

.cms-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border: 1px solid #bdc3c7;
    border-radius: 6px;
    background: #f8f9fa;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    min-height: 38px;
}

.cms-header:hover {
    border-color: #95a5a6;
}

.cms-header:focus-within,
.cms-header.active {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
    background: white;
}

.cms-placeholder {
    color: #95a5a6;
    font-style: italic;
}

.cms-count {
    color: #2c3e50;
    font-weight: 600;
}

.cms-arrow {
    font-size: 0.75em;
    color: #7f8c8d;
    transition: transform 0.25s ease;
    flex-shrink: 0;
    margin-left: 8px;
}

.cms-arrow-open {
    transform: rotate(180deg);
}

.cms-body {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #bdc3c7;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 10001;
    overflow: hidden;
}

.cms-search-wrap {
    position: relative;
    padding: 8px;
    border-bottom: 1px solid #ecf0f1;
}

.cms-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #95a5a6;
    font-size: 0.85em;
}

.cms-search {
    width: 100%;
    padding: 6px 10px 6px 30px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.9em;
    color: #2c3e50;
    background: #f8f9fa;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.cms-search:focus {
    border-color: #3498db;
    background: white;
}

.cms-actions {
    display: flex;
    gap: 4px;
    padding: 6px 8px;
    border-bottom: 1px solid #ecf0f1;
    background: #fafbfc;
}

.cms-action-btn {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: white;
    color: #2c3e50;
    font-size: 0.78em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.15s ease;
}

.cms-action-btn:hover {
    background: #e8f4fd;
    border-color: #3498db;
    color: #2980b9;
}

.cms-list {
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #bdc3c7 transparent;
}

.cms-list::-webkit-scrollbar {
    width: 5px;
}

.cms-list::-webkit-scrollbar-track {
    background: transparent;
}

.cms-list::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 3px;
}

.cms-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    cursor: pointer;
    transition: background-color 0.1s ease;
    border-bottom: 1px solid #f5f6f7;
    user-select: none;
}

.cms-item:last-child {
    border-bottom: none;
}

.cms-item:hover {
    background: #f0f7ff;
}

.cms-item-selected {
    background: #e8f4fd;
}

.cms-item-selected:hover {
    background: #d4ecfb;
}

.cms-checkbox {
    width: 16px;
    height: 16px;
    accent-color: #3498db;
    cursor: pointer;
    flex-shrink: 0;
    pointer-events: none;
}

.cms-item-text {
    flex: 1;
    font-size: 0.9em;
    color: #2c3e50;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cms-status {
    padding: 6px 12px;
    font-size: 0.75em;
    color: #7f8c8d;
    background: #fafbfc;
    border-top: 1px solid #ecf0f1;
    text-align: center;
    font-weight: 600;
}

