/* Variables et réinitialisation */
:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --light-gray: #f3f4f6;
    --dark-gray: #4b5563;
    --border-color: #e5e7eb;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #10b981;
    --success-hover: #059669;
}

/* Classes utilitaires inspirées de Tailwind */
.flex {
    display: flex;
}

.flex-1 {
    flex: 1;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.w-full {
    width: 100%;
}

.h-32 {
    height: 8rem;
}

.font-medium {
    font-weight: 500;
}

.font-semibold {
    font-weight: 600;
}

.text-sm {
    font-size: 0.875rem;
}

.text-xl {
    font-size: 1.25rem;
}

.text-2xl {
    font-size: 1.5rem;
}

.text-center {
    text-align: center;
}

.text-gray-500 {
    color: #6b7280;
}

.text-gray-600 {
    color: #4b5563;
}

.text-white {
    color: white;
}

.text-red-500 {
    color: #ef4444;
}

.bg-blue-500 {
    background-color: #3b82f6;
}

.bg-blue-600 {
    background-color: #2563eb;
}

.bg-red-500 {
    background-color: #ef4444;
}

.bg-red-600 {
    background-color: #dc2626;
}

.bg-green-500 {
    background-color: #10b981;
}

.bg-green-600 {
    background-color: #059669;
}

.bg-gray-100 {
    background-color: #f3f4f6;
}

.bg-gray-500 {
    background-color: #6b7280;
}

.bg-gray-600 {
    background-color: #4b5563;
}

.p-1 {
    padding: 0.25rem;
}

.p-2 {
    padding: 0.5rem;
}

.p-4 {
    padding: 1rem;
}

.px-2 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.px-3 {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.px-4 {
    padding-left: 1rem;
    padding-right: 1rem;
}

.py-1 {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.py-2 {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.mr-2 {
    margin-right: 0.5rem;
}

.mr-3 {
    margin-right: 0.75rem;
}

.ml-2 {
    margin-left: 0.5rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.w-16 {
    width: 4rem;
}

.border {
    border: 1px solid var(--border-color);
}

.border-b {
    border-bottom: 1px solid var(--border-color);
}

.border-b-2 {
    border-bottom-width: 2px;
}

.border-blue-500 {
    border-color: #3b82f6;
}

.rounded {
    border-radius: 0.25rem;
}

.max-h-96 {
    max-height: 24rem;
}

.overflow-y-auto {
    overflow-y: auto;
}

.italic {
    font-style: italic;
}

.hover\:bg-gray-100:hover {
    background-color: #f3f4f6;
}

.hover\:bg-blue-600:hover {
    background-color: #2563eb;
}

.hover\:bg-red-600:hover {
    background-color: #dc2626;
}

.hover\:bg-green-600:hover {
    background-color: #059669;
}

.hover\:bg-gray-600:hover {
    background-color: #4b5563;
}

.last\:border-b-0:last-child {
    border-bottom-width: 0;
}

/* Spinner pour chargement */
.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: #09f;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    background-color: #f9fafb;
    color: #111827;
    padding: 20px;
}

/* Mise en page principale */
.container {
    max-width: 600px;
    margin: 0 auto;
    background-color: white;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 20px;
}

.logo {
    height: 80px;
    max-width: 100%;
}

/* Formulaire et éléments */
.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
}

select, input, textarea, .flatpickr-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.15s ease-in-out;
}

select:focus, input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.tech-container {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.tech-container input {
    flex: 1;
}

.tech-container select {
    width: 40%;
}

textarea {
    min-height: 80px;
    resize: vertical;
}

/* Boutons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

.btn:hover {
    background-color: var(--primary-hover);
}

.btn-danger {
    background-color: var(--danger-color);
}

.btn-danger:hover {
    background-color: var(--danger-hover);
}

.btn-success {
    background-color: var(--success-color);
}

.btn-success:hover {
    background-color: var(--success-hover);
}

.btn-sm {
    padding: 4px 8px;
    font-size: 14px;
}

/* Zone de message généré */
.message-container {
    position: relative;
    margin-top: 20px;
}

#generatedMessage {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    padding-right: 40px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    white-space: pre-wrap;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--dark-gray);
}

.copy-btn:hover {
    color: var(--primary-color);
}

/* Tabs */
.tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.tab {
    padding: 8px 16px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-weight: 500;
}

.tab.active {
    border-bottom: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Pièces consommées */
.pieces-list {
    margin-bottom: 16px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.piece-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.piece-item:last-child {
    border-bottom: none;
}

.piece-details {
    flex: 1;
}

.piece-actions {
    display: flex;
    gap: 4px;
}

.piece-form {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.piece-form input {
    flex: 1;
}

.piece-form .btn {
    white-space: nowrap;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.open {
    display: flex;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--dark-gray);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* Responsive */
@media (max-width: 640px) {
    .tech-container {
        flex-direction: column;
    }
    
    .tech-container select {
        width: 100%;
    }
    
    .piece-form {
        flex-direction: column;
    }
}

/* Tooltips for inventory */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

/* Suggestion dropdown */
.autocomplete-container {
    position: relative;
}

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 0 0 4px 4px;
    z-index: 10;
    display: none;
}

.suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
}

.suggestion-item:hover {
    background-color: var(--light-gray);
}
/* Styles pour la section des modèles de pièces */
.template-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.template-selection {
    background-color: #f9fafb;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

#template-table {
    border-collapse: collapse;
    width: 100%;
}

#template-table th,
#template-table td {
    border: 1px solid var(--border-color);
    padding: 8px;
}

#template-table thead th {
    background-color: #f3f4f6;
    font-weight: 600;
}

#template-table tbody tr:nth-child(even) {
    background-color: #f9fafb;
}

.template-quantity {
    width: 70px;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: center;
}

.template-add-btn {
    padding: 4px 8px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
    font-size: 0.85rem;
}

.template-add-btn:hover {
    background-color: var(--primary-hover);
}

/* Ajuster la largeur des colonnes */
#template-table .col-ref {
    width: 15%;
}
#template-table .col-desc {
    width: 55%;
}
#template-table .col-qty {
    width: 15%;
}
#template-table .col-actions {
    width: 15%;
}