/**
 * GÉNÉRATEUR DE PROMPTS ENRICHIS V2.0
 * Interface moderne avec onglets métier, preview, favoris, score qualité
 * Version: 2.1.1 - Fix conflit loading spinner
 */

/* ==========================================
   VIEW HEADER V2.0 - Onglets principaux
   ========================================== */

.view-header-main {
    margin-bottom: 16px;
}

.view-header-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    top: 2px;
}

.tab-btn:hover {
    color: #009FE3;
    background: #f0f9ff;
}

.tab-btn.active {
    color: #009FE3;
    border-bottom-color: #009FE3;
    font-weight: 600;
}

.tab-btn i {
    width: 18px;
    height: 18px;
}

/* ==========================================
   DATA QUALITY SCORE
   ========================================== */

.data-quality-score {
    margin-top: 16px;
    padding: 16px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 8px;
}

.quality-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.quality-title {
    font-weight: 600;
    font-size: 13px;
    color: #0c4a6e;
}

.quality-percentage {
    font-weight: 700;
    font-size: 18px;
    color: #0369a1;
}

.quality-modules {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quality-module {
    display: grid;
    grid-template-columns: 110px 1fr 50px;
    align-items: center;
    gap: 12px;
}

.quality-module-name {
    font-size: 12px;
    font-weight: 500;
    color: #334155;
}

.quality-progress-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.quality-progress-fill {
    height: 100%;
    background: #10b981;
    border-radius: 4px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.quality-module-percent {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    text-align: right;
}

/* ==========================================
   TEMPLATE CATEGORIES V2.0 - Tabs horizontaux modernes
   ========================================== */

.template-categories-v2 {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 0;
    border-bottom: 2px solid #e5e7eb;
}

.template-categories-v2::-webkit-scrollbar {
    height: 4px;
}

.template-categories-v2::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 2px;
}

.template-categories-v2::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

.category-filter-v2 {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-bottom: 3px solid transparent;
    background: transparent;
    border-radius: 0;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    white-space: nowrap;
    flex-shrink: 0;
    color: #6b7280;
}

.category-filter-v2:hover {
    color: #009FE3;
    background: #f0f9ff;
    border-bottom-color: #009FE3;
}

.category-filter-v2.active {
    background: transparent;
    color: #009FE3;
    border-bottom-color: #009FE3;
    font-weight: 700;
}

.category-filter-v2.active i {
    color: #009FE3;
}

.category-filter-v2 i {
    width: 16px;
    height: 16px;
    color: #6b7280;
    transition: color 0.2s;
}

.category-filter-v2.active i {
    color: #009FE3;
}

.category-count {
    font-size: 11px;
    padding: 2px 6px;
    background: #f3f4f6;
    border-radius: 10px;
    color: #6b7280;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

.category-filter-v2.active .category-count {
    background: #e0f2fe;
    color: #009FE3;
}

/* ==========================================
   TEMPLATE CARDS V2.0
   ========================================== */

.templates-list-v2 {
    max-height: 450px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;  /* Réduit de 12px → 10px pour plus de densité */
}

.templates-list-v2::-webkit-scrollbar {
    width: 6px;
}

.templates-list-v2::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 3px;
}

.templates-list-v2::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.templates-list-v2::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.template-card-v2 {
    padding: 12px;  /* Réduit de 14px → 12px pour plus de densité */
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    position: relative;
}

.template-card-v2:hover {
    border-color: #009FE3;
    box-shadow: 0 4px 12px rgba(0, 159, 227, 0.12);
    transform: translateY(-1px);
}

.template-card-v2.selected {
    border-color: #009FE3;
    background: linear-gradient(135deg, #f0f9ff 0%, #ffffff 100%);
    box-shadow: 0 4px 16px rgba(0, 159, 227, 0.2);
}

.template-card-header-v2 {
    display: flex;
    align-items: flex-start;
    gap: 10px;  /* Réduit de 12px → 10px */
    margin-bottom: 6px;  /* Réduit de 8px → 6px */
}

.template-icon-v2 {
    width: 38px;  /* Réduit de 42px → 38px */
    height: 38px;  /* Réduit de 42px → 38px */
    border-radius: 8px;  /* Réduit de 10px → 8px pour proportion */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.template-icon-v2 i {
    width: 20px;  /* Réduit de 22px → 20px */
    height: 20px;  /* Réduit de 22px → 20px */
}

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

.template-info-v2 h4 {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 4px 0;
}

.template-category-v2 {
    font-size: 12px;
    font-weight: 600;
}

.template-actions-v2 {
    display: flex;
    align-items: center;
    gap: 4px;
}

.favorite-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #e5e7eb;
    background: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.favorite-btn:hover {
    border-color: #fbbf24;
    background: #fefce8;
}

.favorite-btn i {
    width: 16px;
    height: 16px;
    color: #d1d5db;
    transition: color 0.2s;
}

.favorite-btn.active {
    border-color: #fbbf24;
    background: #fef3c7;
}

.favorite-btn.active i {
    color: #f59e0b;
    fill: #f59e0b;
}

.template-description-v2 {
    font-size: 13px;
    color: #6b7280;
    margin: 6px 0;  /* Réduit de 8px → 6px */
    line-height: 1.4;  /* Réduit de 1.5 → 1.4 pour plus de densité */
}

.template-footer-v2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    color: #9ca3af;
    margin-top: 6px;  /* Réduit de 8px → 6px */
}

.template-modules-v2 {
    display: flex;
    align-items: center;
    gap: 4px;
}

.template-modules-v2 i {
    width: 14px;
    height: 14px;
}

.selected-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: #009FE3;
    color: white;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.selected-badge i {
    width: 12px;
    height: 12px;
}

/* ==========================================
   NO RESULTS STATE
   ========================================== */

.no-results-sub {
    margin-top: 8px;
    font-size: 12px;
    color: #9ca3af;
}

/* ==========================================
   GENERATE BUTTON V2.0
   ========================================== */

.generate-btn-v2 {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, #009FE3, #0284c7);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0, 159, 227, 0.3);
}

.generate-btn-v2:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 159, 227, 0.4);
}

.generate-btn-v2:active:not(:disabled) {
    transform: translateY(0);
}

.generate-btn-v2:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    box-shadow: none;
}

.generate-btn-v2 i {
    width: 20px;
    height: 20px;
}

/* ==========================================
   PREVIEW PANEL V2.0
   ========================================== */

.preview-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.preview-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.preview-status.preview {
    background: #e0e7ff;
    color: #4338ca;
}

.preview-status.generated {
    background: #d1fae5;
    color: #065f46;
}

/* Template Preview (before generation) */
.template-preview-content {
    padding: 24px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.template-preview-header {
    margin-bottom: 16px;
}

.template-preview-meta h4 {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 8px 0;
}

.template-preview-category {
    font-size: 13px;
    font-weight: 600;
}

.template-preview-description {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.6;
    margin: 12px 0;
}

.template-preview-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 20px 0;
}

.template-preview-prompt {
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 13px;
    color: #374151;
    line-height: 1.7;
    background: #f9fafb;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 600px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom scrollbar for template preview content */
.template-preview-content::-webkit-scrollbar {
    width: 8px;
}

.template-preview-content::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.template-preview-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.template-preview-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.preview-placeholder-sub {
    margin-top: 8px;
    font-size: 13px;
    color: #9ca3af;
}

/* Copy Button V2.0 */
.copy-btn-v2 {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: white;
    border: 2px solid #009FE3;
    color: #009FE3;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn-v2:hover {
    background: #009FE3;
    color: white;
}

.copy-btn-v2.success {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

.copy-btn-v2 i {
    width: 16px;
    height: 16px;
}

/* ==========================================
   HISTORY V2.0
   ========================================== */

.prompt-history-v2 {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-list-v2 {
    max-height: 450px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.history-list-v2::-webkit-scrollbar {
    width: 6px;
}

.history-list-v2::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 3px;
}

.history-list-v2::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.history-item-v2 {
    padding: 14px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    transition: all 0.2s;
}

.history-item-v2:hover {
    border-color: #009FE3;
    box-shadow: 0 2px 8px rgba(0, 159, 227, 0.1);
}

.history-item-header-v2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-template-v2 {
    font-size: 13px;
    font-weight: 600;
}

.history-delete-btn-v2 {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #9ca3af;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.history-delete-btn-v2:hover {
    background: #fee2e2;
    color: #dc2626;
}

.history-delete-btn-v2 i {
    width: 14px;
    height: 14px;
}

.history-item-body-v2 {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.history-client-v2,
.history-date-v2 {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #6b7280;
}

.history-client-v2 i,
.history-date-v2 i {
    width: 13px;
    height: 13px;
}

.history-load-btn-v2 {
    width: 100%;
    padding: 8px 12px;
    background: #f0f9ff;
    border: 1px solid #009FE3;
    color: #009FE3;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.history-load-btn-v2:hover {
    background: #009FE3;
    color: white;
}

.history-load-btn-v2 i {
    width: 14px;
    height: 14px;
}

.clear-history-btn-v2 {
    width: 100%;
    padding: 12px 16px;
    background: white;
    border: 1px solid #ef4444;
    color: #ef4444;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.clear-history-btn-v2:hover {
    background: #fee2e2;
}

.clear-history-btn-v2 i {
    width: 16px;
    height: 16px;
}

.history-empty {
    text-align: center;
    padding: 60px 20px;
    color: #9ca3af;
}

.history-empty i {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
}

.history-empty p {
    margin: 0;
    font-size: 14px;
}

/* ==========================================
   RESPONSIVE - MOBILE & TABLETTE
   ========================================== */

@media (max-width: 1024px) {
    .prompt-generator-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .prompt-config-panel {
        order: 2;
    }

    .prompt-preview-panel {
        order: 1;
    }
}

@media (max-width: 768px) {
    .view-header-tabs {
        gap: 4px;
    }

    .tab-btn {
        padding: 10px 14px;
        font-size: 13px;
    }

    .tab-btn span {
        display: none;
    }

    /* Tabs toujours en horizontal, mais plus compact */
    .category-filter-v2 {
        padding: 8px 12px;  /* Padding réduit pour mobile */
        font-size: 12px;
    }

    .category-filter-v2 i {
        width: 16px;
        height: 16px;
    }

    .quality-module {
        grid-template-columns: 90px 1fr 45px;
        gap: 8px;
    }

    .quality-module-name {
        font-size: 11px;
    }

    .data-quality-score {
        padding: 12px;
    }

    .template-card-v2 {
        padding: 12px;
    }

    .templates-list-v2 {
        max-height: 350px;
    }

    .generate-btn-v2 {
        padding: 14px 20px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .prompt-generator-view {
        padding: 12px;
    }

    .view-header-main h1 {
        font-size: 20px;
    }

    .view-subtitle {
        font-size: 13px;
    }

    .config-section {
        padding: 14px;
    }

    /* Sur mobile, afficher seulement icônes + count */
    .category-filter-v2 span:not(.category-count) {
        display: none;  /* Cache le texte, garde seulement icône + count */
    }

    .category-filter-v2 {
        padding: 8px 10px;  /* Encore plus compact */
        font-size: 11px;
    }

    .category-filter-v2 i {
        width: 18px;
        height: 18px;
    }

    .template-card-v2 {
        padding: 10px;
    }

    .favorite-btn {
        width: 28px;
        height: 28px;
    }

    .quality-module {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .quality-module-name {
        grid-column: 1 / -1;
    }

    .quality-progress-bar {
        grid-column: 1 / -1;
    }

    .quality-module-percent {
        display: none;
    }
}

/* ==========================================
   LOADING ANIMATIONS
   ========================================== */

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.prompt-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #009FE3;
    border-radius: 50%;
    animation: prompt-spin 1s linear infinite;
}

@keyframes prompt-spin {
    to {
        transform: rotate(360deg);
    }
}
