/* writer_ui.css - Boutons, toolbar, modals, formulaires */
/* Version 1.1 - Nettoyé : doublons supprimés */

/* ==================== BOUTONS SECONDAIRES ==================== */

.btn-secondary {
    background-color: #6c757d;
    border-color: #5a6eb8;
}

.btn-secondary:hover {
    background-color: #5a6eb8;
    border-color: #495a6c;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* ==================== MODIFY MENU ==================== */

.modify-menu {
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    min-width: 300px;
    max-width: 400px;
    font-family: Arial, sans-serif;
    max-height: 70vh;
    overflow-y: auto;
}

.modify-menu-header {
    background: #f5f5f5;
    padding: 10px 15px;
    border-bottom: 1px solid #ddd;
    border-radius: 8px 8px 0 0;
}

.modify-menu-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.modify-menu-actions {
    padding: 5px 0;
}

.modify-menu-action {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
    border-bottom: 1px solid #eee;
}

.modify-menu-action:hover {
    background-color: #f0f0f0;
}

.action-icon {
    margin-right: 10px;
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.modify-menu-category {
    background: #f9f9f9;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    border-radius: 8px 8px 0 0;
}

.modify-menu-category h3 {
    margin: 0;
    font-size: 14px;
    color: #333;
}

/* ==================== MODIFY MENU - VERSIONS ==================== */

.modify-menu-version {
    padding: 5px 0;
    border-bottom: 1px solid #eee;
}

.modify-menu-version h3 {
    margin: 0;
    font-size: 14px;
    color: #333;
}

.modify-menu-version-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
    border-bottom: 1px solid #eee;
}

.modify-menu-version-item:hover {
    background-color: #f0f0f0;
}

.modify-version-icon {
    margin-right: 10px;
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.modify-version-label {
    font-size: 14px;
    margin-left: 5px;
    text-align: left;
    flex: 1;
}

/* ==================== MODIFY MENU - ADVANCED ==================== */

.modify-menu-advanced {
    padding: 5px 0;
    display: none;
    border-bottom: 1px solid #eee;
}

.modify-menu-advanced .action-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
    border-bottom: 1px solid #eee;
}

.modify-menu-advanced .action-item:hover {
    background-color: #f0f0f0;
}

.modify-menu-advanced .action-icon {
    margin-right: 10px;
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.modify-menu-advanced .action-label {
    font-size: 14px;
    margin-left: 5px;
    text-align: left;
    flex: 1;
}

.modify-menu-advanced .action:hover .action-label {
    color: #007bff;
}

/* ==================== MODIFY MENU - BOUTON FERMETURE ==================== */

.modify-menu-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modify-menu-close-btn:hover {
    color: #333;
}

/* ==================== CORRECTION MENU ==================== */

.correction-menu {
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 280px;
    max-width: 350px;
    padding: 0;
    font-family: Arial, sans-serif;
    max-height: 70vh;
    overflow-y: auto;
}

.correction-menu-category {
    background: #f5f5f5;
    padding: 10px 15px;
    border-bottom: 1px solid #ddd;
    border-radius: 8px 8px 0 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.correction-menu-category h3 {
    margin: 0;
    font-size: 14px;
    color: #333;
    font-weight: 600;
}

.correction-menu-actions {
    padding: 5px 0;
}

.correction-menu-action {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
    border-bottom: 1px solid #eee;
}

.correction-menu-action:last-child {
    border-bottom: none;
}

.correction-menu-action:hover {
    background-color: #f0f0f0;
}

/* ==================== SÉLECTEURS DE STYLES (TITRES ET POLICES) ==================== */

.heading-select,
.font-select {
    padding: 0.4rem 0.8rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 140px;
}

.heading-select:hover,
.font-select:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.heading-select:focus,
.font-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

.font-select {
    min-width: 160px;
}

/* ==================== BOUTONS ==================== */

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    font-weight: 500;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-tool {
    padding: 0.5rem 1rem;
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    color: #333;
}

.btn-tool:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.btn-tool.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-link {
    color: #007bff;
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    font-size: inherit;
}

.btn-link:hover {
    color: #0056b3;
}

/* ==================== MENUS DÉROULANTS (STYLES / THÈMES) ==================== */

.style-selector,
.theme-selector {
    position: relative;
}

.style-menu,
.theme-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    min-width: 200px;
    z-index: 1000;
    margin-top: 0.25rem;
    max-height: 400px;
    overflow-y: auto;
}

.style-menu.show,
.theme-menu.show {
    display: block;
}

.theme-menu button {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: white;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
    color: #333;
    font-size: 0.9rem;
}

.theme-menu button:hover {
    background: var(--light);
}

.style-menu {
    min-width: 350px;
    max-width: 400px;
}

.style-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

.style-option:last-child {
    border-bottom: none;
}

.style-option:hover {
    background: #f8f9fa;
}

.style-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.style-info {
    flex: 1;
}

.style-info strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: #333;
}

.style-info small {
    display: block;
    font-size: 0.85rem;
    color: #666;
    line-height: 1.4;
}

/* ==================== MODALS ==================== */

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    overflow: auto;
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow: auto;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--light);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--dark);
}

.close {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    color: #999;
    cursor: pointer;
    border: none;
    background: none;
    transition: color 0.2s;
}

.close:hover {
    color: #333;
}

.modal-body {
    padding: 1.5rem;
}

/* ==================== FORMULAIRES ==================== */

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

.form-group select {
    cursor: pointer;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
}

.form-group small {
    display: block;
    margin-top: 0.5rem;
    color: #666;
    font-size: 0.875rem;
}

.form-group small a {
    color: var(--primary-color);
}

.max-length-info {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.25rem;
}

.tone-description {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.25rem;
    font-style: italic;
}

/* ==================== BARRE DE PROGRESSION ==================== */

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-hover));
    animation: progress 2s ease-in-out infinite;
}

@keyframes progress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* ==================== DIVERS ==================== */

#fileNameDisplay {
    background: rgba(255,255,255,0.1);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.95rem;
}

/* Scrollbars personnalisées */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Info box */
.info-box {
    background: #f0f8ff;
    border: 1px solid #007bff;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

/* ==================== HYBRID MODIFY MENU ==================== */

.hybrid-modify-menu {
    position: absolute;
    z-index: 1000;
    background-color: #ffffff;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0.5rem;
    min-width: 280px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
}

.hybrid-menu-header h3 {
    margin: 0 0 0.5rem 0;
    padding: 0.25rem 0.5rem;
    font-size: 16px;
    color: #333;
    border-bottom: 1px solid #eee;
}

.hybrid-menu-section h4 {
    margin: 0.75rem 0 0.5rem 0;
    padding: 0 0.5rem;
    font-size: 13px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hybrid-menu-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0 0.5rem 0.5rem 0.5rem;
}

.hybrid-menu-btn {
    background-color: #f7f7f7;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 35px;
    height: 35px;
}

.hybrid-menu-btn:hover {
    background-color: #e9e9e9;
    border-color: #bbb;
    transform: translateY(-1px);
}

.hybrid-menu-btn-ia {
    background-color: #e3f2fd;
    border-color: #bbdefb;
    color: #1976d2;
    flex-grow: 1;
    justify-content: flex-start;
}

.hybrid-menu-btn-ia:hover {
    background-color: #bbdefb;
    border-color: #90caf9;
}

/* ==================== ANIMATION DE CHARGEMENT IA ==================== */

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ai-progress {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    background-color: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
    min-width: 300px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.ai-progress-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.ai-progress-icon {
    font-size: 2rem;
    color: #007bff;
    animation: spin 1.5s linear infinite;
}

.ai-progress-text {
    font-size: 1rem;
    color: #333;
    font-weight: 500;
}

.ai-progress-details {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.5rem;
    font-style: italic;
}

.ai-progress-step {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.ai-progress-step.active {
    opacity: 1;
    color: #007bff;
    font-weight: bold;
}

/* ==================== MENU DÉROULANT IA ==================== */

.ai-menu-container {
    position: relative;
    display: inline-block;
}

.ai-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.25rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 280px;
    max-width: 320px;
    z-index: 1000;
    overflow: hidden;
}

.ai-dropdown-menu.hidden {
    display: none;
}

.ai-menu-section {
    padding: 0.5rem 0;
}

.ai-menu-section-title {
    padding: 0.5rem 1rem;
    font-size: 0.75em;
    font-weight: bold;
    color: #666;
    text-transform: uppercase;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
}

.ai-menu-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.95em;
    color: #333;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-menu-item:hover {
    background: #f0f8ff;
    color: #007bff;
}

.ai-menu-item:active {
    background: #e0f0ff;
}

.ai-menu-separator {
    height: 1px;
    background: #e0e0e0;
    margin: 0.25rem 0;
}

/* ==================== SELECTEUR DE TYPE DE DOCUMENT IA (accordéon) ==================== */

.tp-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.tp-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #111;
    margin: 0 0 4px;
}

.tp-subtitle {
    font-size: .85rem;
    color: #888;
    margin: 0;
}

.tp-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.tp-btn-alt {
    padding: 8px 18px;
    background: #f8f9fa;
    border: 1.5px solid #d1d5db;
    border-radius: 20px;
    cursor: pointer;
    font-size: .88rem;
    font-weight: 500;
}

.tp-close {
    width: 34px;
    height: 34px;
    background: none;
    border: 1.5px solid #d1d5db;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.3rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tp-cat {
    border-bottom: 1px solid #f0f0f0;
}

.tp-cat-head {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 12px 4px;
    text-align: left;
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #6b7280;
}

.tp-cat-head:hover {
    color: #374151;
}

.tp-cat-label {
    flex: 1;
    min-width: 0;
}

.tp-cat-count {
    font-size: .72rem;
    font-weight: 600;
    color: #9ca3af;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 1px 8px;
}

.tp-chevron {
    display: inline-block;
    transition: transform .18s ease;
    color: #9ca3af;
    font-size: 1rem;
    flex-shrink: 0;
}

.tp-cat-head.tp-open .tp-chevron {
    transform: rotate(90deg);
}

.tp-chips {
    display: none;
    flex-wrap: wrap;
    gap: 7px;
    padding: 2px 4px 16px;
}

.tp-chips.tp-open {
    display: flex;
}

.tp-chip {
    padding: 6px 14px;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 20px;
    cursor: pointer;
    font-size: .85rem;
    color: #374151;
    white-space: nowrap;
}

.tp-chip:hover {
    border-color: #007bff;
    color: #007bff;
}
