/**
 * Styles pour l'import de classeurs depuis photos
 */

/* Modal principal - Style Glassmorphism moderne */
.binder-import-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.import-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.import-modal-content {
    position: relative;
    background: rgba(10, 14, 39, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    color: #e0e6ed;
}

.import-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.import-modal-header h3 {
    margin: 0;
    color: #fff;
    font-size: 1.4rem;
    font-weight: 700;
}

.import-modal-header .modal-close-btn {
    color: rgba(255, 255, 255, 0.8);
    font-size: 28px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.import-modal-header .modal-close-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

.import-modal-body {
    padding: 25px;
    color: #e0e6ed;
}

/* Steps */
.import-step {
    animation: fadeIn 0.3s ease;
}

.import-step.hidden {
    display: none;
}

.import-step h4 {
    color: #fff;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid transparent;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    font-size: 1.1rem;
}

.import-step h4::after {
    content: '';
    display: block;
    margin-top: 10px;
    height: 2px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 1px;
}

/* Grid selector */
.grid-selector {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.grid-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: rgba(255, 255, 255, 0.7);
    min-width: 100px;
}

.grid-option:hover {
    border-color: rgba(102, 126, 234, 0.5);
    background: rgba(102, 126, 234, 0.15);
    color: #fff;
}

.grid-option.active {
    border-color: rgba(102, 126, 234, 0.8);
    background: rgba(102, 126, 234, 0.2);
    color: #fff;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.grid-preview {
    display: grid;
    gap: 2px;
    margin-bottom: 8px;
    width: 40px;
    height: 50px;
}

.grid-preview.grid-3x3 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.grid-preview.grid-4x3 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.grid-preview.grid-3x4 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

.grid-preview::before {
    content: '';
    display: block;
}

.grid-preview > * {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 2px;
}

.grid-preview.grid-auto {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 5px;
}

/* Upload zone */
.upload-zone {
    border: 3px dashed rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 50px 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.03);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: rgba(102, 126, 234, 0.6);
    background: rgba(102, 126, 234, 0.1);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.upload-zone p {
    margin: 5px 0;
    color: #fff;
}

.upload-zone small {
    color: rgba(255, 255, 255, 0.5);
}

/* Pages queue */
.pages-queue {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 20px;
    min-height: 100px;
}

.queue-item {
    position: relative;
    width: 120px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.queue-item:hover {
    border-color: rgba(102, 126, 234, 0.4);
}

.queue-item img {
    width: 100%;
    height: 160px;
    object-fit: cover;
}

.queue-item .page-number {
    display: block;
    text-align: center;
    padding: 5px;
    background: rgba(0, 0, 0, 0.3);
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.queue-item .remove-page {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: transform 0.2s ease;
}

.queue-item .remove-page:hover {
    transform: scale(1.1);
}

/* Step actions */
.step-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.step-actions .btn {
    border-radius: 12px;
    font-weight: 600;
    padding: 10px 24px;
    transition: all 0.3s ease;
}

.step-actions .btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    color: #fff;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.step-actions .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.step-actions .btn-secondary,
.step-actions .btn-outline-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

.step-actions .btn-secondary:hover,
.step-actions .btn-outline-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Validation grid */
.validation-container {
    margin-bottom: 20px;
}

.page-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.page-nav span {
    color: #fff;
    font-weight: 500;
}

.page-nav .btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 8px;
}

.page-nav .btn:hover {
    background: rgba(102, 126, 234, 0.2);
}

.validation-grid {
    display: grid;
    gap: 15px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.validation-slot {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border: 2px solid rgba(255, 255, 255, 0.08);
    transition: all 0.2s ease;
}

.validation-slot.has-card:hover {
    border-color: rgba(102, 126, 234, 0.6);
    background: rgba(102, 126, 234, 0.1);
}

.validation-slot.empty {
    opacity: 0.5;
    min-height: 150px;
    justify-content: center;
    color: rgba(255, 255, 255, 0.5);
}

.slot-preview {
    position: relative;
    width: 80px;
    height: 112px;
    border-radius: 5px;
    overflow: hidden;
}

.slot-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.validated-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #22c55e;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.slot-match {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    min-width: 120px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: border-color 0.2s ease;
}

.slot-match img {
    width: 40px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
}

/* Validated state - ne pas override les couleurs de confiance */
.slot-match.validated {
    /* Le fond et bordure sont gérés par les classes confidence-* */
}

/* Backgrounds basés sur la confiance */
.slot-match.confidence-high {
    background: rgba(34, 197, 94, 0.15);
}

.slot-match.confidence-medium {
    background: rgba(245, 158, 11, 0.15);
}

.slot-match.confidence-low {
    background: rgba(239, 68, 68, 0.15);
}

/* Match info container - nom + badge en colonne */
.match-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.match-name {
    font-size: 11px;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slot-actions {
    margin-top: 8px;
    opacity: 1;
    visibility: visible;
}

.btn-xs {
    padding: 5px 12px;
    font-size: 11px;
    background: rgba(102, 126, 234, 0.3);
    border: 1px solid rgba(102, 126, 234, 0.5);
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-xs:hover {
    background: rgba(102, 126, 234, 0.5);
    border-color: rgba(102, 126, 234, 0.8);
}

/* Text "À valider" plus visible */
.no-match {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 500;
    padding: 8px 0;
    text-align: center;
    width: 100%;
}

/* Hauteur uniforme pour toutes les slot-match */
.slot-match {
    min-height: 66px;
    justify-content: center;
}

/* Validation stats */
.validation-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-validated,
.stat-pending {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.stat-validated {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.stat-validated::before {
    content: '✓';
    font-size: 0.8rem;
}

.stat-pending {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.stat-pending::before {
    content: '○';
    font-size: 0.8rem;
}

/* Progress bar */
.import-progress {
    padding: 20px 25px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.import-progress.hidden {
    display: none;
}

.progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    margin-top: 10px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

/* Success state */
.import-success {
    text-align: center;
    padding: 40px 20px;
}

.success-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.import-success h4 {
    color: #22c55e;
    border: none;
}

.success-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
}

/* Candidates modal - Style moderne */
.candidates-select-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
    justify-content: center;
    align-items: center;
}

.candidates-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.candidates-content {
    position: relative;
    background: rgba(10, 14, 39, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    padding: 25px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.candidates-content h4 {
    margin: 0 0 20px;
    color: #fff;
    text-align: center;
    font-weight: 600;
}

.crop-preview {
    text-align: center;
    margin-bottom: 20px;
}

.crop-preview img {
    max-width: 150px;
    border-radius: 8px;
    border: 2px solid var(--border-color, #444);
}

.candidates-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.candidate-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.candidate-item:hover {
    border-color: rgba(99, 102, 241, 0.6);
    background: rgba(99, 102, 241, 0.1);
}

.candidate-item.selected {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
}

.candidate-item img {
    width: 60px;
    height: 84px;
    object-fit: cover;
    border-radius: 5px;
}

.candidate-info {
    flex: 1;
}

.candidate-name {
    color: #fff;
    font-weight: 600;
    margin-bottom: 3px;
}

.candidate-series {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
}

.candidate-confidence {
    font-size: 12px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Confidence level colors */
.confidence-high,
.candidate-confidence.confidence-high {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
}

.confidence-medium,
.candidate-confidence.confidence-medium {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.15);
}

.confidence-low,
.candidate-confidence.confidence-low {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}

/* Confidence badge in slot - Style pill moderne */
.slot-match .confidence-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
    align-self: flex-start;
}

.slot-match .confidence-badge.confidence-high {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4);
}

.slot-match .confidence-badge.confidence-medium {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.slot-match .confidence-badge.confidence-low {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* Border colors based on confidence - haute priorité */
.slot-match.confidence-high,
.slot-match.validated.confidence-high {
    border-color: #22c55e !important;
}

.slot-match.confidence-medium,
.slot-match.validated.confidence-medium {
    border-color: #f59e0b !important;
}

.slot-match.confidence-low,
.slot-match.validated.confidence-low {
    border-color: #ef4444 !important;
}

.candidate-item.manual {
    justify-content: center;
    color: var(--text-secondary, #aaa);
}

.manual-icon {
    font-size: 24px;
}

.candidates-actions {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.candidates-actions .btn-cancel {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 10px 25px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.candidates-actions .btn-cancel:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Manual search section */
.manual-search-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.manual-search-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

.manual-search-header .manual-icon {
    font-size: 16px;
}

.manual-search-input {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.manual-search-input input {
    flex: 1;
    padding: 10px 14px;
    background: rgba(10, 14, 39, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
}

.manual-search-input input:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.6);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.manual-search-input input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.manual-search-input .btn-search {
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.manual-search-input .btn-search:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.manual-search-results {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-result-item:hover {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.5);
}

.search-result-item img {
    width: 40px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
}

.result-info {
    flex: 1;
    min-width: 0;
}

.result-name {
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-series {
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    margin-top: 2px;
}

.search-loading,
.no-results,
.search-error {
    text-align: center;
    padding: 15px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
}

.search-error {
    color: #f87171;
}

/* Form group - Style moderne */
.binder-import-modal .form-group {
    margin-bottom: 20px;
}

.binder-import-modal .form-group label {
    display: block;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.binder-import-modal .form-group input[type="text"],
.binder-import-modal .form-control {
    width: 100%;
    padding: 12px 15px;
    background: rgba(10, 14, 39, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: #fff;
    font-size: 14px;
    transition: all 0.3s ease;
}

.binder-import-modal .form-group input[type="text"]:focus,
.binder-import-modal .form-control:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.6);
    background: rgba(10, 14, 39, 0.95);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.binder-import-modal .form-group input[type="text"]::placeholder,
.binder-import-modal .form-control::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.binder-import-modal .form-group input[type="checkbox"] {
    margin-right: 8px;
    accent-color: #667eea;
}

.binder-import-modal .form-group .form-check-label {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    text-transform: none;
    font-size: 0.9rem;
    letter-spacing: normal;
}

/* Animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
    .import-modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .grid-selector {
        justify-content: center;
    }

    .validation-grid {
        padding: 10px;
        gap: 10px;
    }

    .slot-preview {
        width: 60px;
        height: 84px;
    }

    .slot-match {
        min-width: auto;
        padding: 5px;
    }

    .slot-match img {
        width: 30px;
        height: 42px;
    }
}
