/**
 * Habilec Features CSS
 * Styles pour les fonctionnalités avancées inspirées de Habilec 7
 */

/* ============================================
   VARIABLES
   ============================================ */
:root {
    --hab-modal-bg: rgba(0, 0, 0, 0.6);
    --hab-modal-radius: 16px;
    --hab-success: #10b981;
    --hab-warning: #f59e0b;
    --hab-danger: #ef4444;
    --hab-info: #3b82f6;
}

/* ============================================
   MODAL OVERLAY
   ============================================ */
.hab-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--hab-modal-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: habFadeIn 0.2s ease;
}

@keyframes habFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================
   MODAL
   ============================================ */
.hab-modal {
    background: white;
    border-radius: var(--hab-modal-radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: habSlideUp 0.3s ease;
}

.hab-modal-large {
    max-width: 800px;
}

@keyframes habSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hab-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, var(--hab-primary) 0%, var(--hab-primary-dark) 100%);
    border-radius: var(--hab-modal-radius) var(--hab-modal-radius) 0 0;
}

.hab-modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
}

.hab-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.5rem;
    line-height: 1;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hab-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.hab-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.hab-modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-radius: 0 0 var(--hab-modal-radius) var(--hab-modal-radius);
    border-top: 1px solid #e5e7eb;
}

/* ============================================
   FORMULAIRES
   ============================================ */
.hab-form-group {
    margin-bottom: 1.25rem;
}

.hab-form-group label {
    display: block;
    font-weight: 600;
    color: var(--hab-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.hab-form-group textarea {
    min-height: 60px;
    font-family: inherit;
}

.hab-form-group input[type="text"],
.hab-form-group input[type="email"],
.hab-form-group input[type="number"],
.hab-form-group textarea,
.hab-form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: white;
}

.hab-form-group input:focus,
.hab-form-group textarea:focus,
.hab-form-group select:focus {
    outline: none;
    border-color: var(--hab-primary);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.hab-form-group input::placeholder {
    color: #9ca3af;
}

.hab-form-row {
    display: flex;
    gap: 1rem;
}

.hab-form-row .hab-form-group {
    flex: 1;
}

/* ============================================
   BOUTONS
   ============================================ */
.hab-btn-primary {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--hab-primary) 0%, var(--hab-primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hab-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

.hab-btn-secondary {
    padding: 0.75rem 1.5rem;
    background: white;
    color: var(--hab-text-dark);
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hab-btn-secondary:hover {
    border-color: var(--hab-primary);
    color: #92400e;
}

.hab-btn-sm {
    padding: 0.5rem 0.75rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.hab-btn-sm:hover {
    background: #f5f5f5;
    transform: scale(1.05);
}

.hab-btn-danger {
    color: var(--hab-danger);
}

.hab-btn-danger:hover {
    background: #fef2f2;
    border-color: var(--hab-danger);
}

/* ============================================
   LOGO UPLOAD
   ============================================ */
.hab-logo-upload {
    width: 100%;
    height: 100px;
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fafafa;
    overflow: hidden;
}

.hab-logo-upload:hover {
    border-color: var(--hab-primary);
    background: #fffdf7;
}

.hab-logo-upload span {
    color: #9ca3af;
    font-size: 0.9rem;
}

.hab-logo-upload img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ============================================
   GRILLE D'HABILITATIONS
   ============================================ */
.hab-habilitations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 10px;
}

.hab-checkbox-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hab-checkbox-card:hover {
    border-color: var(--hab-primary);
}

.hab-checkbox-card input {
    display: none;
}

.hab-checkbox-card input:checked + .hab-checkbox-label {
    color: #92400e;
    font-weight: 700;
}

.hab-checkbox-card:has(input:checked) {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: var(--hab-primary);
}

.hab-checkbox-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--hab-text-dark);
}

.hab-checkbox-type {
    font-size: 0.65rem;
    color: #9ca3af;
    margin-top: 2px;
}

/* ============================================
   COUNT BADGES
   ============================================ */
.hab-count-badge {
    display: inline-block;
    background: var(--hab-primary, #f59e0b);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* ============================================
   SEARCH BAR
   ============================================ */
.hab-search-bar {
    position: relative;
    margin-bottom: 0.5rem;
}

.hab-search-bar input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.2rem;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    background: white;
}

.hab-search-bar input:focus {
    outline: none;
    border-color: var(--hab-primary, #f59e0b);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.hab-search-bar input::placeholder {
    color: #9ca3af;
}

.hab-search-icon {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    opacity: 0.4;
    pointer-events: none;
}

/* ============================================
   SELECTION DE CHAPITRES
   ============================================ */
.hab-chapters-select {
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fafafa;
}

.hab-chapter-category {
    border-bottom: 1px solid #e5e7eb;
}

.hab-chapter-category:last-child {
    border-bottom: none;
}

.hab-chapter-category-header {
    padding: 0.75rem 1rem;
    background: white;
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.hab-chapter-category-header:hover {
    background: #f8f9fa;
}

.hab-collapse-icon {
    font-size: 0.7rem;
    color: #9ca3af;
    transition: transform 0.2s ease;
}

.hab-cat-count {
    color: #9ca3af;
    font-weight: 400;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.hab-checkbox-all {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--hab-secondary);
}

.hab-checkbox-all input {
    width: 18px;
    height: 18px;
    accent-color: var(--hab-primary);
}

.hab-chapter-list {
    padding: 0.5rem 1rem 0.75rem;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
    overflow: hidden;
}

.hab-chapter-list.hab-collapsed {
    max-height: 0 !important;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

.hab-chapter-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.hab-chapter-item:hover {
    background: white;
}

.hab-chapter-item input {
    width: 16px;
    height: 16px;
    accent-color: var(--hab-primary);
    flex-shrink: 0;
}

.hab-chapter-item span {
    flex: 1;
    font-size: 0.9rem;
}

.hab-chapter-item small {
    color: #9ca3af;
    font-size: 0.75rem;
    white-space: nowrap;
}

.hab-chapter-item input:checked + span {
    font-weight: 600;
    color: #92400e;
}

/* ============================================
   SELECTION DE QUESTIONS
   ============================================ */
.hab-questions-select {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fafafa;
}

.hab-questions-header {
    padding: 0.75rem 1rem;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
}

.hab-questions-list {
    padding: 0.5rem;
}

.hab-question-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem;
    background: white;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.hab-question-item:hover {
    border-color: var(--hab-primary);
}

.hab-question-item input {
    margin-top: 3px;
    width: 16px;
    height: 16px;
    accent-color: var(--hab-primary);
}

.hab-question-text {
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.4;
}

.hab-question-item small {
    color: #9ca3af;
    font-size: 0.75rem;
}

/* ============================================
   LISTE DE QUIZ
   ============================================ */
.hab-quizzes-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.hab-quiz-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.hab-quiz-card:hover {
    border-color: var(--hab-primary);
    box-shadow: 0 2px 10px rgba(245, 158, 11, 0.15);
}

.hab-quiz-info h4 {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
    color: var(--hab-secondary);
}

.hab-quiz-info p {
    margin: 0;
    font-size: 0.85rem;
    color: #6b7280;
}

.hab-quiz-info small {
    color: #92400e;
    font-size: 0.75rem;
}

.hab-quiz-actions {
    display: flex;
    gap: 0.5rem;
}

/* ============================================
   NOTIFICATIONS
   ============================================ */
.hab-notification {
    position: fixed;
    bottom: 100px;
    right: 20px;
    padding: 1rem 1.5rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 10001;
    animation: habSlideInRight 0.3s ease;
    border-left: 4px solid var(--hab-info);
}

@keyframes habSlideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.hab-notification-success {
    border-left-color: var(--hab-success);
}

.hab-notification-error {
    border-left-color: var(--hab-danger);
}

.hab-notification-warning {
    border-left-color: var(--hab-warning);
}

.hab-notification span {
    font-size: 0.95rem;
    color: var(--hab-text-dark);
}

.hab-notification button {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.hab-notification button:hover {
    color: var(--hab-text-dark);
}

/* ============================================
   ÉTATS SPÉCIAUX
   ============================================ */
.hab-loading {
    text-align: center;
    padding: 2rem;
    color: #9ca3af;
}

.hab-info {
    text-align: center;
    padding: 1.5rem;
    color: #6b7280;
    font-size: 0.9rem;
}

.hab-error {
    text-align: center;
    padding: 1.5rem;
    color: var(--hab-danger);
}

.hab-empty {
    text-align: center;
    padding: 2rem;
    color: #9ca3af;
}

.hab-empty a {
    color: #92400e;
    text-decoration: none;
    font-weight: 600;
}

.hab-empty a:hover {
    text-decoration: underline;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .hab-modal {
        width: 95%;
        max-height: 95vh;
    }

    .hab-modal-large {
        max-width: 100%;
    }

    .hab-form-row {
        flex-direction: column;
    }

    .hab-habilitations-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    }

    .hab-notification {
        left: 20px;
        right: 20px;
        bottom: 80px;
    }
}

@media (max-width: 480px) {
    .hab-modal-header {
        padding: 1rem;
    }

    .hab-modal-body {
        padding: 1rem;
    }

    .hab-modal-footer {
        flex-direction: column;
    }

    .hab-modal-footer button {
        width: 100%;
    }
}
