/* ============================================================================
   STYLES POUR LA SECTION PIÈCES ANNEXÉES
   ============================================================================ */

.paps-pieces-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.paps-pieces-info-box {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 25px;
    border-radius: 16px;
    margin-bottom: 30px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
    animation: slideInDown 0.5s ease-out;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.info-icon {
    font-size: 28px;
    flex-shrink: 0;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.info-content {
    flex: 1;
    line-height: 1.6;
}

.info-content strong {
    display: block;
    margin-bottom: 8px;
    font-size: 1.1em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Section principale */
.pieces-form-section {
    background: #ffffff;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.1);
    margin-bottom: 30px;
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pieces-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 3px solid #f0f0f0;
}

.pieces-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.pieces-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    animation: rotateIn 0.8s ease-out;
}

@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-180deg) scale(0);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

.pieces-header-left h3 {
    margin: 0;
    font-size: 1.5em;
    font-weight: 700;
    color: #333;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.pieces-date-badge {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.95em;
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
    animation: slideInRight 0.6s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Zone de sélection */
.pieces-selection-zone {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 25px;
    border-radius: 16px;
    margin-bottom: 30px;
    border: 2px dashed #667eea;
}

.pieces-form-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    align-items: end;
}

.pieces-form-group {
    display: flex;
    flex-direction: column;
}

.pieces-form-group label {
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    font-size: 1em;
    display: flex;
    align-items: center;
    gap: 5px;
}

.required-mark {
    color: #dc3545;
    font-size: 1.2em;
}

.select-wrapper {
    position: relative;
}

.modern-select {
    width: 100%;
    padding: 14px 40px 14px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 1em;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23667eea' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 12px;
}

.modern-select:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.modern-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.pieces-buttons-group {
    display: flex;
    gap: 12px;
}

.btn-pieces {
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-pieces:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.btn-pieces:active:not(:disabled) {
    transform: translateY(0);
}

.btn-camera {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-camera:disabled {
    background: #e0e0e0;
    color: #999;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-file {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.btn-file:disabled {
    background: #e0e0e0;
    color: #999;
    cursor: not-allowed;
    opacity: 0.6;
}

.file-input-hidden {
    display: none;
}

/* Tableau des pièces */
.pieces-table-wrapper {
    position: relative;
    min-height: 200px;
}

.pieces-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.pieces-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.pieces-table thead th {
    padding: 18px 15px;
    text-align: left;
    font-weight: 700;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pieces-table tbody tr {
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.3s ease;
}

.pieces-table tbody tr:hover {
    background: #f8f9ff;
    transform: scale(1.01);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
}

.pieces-table tbody td {
    padding: 15px;
    vertical-align: middle;
}

.pieces-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9em;
    box-shadow: 0 2px 8px rgba(245, 87, 108, 0.3);
}

.pieces-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: 1.1em;
    box-shadow: 0 2px 8px rgba(79, 172, 254, 0.3);
}

.pieces-images-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.piece-thumbnail {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.piece-thumbnail:hover {
    transform: scale(1.1) rotate(2deg);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    z-index: 10;
}

.piece-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.4);
}

.piece-thumbnail:hover .thumbnail-remove {
    opacity: 1;
}

.thumbnail-remove:hover {
    background: #c82333;
    transform: scale(1.2);
}

.btn-delete-row {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

.btn-delete-row:hover {
    background: linear-gradient(135deg, #ee5a6f 0%, #ff6b6b 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.4);
}

/* État vide */
.pieces-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: #999;
}

.pieces-empty-state.hidden {
    display: none;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.pieces-empty-state p {
    font-size: 1.2em;
    font-weight: 600;
    color: #666;
    margin: 10px 0;
}

.pieces-empty-state small {
    color: #999;
    font-size: 0.95em;
}

/* Actions du formulaire */
.pieces-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 30px;
    padding-top: 25px;
    border-top: 3px solid #f0f0f0;
}

.btn-reset {
    background: linear-gradient(135deg, #e0e0e0 0%, #c0c0c0 100%);
    color: #666;
}

.btn-reset:hover {
    background: linear-gradient(135deg, #c0c0c0 0%, #a0a0a0 100%);
}

.btn-save {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    padding: 14px 32px;
}

.btn-save:hover {
    background: linear-gradient(135deg, #45a049 0%, #4caf50 100%);
}

/* Message de succès */
.pieces-success-message {
    display: none;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    margin-top: 20px;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(76, 175, 80, 0.3);
    animation: slideInUp 0.5s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pieces-success-message.show {
    display: flex;
}

.success-icon {
    font-size: 24px;
    animation: checkmark 0.6s ease-out;
}

@keyframes checkmark {
    0% { transform: scale(0) rotate(-45deg); }
    50% { transform: scale(1.2) rotate(10deg); }
    100% { transform: scale(1) rotate(0); }
}

/* Modal Caméra */
.pieces-camera-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    animation: fadeIn 0.3s ease-out;
}

.pieces-camera-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: zoomIn 0.4s ease-out;
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.camera-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.4);
    z-index: 10;
}

.camera-close-btn:hover {
    background: #c82333;
    transform: rotate(90deg) scale(1.1);
}

.camera-modal-title {
    color: #667eea;
    margin: 0 0 25px 0;
    text-align: center;
    font-size: 1.8em;
    font-weight: 700;
}

.camera-video-container {
    position: relative;
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    margin-bottom: 25px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

#paps_cameraVideo {
    width: 100%;
    display: block;
    border-radius: 16px;
}

.camera-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.btn-camera-action {
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-capture {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-capture:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-switch {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.btn-switch:hover {
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.4);
}

.camera-info {
    text-align: center;
    padding: 12px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 10px;
    font-weight: 600;
    color: #667eea;
}

/* Modal Image */
.pieces-image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10001;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.pieces-image-modal.active {
    display: flex;
}

.image-modal-close {
    position: fixed;
    top: 30px;
    right: 40px;
    width: 50px;
    height: 50px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(220, 53, 69, 0.5);
    z-index: 10002;
}

.image-modal-close:hover {
    background: #c82333;
    transform: rotate(90deg) scale(1.1);
}

.image-modal-content {
    max-width: 90%;
    max-height: 90%;
    animation: zoomIn 0.4s ease-out;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

/* Responsive */
@media (max-width: 768px) {
    .pieces-form-row {
        grid-template-columns: 1fr;
    }
    
    .pieces-buttons-group {
        width: 100%;
        flex-direction: column;
    }
    
    .btn-pieces {
        width: 100%;
        justify-content: center;
    }
    
    .pieces-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .pieces-table {
        font-size: 0.85em;
    }
    
    .pieces-form-actions {
        flex-direction: column;
    }
    
    .btn-pieces {
        width: 100%;
    }
    
    .piece-thumbnail {
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 480px) {
    .paps-pieces-container {
        padding: 0 10px;
    }
    
    .pieces-form-section {
        padding: 20px 15px;
    }
    
    .pieces-header-left h3 {
        font-size: 1.2em;
    }
    
    .pieces-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}