/**
 * Style de la bibliothèque personnelle - DLM User Library
 * Couleurs : Rouge (#e74c3c), Jaune (#f1c40f), Vert (#2ecc71)
 */

/* ===== Variables et reset ===== */
:root {
    --dlm-red: #e74c3c;
    --dlm-red-light: #fadbd8;
    --dlm-yellow: #f1c40f;
    --dlm-yellow-light: #fcf3cf;
    --dlm-green: #2ecc71;
    --dlm-green-light: #d5f5e3;
    --dlm-gray: #95a5a6;
    --dlm-gray-light: #ecf0f1;
    --dlm-dark: #2c3e50;
    --dlm-white: #ffffff;
    --dlm-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --dlm-border-radius: 8px;
}

/* ===== Conteneur principal ===== */
.dlm-my-library {
    max-width: 1400px;
    margin: 30px auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ===== En-tête ===== */
.dlm-library-header {
    margin-bottom: 30px;
    border-bottom: 3px solid var(--dlm-yellow);
    padding-bottom: 20px;
}

.dlm-library-header h2 {
    color: black;
    font-size: 28px;
    margin: 0 0 20px 0;
    position: relative;
    display: inline-block;
}

.dlm-library-header h2:after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 60px;
    height: 3px;
    background: var(--dlm-red);
}

/* ===== Contrôles de la bibliothèque ===== */
.dlm-library-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    justify-content: space-between;
}

/* Zone de recherche */
.dlm-search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
    display: flex;
    align-items: center;
}

.dlm-search-input {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border: 2px solid var(--dlm-gray-light);
    border-radius: 30px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: var(--dlm-white);
}

.dlm-search-input:focus {
    outline: none;
    border-color: var(--dlm-yellow);
    box-shadow: 0 0 0 3px rgba(241, 196, 15, 0.2);
}

.dlm-search-icon {
    position: absolute;
    right: 15px;
    color: var(--dlm-gray);
    font-size: 18px;
    pointer-events: none;
}

/* Options de vue */
.dlm-view-options {
    display: flex;
    gap: 5px;
    background: var(--dlm-gray-light);
    padding: 5px;
    border-radius: 40px;
}

.dlm-view-btn {
    background: none;
    border: none;
    padding: 8px 16px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 14px;
    color: var(--dlm-dark);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.dlm-view-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.dlm-view-btn:hover {
    background: var(--dlm-white);
    color: var(--dlm-red);
}

.dlm-view-btn.active {
    background: var(--dlm-white);
    color: var(--dlm-red);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ===== Grille de livres ===== */
.dlm-books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
    margin: 30px 0;
    transition: opacity 0.3s ease;
}

.dlm-books-grid.fade-in {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0.5; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Carte de livre */
.dlm-book-card {
    background: var(--dlm-white);
    border-radius: var(--dlm-border-radius);
    overflow: hidden;
    box-shadow: var(--dlm-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid var(--dlm-gray-light);
    display: flex;
    flex-direction: column;
}

.dlm-book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
    border-color: var(--dlm-yellow);
}

/* Couverture */
.dlm-book-cover {
    position: relative;
    padding-top: 140%;
    background: var(--dlm-gray-light);
    overflow: hidden;
}

.dlm-book-cover img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.dlm-book-card:hover .dlm-book-cover img {
    transform: scale(1.05);
}

/* Badge de format */
.dlm-format-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    z-index: 2;
}

.dlm-format-badge.pdf {
    background: var(--dlm-red);
}

.dlm-format-badge.epub {
    background: var(--dlm-green);
}

/* Informations du livre */
.dlm-book-info {
    padding: 20px;
    text-align: center;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.dlm-book-info h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: var(--dlm-dark);
    line-height: 1.4;
}

.dlm-book-author {
    color: var(--dlm-gray);
    font-size: 14px;
    margin: 0 0 10px 0;
    font-style: italic;
}

.dlm-book-meta {
    margin: 0 0 15px 0;
    font-size: 13px;
    color: var(--dlm-gray);
}

.dlm-book-meta small {
    color: var(--dlm-dark);
    background: var(--dlm-gray-light);
    padding: 4px 12px;
    border-radius: 20px;
    display: inline-block;
}

/* Bouton de lecture */
.dlm-read-btn,
.button.dlm-read-btn {
    display: inline-block;
    padding: 10px 20px;
    background: var(--dlm-green);
    color: white;
    text-decoration: none;
    border-radius: 30px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    margin-top: auto;
}

.dlm-read-btn:hover {
    background: #27ae60;
    transform: scale(1.05);
    color: white;
}

button.dlm-read-btn:disabled,
.button.dlm-read-btn:disabled {
    background: var(--dlm-gray);
    cursor: not-allowed;
    opacity: 0.7;
}

.dlm-unavailable {
    color: var(--dlm-red);
    font-size: 13px;
    font-weight: 600;
}

/* ===== Vue liste ===== */
.dlm-books-list {
    margin: 30px 0;
    background: var(--dlm-white);
    border-radius: var(--dlm-border-radius);
    overflow: hidden;
    box-shadow: var(--dlm-shadow);
}

.dlm-list-table {
    width: 100%;
    border-collapse: collapse;
}

.dlm-list-table th {
    background: var(--dlm-dark);
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

.dlm-list-table th:first-child {
    border-radius: var(--dlm-border-radius) 0 0 0;
}

.dlm-list-table th:last-child {
    border-radius: 0 var(--dlm-border-radius) 0 0;
}

.dlm-list-table td {
    padding: 15px;
    border-bottom: 1px solid var(--dlm-gray-light);
    vertical-align: middle;
}

.dlm-list-table tr:hover td {
    background: var(--dlm-gray-light);
}

.dlm-list-book {
    display: flex;
    align-items: center;
    gap: 15px;
}

.dlm-list-cover {
    width: 50px;
    height: 70px;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dlm-list-title {
    font-weight: 600;
    color: var(--dlm-dark);
}

/* Barre de progression */
.dlm-progress {
    width: 150px;
}

.dlm-progress-bar {
    height: 6px;
    background: var(--dlm-gray-light);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 5px;
}

.dlm-progress-fill {
    height: 100%;
    background: var(--dlm-yellow);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.dlm-progress-text {
    font-size: 12px;
    color: var(--dlm-gray);
}

/* ===== Pagination ===== */
.dlm-pagination-container {
    margin: 30px 0 20px;
}

.dlm-pagination {
    display: flex;
    justify-content: center;
}

.dlm-pagination-inner {
    display: flex;
    gap: 5px;
    background: var(--dlm-white);
    padding: 5px;
    border-radius: 40px;
    box-shadow: var(--dlm-shadow);
}

.dlm-pagination a,
.dlm-pagination .current {
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    text-decoration: none;
    transition: all 0.2s ease;
}

.dlm-pagination a {
    color: var(--dlm-dark);
    background: var(--dlm-gray-light);
}

.dlm-pagination a:hover {
    background: var(--dlm-yellow);
    color: var(--dlm-dark);
    transform: scale(1.1);
}

.dlm-pagination a.prev:hover,
.dlm-pagination a.next:hover {
    background: var(--dlm-red);
    color: white;
}

.dlm-pagination .current {
    background: var(--dlm-red);
    color: white;
    font-weight: 600;
}

.dlm-pagination .dots {
    color: var(--dlm-gray);
    padding: 0 5px;
}

/* ===== Footer et stats ===== */
.dlm-library-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--dlm-gray-light);
    text-align: center;
}

.dlm-stats {
    color: var(--dlm-gray);
    font-size: 14px;
    background: var(--dlm-gray-light);
    padding: 10px 20px;
    border-radius: 30px;
    display: inline-block;
}

/* ===== Loader ===== */
.dlm-loading {
    text-align: center;
    padding: 50px 0;
}

.dlm-spinner {
    display: inline-block;
    width: 50px;
    height: 50px;
    border: 3px solid var(--dlm-gray-light);
    border-top-color: var(--dlm-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 15px;
}

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

.dlm-loading p {
    color: var(--dlm-gray);
    font-size: 16px;
}

/* ===== Messages ===== */
.dlm-no-books,
.dlm-no-results {
    text-align: center;
    padding: 50px 20px;
    background: var(--dlm-gray-light);
    border-radius: var(--dlm-border-radius);
    color: var(--dlm-gray);
    font-size: 16px;
}

.dlm-no-results .error {
    color: var(--dlm-red);
    font-weight: 600;
}

.dlm-login-required {
    text-align: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, var(--dlm-yellow-light), var(--dlm-red-light));
    border-radius: var(--dlm-border-radius);
}

.dlm-login-required p {
    font-size: 18px;
    color: var(--dlm-dark);
    margin-bottom: 20px;
}

.dlm-login-required .button {
    display: inline-block;
    padding: 12px 30px;
    background: var(--dlm-green);
    color: white;
    text-decoration: none;
    border-radius: 30px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.dlm-login-required .button:hover {
    background: #27ae60;
    transform: scale(1.05);
}

/* ===== Styles responsives ===== */

/* Tablettes */
@media screen and (max-width: 1024px) {
    .dlm-my-library {
        padding: 15px;
    }
    
    .dlm-books-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
}

/* Mobiles (paysage) */
@media screen and (max-width: 768px) {
    .dlm-library-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .dlm-search-box {
        min-width: 100%;
    }
    
    .dlm-view-options {
        justify-content: center;
    }
    
    .dlm-books-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px;
    }
    
    .dlm-book-info {
        padding: 15px 10px;
    }
    
    .dlm-book-info h3 {
        font-size: 16px;
    }
    
    .dlm-book-author {
        font-size: 12px;
    }
    
    /* Adaptation du tableau en liste */
    .dlm-list-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .dlm-list-table th,
    .dlm-list-table td {
        padding: 10px;
    }
    
    .dlm-list-cover {
        width: 40px;
        height: 56px;
    }
    
    .dlm-progress {
        width: 120px;
    }
    
    .dlm-pagination-inner {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .dlm-pagination a,
    .dlm-pagination .current {
        min-width: 35px;
        height: 35px;
        font-size: 13px;
    }
}

/* Petits mobiles */
@media screen and (max-width: 480px) {
    .dlm-my-library {
        padding: 10px;
    }
    
    .dlm-library-header h2 {
        font-size: 24px;
    }
    
    .dlm-books-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    
    .dlm-book-card {
        max-width: 300px;
        margin: 0 auto;
        width: 100%;
    }
    
    .dlm-view-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .dlm-view-btn .dashicons {
        font-size: 16px;
    }
    
    /* Version mobile du tableau */
    .dlm-list-table,
    .dlm-list-table tbody,
    .dlm-list-table tr,
    .dlm-list-table td {
        display: block;
    }
    
    .dlm-list-table thead {
        display: none;
    }
    
    .dlm-list-table tr {
        margin-bottom: 15px;
        border: 1px solid var(--dlm-gray-light);
        border-radius: var(--dlm-border-radius);
        padding: 10px;
        background: var(--dlm-white);
    }
    
    .dlm-list-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 8px 10px;
        border: none;
        border-bottom: 1px solid var(--dlm-gray-light);
    }
    
    .dlm-list-table td:last-child {
        border-bottom: none;
    }
    
    .dlm-list-table td:before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--dlm-dark);
        margin-right: 10px;
    }
    
    .dlm-list-book {
        justify-content: space-between;
    }
    
    .dlm-progress {
        width: 100%;
        max-width: 150px;
    }
    
    .dlm-stats {
        font-size: 12px;
        padding: 8px 16px;
    }
    
    .dlm-login-required p {
        font-size: 16px;
    }
}

/* Très petits écrans */
@media screen and (max-width: 320px) {
    .dlm-view-options {
        flex-direction: column;
        width: 100%;
    }
    
    .dlm-view-btn {
        justify-content: center;
    }
    
    .dlm-pagination a,
    .dlm-pagination .current {
        min-width: 30px;
        height: 30px;
    }
}

/* ===== Utilitaires ===== */
.dlm-hidden {
    display: none !important;
}

.dlm-text-red {
    color: var(--dlm-red);
}

.dlm-text-yellow {
    color: var(--dlm-yellow);
}

.dlm-text-green {
    color: var(--dlm-green);
}

/* Support dark mode (optionnel) */
@media (prefers-color-scheme: dark) {
    :root {
        --dlm-dark: #ecf0f1;
        --dlm-white: #2c3e50;
        --dlm-gray-light: #34495e;
        --dlm-gray: #7f8c8d;
    }
    
    .dlm-book-card {
        border-color: #34495e;
    }
    
    .dlm-list-table td {
        color: #ecf0f1;
    }
}
