/**
 * Digital Library Manager - Tableau de bord Auteur
 */

/* Conteneur principal */
.dlm-author-dashboard {
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* En-tête */
.dlm-dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #009E49;
}

.dlm-dashboard-header h1 {
    margin: 0;
    font-size: 1.8rem;
    color: #009E49;
}

.dlm-dashboard-welcome {
    margin: 0;
    color: #666;
    font-size: 1rem;
}

/* Navigation par onglets */
.dlm-dashboard-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.dlm-dashboard-tabs a {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 15px;
    background: #f0f7f2;
    color: #009E49;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s;
}

.dlm-dashboard-tabs a:hover {
    background: #e0efe5;
    transform: translateY(-2px);
}

.dlm-dashboard-tabs a.active {
    background: #009E49;
    color: white;
}

.dlm-dashboard-tabs a.active .dashicons {
    color: #FCD116;
}

/* Section d'information */
.dlm-author-notice {
    margin-bottom: 25px;
}

.dlm-notice-box {
    background: #e8f4fd;
    border-left: 4px solid #009E49;
    border-radius: 4px;
    padding: 15px;
}

.dlm-notice-box h4 {
    margin: 0 0 10px 0;
    color: #009E49;
    display: flex;
    align-items: center;
    gap: 5px;
}

.dlm-status-legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.dlm-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.dlm-status-badge {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.dlm-status-badge.approved { background: #4ab866; }
.dlm-status-badge.suspended { background: #dba617; }
.dlm-status-badge.pending { background: #3858e9; }
.dlm-status-badge.rejected { background: #d63638; }

/* En-tête d'onglet avec filtre */
.dlm-tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.dlm-tab-header h2 {
    margin: 0;
    font-size: 1.4rem;
    color: #333;
}

.dlm-book-filters {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dlm-filter-select {
    padding: 8px 12px;
    border: 1px solid #009E49;
    border-radius: 4px;
    background: white;
    color: #009E49;
    font-weight: 500;
}

/* ===== TABLEAU RESPONSIVE AMÉLIORÉ ===== */

/* Conteneur du tableau avec défilement horizontal */
.dlm-table-wrapper {
    overflow-x: auto;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    -webkit-overflow-scrolling: touch;
}

/* Style de base du tableau */
.dlm-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    table-layout: fixed; /* ← CRUCIAL : Fixe la largeur des colonnes */
    min-width: 800px; /* Largeur minimale pour éviter l'écrasement */
}

/* En-têtes du tableau */
.dlm-table thead tr {
    background: #3858e9;
    color: white;
}

.dlm-table th {
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}

/* Définition des largeurs de colonnes en pourcentages */
.dlm-table th:nth-child(1), /* Titre */
.dlm-table td:nth-child(1) {
    width: 30%; /* Le titre prend 30% */
}

.dlm-table th:nth-child(2), /* Prix */
.dlm-table td:nth-child(2) {
    width: 10%;
    text-align: center;
}

.dlm-table th:nth-child(3), /* Statut */
.dlm-table td:nth-child(3) {
    width: 15%;
    text-align: center;
}

.dlm-table th:nth-child(4), /* Date */
.dlm-table td:nth-child(4) {
    width: 15%;
    text-align: center;
}

.dlm-table th:nth-child(5), /* Actions */
.dlm-table td:nth-child(5) {
    width: 30%; /* Actions prennent aussi 30% */
    text-align: right;
}

/* Contenu des cellules */
.dlm-table td {
    padding: 12px;
    border-bottom: 1px solid #e0e4e8;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Titre du livre - gestion du texte long */
.dlm-table .dlm-book-title {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-weight: 500;
    max-width: 100%;
}

/* Prix - centrage */
.dlm-table .dlm-book-price {
    font-weight: 600;
    color: #2e7d32;
    text-align: center;
    white-space: nowrap;
}

/* Date - centrage */
.dlm-table td:nth-child(4) {
    text-align: center;
    white-space: nowrap;
}

/* Ligne au survol */
.dlm-table tbody tr:hover {
    background: #f8f9fa;
}

/* ===== BOUTONS D'ACTION AMÉLIORÉS ===== */
.dlm-book-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.dlm-book-actions .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 4px;
    background: white;
    border: 1px solid #dcdcde;
    color: #3858e9;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.dlm-book-actions .button:hover {
    background: #f0f6ff;
    border-color: #3858e9;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.dlm-book-actions .button .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
    line-height: 1.2;
}

/* Bouton avec texte */
.dlm-book-actions .button.has-text {
    padding: 0 15px;
    gap: 5px;
}

/* ===== VERSION DESKTOP (≥ 1024px) ===== */
@media (min-width: 1024px) {
    .dlm-table {
        min-width: 100%; /* Prend toute la largeur */
        table-layout: fixed;
    }
    
    .dlm-table th,
    .dlm-table td {
        padding: 15px 12px;
    }
    
    /* Ajustement fin des largeurs pour desktop */
    .dlm-table th:nth-child(1), .dlm-table td:nth-child(1) { width: 30%; }
    .dlm-table th:nth-child(2), .dlm-table td:nth-child(2) { width: 10%; }
    .dlm-table th:nth-child(3), .dlm-table td:nth-child(3) { width: 15%; }
    .dlm-table th:nth-child(4), .dlm-table td:nth-child(4) { width: 15%; }
    .dlm-table th:nth-child(5), .dlm-table td:nth-child(5) { width: 30%; }
}

/* ===== VERSION TABLETTE (768px - 1023px) ===== */
@media (min-width: 768px) and (max-width: 1023px) {
    .dlm-table {
        min-width: 100%;
        table-layout: fixed;
    }
    
    /* Ajustement pour tablettes */
    .dlm-table th:nth-child(1), .dlm-table td:nth-child(1) { width: 35%; }
    .dlm-table th:nth-child(2), .dlm-table td:nth-child(2) { width: 12%; }
    .dlm-table th:nth-child(3), .dlm-table td:nth-child(3) { width: 18%; }
    .dlm-table th:nth-child(4), .dlm-table td:nth-child(4) { width: 15%; }
    .dlm-table th:nth-child(5), .dlm-table td:nth-child(5) { width: 20%; }
    
    .dlm-table th,
    .dlm-table td {
        padding: 12px 8px;
        font-size: 13px;
    }
    
    .dlm-book-actions {
        gap: 4px;
    }
    
    .dlm-book-actions .button {
        min-width: 32px;
        height: 32px;
    }
}

/* ===== VERSION MOBILE (< 768px) - TOUJOURS TABLEAU AVEC SCROLL ===== */
@media (max-width: 767px) {
    /* On garde le tableau, on ne le transforme pas en cartes */
    .dlm-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 15px 0;
    }
    
    .dlm-table {
        min-width: 700px; /* Largeur fixe pour forcer le scroll horizontal */
        table-layout: fixed;
    }
    
    /* Largeurs adaptées pour mobile */
    .dlm-table th:nth-child(1), .dlm-table td:nth-child(1) { width: 200px; } /* Titre fixe */
    .dlm-table th:nth-child(2), .dlm-table td:nth-child(2) { width: 80px; }  /* Prix */
    .dlm-table th:nth-child(3), .dlm-table td:nth-child(3) { width: 100px; } /* Statut */
    .dlm-table th:nth-child(4), .dlm-table td:nth-child(4) { width: 100px; } /* Date */
    .dlm-table th:nth-child(5), .dlm-table td:nth-child(5) { width: 140px; } /* Actions */
    
    .dlm-table th,
    .dlm-table td {
        padding: 10px 6px;
        font-size: 12px;
    }
    
    /* Ajustement des statuts pour mobile */
    .dlm-status {
        padding: 4px 8px;
        font-size: 11px;
        white-space: nowrap;
    }
    
    /* Actions en ligne pour mobile */
    .dlm-book-actions {
        gap: 3px;
    }
    
    .dlm-book-actions .button {
        min-width: 28px;
        height: 28px;
        padding: 0 4px;
    }
    
    .dlm-book-actions .button .dashicons {
        width: 14px;
        height: 14px;
        font-size: 14px;
    }
    
    /* Cacher le texte des boutons sur mobile, garder seulement les icônes */
    .dlm-book-actions .button.has-text .button-text {
        display: none;
    }
    
    /* Style de la barre de défilement pour mobile */
    .dlm-table-wrapper::-webkit-scrollbar {
        height: 4px;
    }
    
    .dlm-table-wrapper::-webkit-scrollbar-thumb {
        background: #3858e9;
        border-radius: 4px;
    }
    
    .dlm-table-wrapper::-webkit-scrollbar-track {
        background: #f0f0f0;
    }
}

/* ===== CORRECTION POUR L'EN-TÊTE DU TABLEAU ===== */
.dlm-tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.dlm-tab-header h2 {
    margin: 0;
    font-size: 1.4rem;
    color: #333;
}

.dlm-book-filters {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dlm-filter-select {
    padding: 8px 12px;
    border: 1px solid #009E49;
    border-radius: 4px;
    background: white;
    color: #009E49;
    font-weight: 500;
}

/* Pour les très petits écrans */
@media (max-width: 480px) {
    .dlm-tab-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .dlm-book-filters {
        width: 100%;
    }
    
    .dlm-filter-select {
        width: 100%;
    }
}

/* ===== STATUTS AVEC BADGES ===== */
.dlm-status {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}

.dlm-status-approved {
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #bbdefb;
}

.dlm-status-pending {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffe0b2;
}

.dlm-status-suspended {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.dlm-status-rejected {
    background: #fafafa;
    color: #424242;
    border: 1px solid #e0e0e0;
}

/* ===== AMÉLIORATIONS POUR GRANDS ÉCRANS ===== */
@media (min-width: 1200px) {
    .dlm-table th,
    .dlm-table td {
        padding: 15px 20px;
    }
    
    .dlm-table .dlm-book-title {
        min-width: 300px;
    }
    
    .dlm-book-actions .button {
        min-width: 40px;
        height: 40px;
    }
}

/* ===== CORRECTION ALIGNEMENT ===== */
.dlm-table th:last-child,
.dlm-table td:last-child {
    text-align: right;
    padding-right: 20px;
}

.dlm-table th:first-child,
.dlm-table td:first-child {
    padding-left: 20px;
}

/* Assurer que les boutons sont bien alignés à droite */
.dlm-table td.dlm-book-actions {
    text-align: right;
}

/* ===== VERSION TRÈS PETITS ÉCRANS ===== */
@media (max-width: 480px) {
    .dlm-table {
        font-size: 13px;
    }
    
    .dlm-table th,
    .dlm-table td {
        padding: 10px 8px;
    }
    
    .dlm-status {
        padding: 3px 8px;
        font-size: 11px;
    }
} 

/* ===== OUTILS POUR LES RAISONS DE REJET ===== */
.dlm-reason-tooltip {
    position: relative;
    display: inline-block;
    margin-left: 5px;
}

.dlm-reason-tooltip .dashicons {
    color: #d63638;
    cursor: help;
}

.dlm-reason-tooltip:hover .dlm-reason-text {
    display: block;
}

.dlm-reason-text {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 5px;
}

/* Cartes de statistiques */
.dlm-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.dlm-stat-card {
    display: flex;
    align-items: center;
    gap: 15px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.dlm-stat-icon {
    width: 50px;
    height: 50px;
    background: #f0f7f2;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dlm-stat-icon .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: #009E49;
}

.dlm-stat-content {
    flex: 1;
}

.dlm-stat-content h3 {
    margin: 0 0 5px 0;
    font-size: 0.9rem;
    color: #666;
}

.dlm-stat-value {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 600;
    color: #333;
}

.dlm-stat-value.dlm-highlight {
    color: #009E49;
}

/* Barre de progression */
.dlm-progress-bar {
    position: relative;
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    width: 150px;
}

.dlm-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #009E49, #FCD116);
    border-radius: 4px;
}

.dlm-progress-label {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.7rem;
    color: #333;
    font-weight: 600;
}

/* Carte de solde */
.dlm-balance-card {
    display: flex;
    align-items: center;
    gap: 20px;
    background: white;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.dlm-balance-icon {
    width: 70px;
    height: 70px;
    background: #f0f7f2;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dlm-balance-icon .dashicons {
    font-size: 36px;
    width: 36px;
    height: 36px;
    color: #009E49;
}

.dlm-balance-info {
    flex: 1;
}

.dlm-balance-info h3 {
    margin: 0 0 5px 0;
    font-size: 1rem;
    color: #666;
}

.dlm-balance-amount {
    margin: 0 0 10px 0;
    font-size: 2.5rem;
    font-weight: 600;
    color: #009E49;
}

.dlm-balance-note {
    margin: 10px 0 0 0;
    color: #666;
    font-size: 0.9rem;
}

/* Formulaire de soumission */
.dlm-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 20px;
}

.dlm-form-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dlm-form-group {
    margin-bottom: 15px;
}

.dlm-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.dlm-form-group .required {
    color: #EF2B2D;
}

.dlm-form-group input[type="text"],
.dlm-form-group input[type="number"],
.dlm-form-group input[type="tel"],
.dlm-form-group select,
.dlm-form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.dlm-form-group input:focus,
.dlm-form-group select:focus,
.dlm-form-group textarea:focus {
    outline: none;
    border-color: #009E49;
    box-shadow: 0 0 0 2px rgba(0, 158, 73, 0.1);
}

.dlm-checkbox-group {
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
}

.dlm-checkbox {
    display: block;
    margin: 5px 0;
    cursor: pointer;
}

.dlm-checkbox input[type="checkbox"] {
    margin-right: 8px;
}

.dlm-field-note {
    margin: 5px 0 0 0;
    color: #666;
    font-size: 0.8rem;
}

.dlm-char-counter {
    text-align: right;
    color: #666;
    font-size: 0.8rem;
    margin-top: 5px;
}

.dlm-char-counter span {
    font-weight: 600;
    color: #009E49;
}

.dlm-confirmation {
    margin-top: 20px;
    padding: 15px;
    background: #f0f7f2;
    border-radius: 4px;
    border-left: 4px solid #009E49;
}

.dlm-form-actions {
    text-align: right;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

/* Alertes */
.dlm-alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
}

.dlm-alert-error {
    background: #fee;
    border-left: 4px solid #EF2B2D;
}

.dlm-alert-success {
    background: #f0f7f2;
    border-left: 4px solid #009E49;
}

.dlm-alert ul {
    margin: 5px 0 0 20px;
}

/* États vides */
.dlm-empty-state {
    text-align: center;
    padding: 50px;
    background: white;
    border-radius: 8px;
}

.dlm-empty-state .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #ddd;
}

.dlm-empty-state p {
    margin: 15px 0;
    color: #666;
}

.dlm-no-data {
    text-align: center;
    padding: 30px;
    background: white;
    border-radius: 8px;
    color: #999;
}

/* Utilitaires */
.dlm-text-right {
    text-align: right;
}

.dlm-highlight {
    font-weight: 600;
    color: #009E49;
}

.dlm-muted {
    color: #999;
}

/* Responsive */
@media (max-width: 768px) {
    .dlm-dashboard-tabs {
        flex-direction: column;
    }
    
    .dlm-form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .dlm-stats-grid {
        grid-template-columns: 1fr;
    }
    
    .dlm-balance-card {
        flex-direction: column;
        text-align: center;
    }
    
    .dlm-table {
        font-size: 0.8rem;
    }
    
    .dlm-table th,
    .dlm-table td {
        padding: 8px 10px;
    }
}

/* ===== GESTION DU SCROLL VERTICAL ===== */

/* Conteneur principal avec scroll vertical */
.dlm-scrollable-table-container {
    overflow-y: auto;    /* Scroll vertical */
    overflow-x: hidden;  /* Pas de scroll horizontal (géré par le wrapper) */
    max-height: 500px;   /* Hauteur maximale avant scroll */
    border-radius: 8px;
    scrollbar-width: thin; /* Pour Firefox */
    scrollbar-color: #3858e9 #f0f0f0; /* Pour Firefox */
}

/* Style de la scrollbar pour Chrome/Safari/Edge */
.dlm-scrollable-table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.dlm-scrollable-table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.dlm-scrollable-table-container::-webkit-scrollbar-thumb {
    background: #3858e9;
    border-radius: 4px;
}

.dlm-scrollable-table-container::-webkit-scrollbar-thumb:hover {
    background: #2a4bd6;
}

/* En-tête fixe pendant le scroll */
.dlm-scrollable-table-container thead th {
    position: sticky;
    top: 0;
    background: #3858e9;
    color: white;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ===== HAUTEURS ADAPTATIVES SELON L'ÉCRAN ===== */

/* Desktop - hauteur plus grande */
@media (min-width: 1024px) {
    .dlm-scrollable-table-container {
        max-height: 600px;
    }
}

/* Tablette - hauteur moyenne */
@media (min-width: 768px) and (max-width: 1023px) {
    .dlm-scrollable-table-container {
        max-height: 450px;
    }
}

/* Mobile - hauteur réduite */
@media (max-width: 767px) {
    .dlm-scrollable-table-container {
        max-height: 350px;
    }
    
    /* Ajustement de la scrollbar pour mobile */
    .dlm-scrollable-table-container::-webkit-scrollbar {
        width: 4px;
    }
}
