/**
 * Styles frontend pour Formation Miassar
 * Version unifiée 2.0.0
 */

/* ============================================
   VARIABLES ET RÉINITIALISATION
   ============================================ */

:root {
    --dmt-primary-color: #fcb800;
    --dmt-secondary-color: #2c3e50;
    --dmt-success-color: #4CAF50;
    --dmt-warning-color: #FF9800;
    --dmt-danger-color: #F44336;
    --dmt-info-color: #2196F3;
    --dmt-light-color: #f8f9fa;
    --dmt-dark-color: #343a40;
    --dmt-border-color: #e0e0e0;
    --dmt-border-radius: 8px;
    --dmt-box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --dmt-transition: all 0.3s ease;
}

/* Réinitialisation */
.dmt-unified-training * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.dmt-unified-training {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
}

/* ============================================
   STRUCTURE PRINCIPALE
   ============================================ */

.dmt-training-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.dmt-training-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px;
    background: linear-gradient(135deg, var(--dmt-primary-color), #ff9800);
    border-radius: var(--dmt-border-radius);
    color: white;
}

.dmt-training-header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.dmt-training-header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* ============================================
   SECTION STATISTIQUES
   ============================================ */

.dmt-stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.dmt-stat-card {
    background: white;
    border-radius: var(--dmt-border-radius);
    padding: 25px;
    text-align: center;
    box-shadow: var(--dmt-box-shadow);
    transition: var(--dmt-transition);
    border: 1px solid var(--dmt-border-color);
}

.dmt-stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.dmt-stat-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 15px;
    background: var(--dmt-primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.dmt-stat-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.dmt-stat-label {
    font-size: 0.9rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dmt-stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--dmt-secondary-color);
}

/* ============================================
   BARRE DE PROGRESSION PRINCIPALE
   ============================================ */

.dmt-progress-section {
    margin-bottom: 40px;
    background: white;
    padding: 25px;
    border-radius: var(--dmt-border-radius);
    box-shadow: var(--dmt-box-shadow);
}

.dmt-progress-bar {
    width: 100%;
    height: 12px;
    background: #e9ecef;
    border-radius: 6px;
    overflow: hidden;
    margin-top: 10px;
}

.dmt-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--dmt-primary-color), #ff9800);
    border-radius: 6px;
    transition: width 0.8s ease;
}

/* ============================================
   FILTRES PAR CATÉGORIE
   ============================================ */

.dmt-filters-section {
    margin-bottom: 40px;
    background: white;
    padding: 25px;
    border-radius: var(--dmt-border-radius);
    box-shadow: var(--dmt-box-shadow);
}

.dmt-filters-section h3 {
    margin-bottom: 20px;
    color: var(--dmt-secondary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.dmt-filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.dmt-filter-btn {
    padding: 12px 20px;
    background: white;
    border: 2px solid var(--dmt-border-color);
    border-radius: 50px;
    cursor: pointer;
    transition: var(--dmt-transition);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.dmt-filter-btn:hover {
    border-color: var(--dmt-primary-color);
    color: var(--dmt-primary-color);
}

.dmt-filter-btn.active {
    background: var(--dmt-primary-color);
    border-color: var(--dmt-primary-color);
    color: white;
}

/* ============================================
   GRILLE DES MODULES
   ============================================ */

.dmt-modules-section {
    margin-bottom: 40px;
    background: white;
    padding: 25px;
    border-radius: var(--dmt-border-radius);
    box-shadow: var(--dmt-box-shadow);
}

.dmt-modules-section h3 {
    margin-bottom: 25px;
    color: var(--dmt-secondary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.dmt-modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
}

/* ============================================
   CARTE DE MODULE
   ============================================ */

.dmt-module-card {
    background: white;
    border: 1px solid var(--dmt-border-color);
    border-radius: var(--dmt-border-radius);
    overflow: hidden;
    transition: var(--dmt-transition);
    display: flex;
    flex-direction: column;
}

.dmt-module-card:hover {
    box-shadow: var(--dmt-box-shadow);
    border-color: var(--dmt-primary-color);
}

.dmt-module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid var(--dmt-border-color);
}

.dmt-module-category {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 20px;
    background: white;
    border: 1px solid var(--dmt-border-color);
}

.dmt-module-category.config { color: #2196F3; border-color: #2196F3; }
.dmt-module-category.products { color: #4CAF50; border-color: #4CAF50; }
.dmt-module-category.promotion { color: #FF9800; border-color: #FF9800; }
.dmt-module-category.communication { color: #9C27B0; border-color: #9C27B0; }
.dmt-module-category.orders { color: #795548; border-color: #795548; }
.dmt-module-category.finance { color: #607D8B; border-color: #607D8B; }
.dmt-module-category.support { color: #E91E63; border-color: #E91E63; }

.dmt-module-status {
    font-size: 0.8rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dmt-module-status.pending {
    background: #ffebee;
    color: #c62828;
}

.dmt-module-status.in-progress {
    background: #fff3e0;
    color: #ef6c00;
}

.dmt-module-status.completed {
    background: #e8f5e9;
    color: #2e7d32;
}

.dmt-module-body {
    padding: 20px;
    flex-grow: 1;
}

.dmt-module-body h4 {
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: var(--dmt-secondary-color);
}

.dmt-module-body p {
    color: #666;
    margin-bottom: 15px;
    line-height: 1.5;
}

.dmt-content-icons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.dmt-content-icons i {
    width: 30px;
    height: 30px;
    background: #f5f5f5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 0.9rem;
}

.dmt-module-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--dmt-border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafafa;
}

.dmt-module-progress {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dmt-module-progress .dmt-progress-bar {
    flex: 1;
    height: 6px;
    margin: 0;
}

.dmt-module-progress span {
    font-weight: bold;
    color: var(--dmt-secondary-color);
    min-width: 40px;
    text-align: right;
}

.dmt-module-btn {
    padding: 10px 20px;
    background: var(--dmt-primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--dmt-transition);
}

.dmt-module-btn:hover {
    background: #e0a800;
    transform: translateY(-2px);
}

/* ============================================
   MODAL D'ÉTUDE
   ============================================ */

.dmt-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
}

.dmt-modal-overlay.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.dmt-study-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    background: white;
    border-radius: var(--dmt-border-radius);
    z-index: 10000;
    display: none;
    overflow: hidden;
}

.dmt-study-modal.active {
    display: block;
    animation: modalSlideIn 0.3s ease;
}

.dmt-study-content {
    max-height: 90vh;
    overflow-y: auto;
}

.dmt-study-header {
    padding: 25px;
    background: var(--dmt-secondary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.dmt-study-header h2 {
    font-size: 1.5rem;
    margin: 0;
}

.dmt-close-study {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--dmt-transition);
}

.dmt-close-study:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dmt-study-body {
    padding: 30px;
}

.dmt-study-description {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--dmt-border-color);
}

.dmt-study-description p {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #555;
}

/* Sections de contenu */
.dmt-study-section {
    margin-bottom: 30px;
    padding: 25px;
    border: 1px solid var(--dmt-border-color);
    border-radius: var(--dmt-border-radius);
    transition: var(--dmt-transition);
}

.dmt-study-section.completed {
    border-color: var(--dmt-success-color);
    background: #f8fff8;
}

.dmt-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.dmt-section-header h3 {
    font-size: 1.2rem;
    color: var(--dmt-secondary-color);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.dmt-section-status {
    font-size: 0.85rem;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 20px;
    background: #e9ecef;
    color: #666;
}

.dmt-section-status.pending {
    background: #fff3cd;
    color: #856404;
}

.dmt-section-content {
    margin-bottom: 20px;
}

/* Contenu vidéo */
.dmt-video-container {
    margin-bottom: 20px;
}

.dmt-video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    border-radius: var(--dmt-border-radius);
    background: #000;
}

.dmt-video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.dmt-video-note {
    font-size: 0.9rem;
    color: #666;
    margin-top: 10px;
    font-style: italic;
}

/* Contenu PDF */
.dmt-pdf-preview {
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: var(--dmt-border-radius);
}

.dmt-pdf-icon {
    color: #F44336;
}

.dmt-pdf-info h4 {
    margin-bottom: 5px;
    color: var(--dmt-secondary-color);
}

.dmt-pdf-info p {
    margin-bottom: 15px;
    color: #666;
}

/* Contenu article */
.dmt-article-preview {
    background: #f8f9fa;
    padding: 20px;
    border-radius: var(--dmt-border-radius);
}

.dmt-article-preview p {
    margin-bottom: 15px;
    line-height: 1.6;
}

.dmt-read-more {
    text-align: center;
    margin-top: 15px;
}

/* Contenu quiz */
.dmt-quiz-info {
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 20px;
    background: #f0f7ff;
    border-radius: var(--dmt-border-radius);
    border-left: 4px solid var(--dmt-info-color);
}

.dmt-quiz-icon {
    color: var(--dmt-info-color);
}

.dmt-quiz-details h4 {
    margin-bottom: 10px;
    color: var(--dmt-secondary-color);
}

.dmt-quiz-features {
    list-style: none;
    padding: 0;
    margin: 10px 0 0;
}

.dmt-quiz-features li {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: #555;
}

.dmt-quiz-features i {
    color: var(--dmt-success-color);
}

.dmt-quiz-result {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: #e8f5e9;
    border-radius: var(--dmt-border-radius);
    color: #2e7d32;
}

/* Barre de progression dans la modal */
.dmt-study-progress {
    margin: 30px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: var(--dmt-border-radius);
}

.dmt-progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-weight: 500;
    color: var(--dmt-secondary-color);
}

/* Actions */
.dmt-section-actions {
    margin-top: 20px;
}

.dmt-study-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--dmt-border-color);
}

/* ============================================
   BOUTONS
   ============================================ */

.dmt-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--dmt-transition);
    text-decoration: none;
    font-size: 0.95rem;
}

.dmt-btn-primary {
    background: var(--dmt-primary-color);
    color: white;
}

.dmt-btn-primary:hover {
    background: #e0a800;
    color: white;
}

.dmt-btn-secondary {
    background: #6c757d;
    color: white;
}

.dmt-btn-secondary:hover {
    background: #5a6268;
    color: white;
}

.dmt-btn-outline {
    background: transparent;
    border: 2px solid var(--dmt-border-color);
    color: #555;
}

.dmt-btn-outline:hover {
    border-color: var(--dmt-primary-color);
    color: var(--dmt-primary-color);
}

.dmt-btn-success {
    background: var(--dmt-success-color);
    color: white;
}

.dmt-btn-block {
    width: 100%;
    justify-content: center;
}

/* ============================================
   ÉTATS ET MESSAGES
   ============================================ */

.dmt-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.dmt-loading i {
    font-size: 2rem;
    margin-bottom: 15px;
    display: block;
}

.dmt-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.dmt-empty i {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
    color: #ddd;
}

.dmt-error {
    text-align: center;
    padding: 40px;
    background: #ffebee;
    border-radius: var(--dmt-border-radius);
    color: #c62828;
}

.dmt-error i {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
}

.dmt-success {
    text-align: center;
    padding: 20px;
    background: #e8f5e9;
    border-radius: var(--dmt-border-radius);
    color: #2e7d32;
}

.dmt-success i {
    font-size: 2rem;
    margin-bottom: 10px;
    display: block;
}

/* Message de connexion */
.dmt-login-required {
    max-width: 400px;
    margin: 50px auto;
    text-align: center;
}

.dmt-login-box {
    background: white;
    padding: 40px;
    border-radius: var(--dmt-border-radius);
    box-shadow: var(--dmt-box-shadow);
}

.dmt-login-box i {
    color: var(--dmt-primary-color);
    margin-bottom: 20px;
}

.dmt-login-box h3 {
    margin-bottom: 15px;
    color: var(--dmt-secondary-color);
}

.dmt-login-btn {
    margin-top: 20px;
    display: inline-flex;
}

/* Message non-vendeur */
.dmt-not-vendor {
    max-width: 500px;
    margin: 50px auto;
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: var(--dmt-border-radius);
    box-shadow: var(--dmt-box-shadow);
}

.dmt-not-vendor i {
    color: #ff9800;
    font-size: 3rem;
    margin-bottom: 20px;
}

.dmt-not-vendor h3 {
    margin-bottom: 15px;
    color: var(--dmt-secondary-color);
}

/* ============================================
   NOTIFICATIONS
   ============================================ */

.dmt-badge-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: var(--dmt-border-radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 10001;
    animation: slideInRight 0.3s ease;
    max-width: 400px;
    border-left: 4px solid var(--dmt-primary-color);
}

.dmt-badge-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--dmt-primary-color), #ff9800);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.dmt-badge-content h4 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dmt-badge-content h3 {
    margin-bottom: 5px;
    color: var(--dmt-secondary-color);
}

.dmt-close-notification {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    align-self: flex-start;
}

.dmt-error-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #f44336;
    color: white;
    padding: 15px 20px;
    border-radius: var(--dmt-border-radius);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 10001;
    animation: slideInUp 0.3s ease;
    box-shadow: 0 5px 15px rgba(244, 67, 54, 0.3);
}

.dmt-close-error {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 992px) {
    .dmt-modules-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
    
    .dmt-study-modal {
        width: 95%;
    }
}

@media (max-width: 768px) {
    .dmt-training-header h1 {
        font-size: 2rem;
    }
    
    .dmt-training-header p {
        font-size: 1rem;
    }
    
    .dmt-stats-section {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dmt-modules-grid {
        grid-template-columns: 1fr;
    }
    
    .dmt-filter-buttons {
        overflow-x: auto;
        padding-bottom: 10px;
        flex-wrap: nowrap;
    }
    
    .dmt-filter-buttons.mobile-scroll {
        -webkit-overflow-scrolling: touch;
    }
    
    .dmt-filter-btn {
        white-space: nowrap;
    }
    
    .dmt-pdf-preview,
    .dmt-quiz-info {
        flex-direction: column;
        text-align: center;
    }
    
    .dmt-study-actions {
        flex-direction: column;
    }
    
    .dmt-badge-notification {
        left: 20px;
        right: 20px;
        max-width: none;
    }
}

@media (max-width: 576px) {
    .dmt-training-container {
        padding: 15px;
    }
    
    .dmt-stats-section {
        grid-template-columns: 1fr;
    }
    
    .dmt-module-card {
        margin-bottom: 15px;
    }
    
    .dmt-module-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .dmt-module-footer {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .dmt-module-progress {
        width: 100%;
    }
    
    .dmt-study-modal {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        top: 0;
        left: 0;
        transform: none;
    }
    
    .dmt-study-content {
        max-height: 100vh;
    }
}

/* ============================================
   THÈMES SPÉCIAUX
   ============================================ */

/* Mode sombre */
@media (prefers-color-scheme: dark) {
    .dmt-unified-training {
        color: #e0e0e0;
        background: #1a1a1a;
    }
    
    .dmt-training-container,
    .dmt-stat-card,
    .dmt-progress-section,
    .dmt-filters-section,
    .dmt-modules-section,
    .dmt-module-card,
    .dmt-study-section,
    .dmt-login-box,
    .dmt-not-vendor {
        background: #2d2d2d;
        color: #e0e0e0;
    }
    
    .dmt-training-header {
        background: linear-gradient(135deg, #333, #444);
    }
    
    .dmt-border-color {
        border-color: #444;
    }
    
    .dmt-stat-card,
    .dmt-progress-section,
    .dmt-filters-section,
    .dmt-modules-section,
    .dmt-module-card {
        border-color: #444;
    }
    
    .dmt-stat-value,
    .dmt-module-body h4,
    .dmt-section-header h3,
    .dmt-progress-label {
        color: #e0e0e0;
    }
    
    .dmt-module-body p,
    .dmt-stat-label,
    .dmt-video-note {
        color: #aaa;
    }
    
    .dmt-pdf-preview,
    .dmt-article-preview,
    .dmt-quiz-info,
    .dmt-study-progress {
        background: #333;
    }
    
    .dmt-content-icons i {
        background: #333;
        color: #aaa;
    }
    
    .dmt-module-footer {
        background: #252525;
    }
    
    .dmt-btn-outline {
        border-color: #555;
        color: #aaa;
    }
    
    .dmt-btn-outline:hover {
        border-color: var(--dmt-primary-color);
        color: var(--dmt-primary-color);
    }
}

/* Impression */
@media print {
    .dmt-training-header,
    .dmt-stats-section,
    .dmt-filters-section,
    .dmt-module-footer .dmt-module-btn {
        display: none;
    }
    
    .dmt-module-card {
        break-inside: avoid;
        border: 1px solid #000;
    }
}