/**
 * Digital Library Plugin - Custom Styles
 * Styles for eBook/audiobook functionality
 */

/* ==========================================================================
   Status Badge Icons
   ========================================================================== */

.digital-badge-icon {
    display: inline-block;
    margin-left: 0.25rem;
    font-size: 0.75em;
    opacity: 0.9;
    transition: opacity 0.2s ease;
}

.digital-badge-icon:hover {
    opacity: 1;
}

.digital-badge-icon.ebook-icon {
    color: #dc2626; /* red-600 for PDF */
}

.digital-badge-icon.audio-icon {
    color: #16a34a; /* green-600 for audio */
}

/* Ensure icons don't break layout in small badges */
.book-status-badge .digital-badge-icon,
.related-availability-badge .digital-badge-icon {
    vertical-align: middle;
    line-height: 1;
}

/* ==========================================================================
   Action Buttons - Digital Content
   ========================================================================== */

.action-buttons .plugin-book-action {
    color: var(--text-color, #1e293b);
    border-color: color-mix(in srgb, var(--text-color, #1e293b) 22%, transparent);
    background: color-mix(in srgb, var(--light-bg, #f8fafc) 72%, transparent);
    box-shadow: none;
}

.action-buttons .plugin-book-action:hover,
.action-buttons .plugin-book-action:focus-visible {
    color: var(--button-text-color, #fff);
    border-color: var(--button-color, #1e293b);
    background: var(--button-color, #1e293b);
    box-shadow: none;
}

.plugin-player-action {
    min-height: 40px;
    padding: .55rem .8rem;
    border-radius: 10px;
    font-size: .8rem;
    box-shadow: none;
}

/* ==========================================================================
   Audiobook Player Container
   ========================================================================== */

#audiobook-player-container {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#audiobook-player-container .card,
#pdf-viewer-container .card {
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
}

#audiobook-player-container .card:hover,
#pdf-viewer-container .card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

/* ==========================================================================
   Audio Player — Black & White Theme
   ========================================================================== */

.player-digital-library {
    margin: 0;
    width: 100%;
}

.player-digital-library .player {
    box-shadow: none !important;
    border-radius: 12px;
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    padding: 1rem;
}

.player-digital-library .play-pause-btn {
    background-color: #1e293b !important;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.player-digital-library .play-pause-btn:hover {
    background-color: #334155 !important;
    transform: scale(1.1);
}

.player-digital-library .play-pause-btn svg path {
    fill: #fff !important;
}

.player-digital-library .slider .gap-progress {
    background-color: #1e293b !important;
}

.player-digital-library .slider .gap-progress .pin {
    background-color: #1e293b !important;
}

.player-digital-library .controls__slider {
    background-color: #e5e7eb;
}

.player-digital-library .controls__current-time,
.player-digital-library .controls__total-time {
    font-size: 0.875rem;
    color: #475569;
    font-weight: 500;
}

/* Volume controls */
.player-digital-library .volume__button {
    color: #475569;
}

.player-digital-library .volume__button.open path {
    fill: #1e293b !important;
}

.player-digital-library .volume__controls .slider .gap-progress {
    background-color: #1e293b !important;
}

/* Download button (if enabled) */
.player-digital-library .download {
    color: #475569;
    transition: color 0.2s ease;
}

.player-digital-library .download:hover {
    color: #1e293b;
}

/* ==========================================================================
   Admin Form - Digital Content Section
   ========================================================================== */

.bg-gradient-to-br.from-purple-50.to-indigo-50 {
    background: linear-gradient(135deg, #faf5ff 0%, #eef2ff 100%);
}

/* Upload button states */
#upload-ebook-btn,
#upload-audio-btn {
    font-weight: 600;
    letter-spacing: 0.025em;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

#upload-ebook-btn:hover {
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
    transform: translateY(-2px);
}

#upload-audio-btn:hover {
    box-shadow: 0 4px 12px rgba(30, 41, 59, 0.3);
    transform: translateY(-2px);
}

#upload-ebook-btn:active,
#upload-audio-btn:active {
    transform: translateY(0);
}

/* ==========================================================================
   PDF Viewer Container
   ========================================================================== */

#pdf-viewer-container {
    animation: slideDown 0.3s ease-out;
}

.pdf-viewer-frame {
    width: 100%;
    height: 80vh;
    border: none;
    border-radius: 8px;
    background: #f1f5f9;
}

#pdf-viewer-container .btn-danger {
    background-color: #dc2626 !important;
    border-color: #dc2626 !important;
    color: #fff;
}

#pdf-viewer-container .btn-danger:hover,
#pdf-viewer-container .btn-danger:focus {
    background-color: #b91c1c !important;
    border-color: #b91c1c !important;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .action-buttons .plugin-book-action {
        min-width: 100%;
    }

    #audiobook-player-container .card-body {
        padding: 1rem;
    }

    .player-digital-library .player {
        padding: 0.75rem;
    }

    .player-digital-library .play-pause-btn {
        width: 36px;
        height: 36px;
    }

    .pdf-viewer-frame {
        height: 60vh;
    }

    #pdf-viewer-container .card-body {
        padding: 1rem;
    }
}

/* ==========================================================================
   Accessibility Enhancements
   ========================================================================== */

/* Focus states for keyboard navigation */
.player-accessible *:focus {
    outline: 2px solid #1e293b;
    outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .player-digital-library .player {
        border: 2px solid currentColor;
    }

    .digital-badge-icon {
        opacity: 1;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .action-buttons .ui-button:hover {
        transform: none;
    }

    #audiobook-player-container .card:hover,
    #pdf-viewer-container .card:hover {
        transform: none;
    }
}

.digital-attachments-editor { margin-top: 1.5rem; }
.digital-attachments-editor > p { margin: .75rem 0; color: var(--text-light, #475569); }
.digital-attachment-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr) auto; align-items: end; gap: .75rem; padding: 1rem 0; border-bottom: 1px solid var(--border-color, #e5e7eb); }
.digital-attachment-row label { min-width: 0; }
.digital-attachment-invalid { grid-column: 1 / -1; margin: 0; color: #b91c1c; }
.digital-attachment-row input, .digital-attachment-row select { display: block; width: 100%; }
.digital-attachment-uploaders { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
/* Frontend: one card per digital file (type, name and kind, then actions). */
.digital-attachments-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.digital-attachments-list li.digital-attachment { flex: 1 1 300px; min-width: 0; padding: 16px 18px; border-radius: 16px; background: var(--pk-surface, #fff); border: 1px solid var(--pk-line, #ece8ea); display: flex; flex-direction: column; gap: 10px; overflow-wrap: anywhere; }
/* The file type and its name share the first row; the actions take a row of
   their own, aligned under the name, so a long file name is never squeezed
   to a few characters by the buttons beside it. */
.digital-attachment__head { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 10px 14px; }
.digital-attachment__type { flex: none; width: 40px; height: 48px; border-radius: 6px; background: var(--pk-accent-soft, #fdeaf2); color: var(--pk-accent-strong, #a8004b); display: grid; place-items: center; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.digital-attachment__type--round { height: 40px; border-radius: 50%; }
.digital-attachment__text { min-width: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.digital-attachment__text strong { font-size: 14px; font-weight: 600; color: var(--pk-ink, #1b1720); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.digital-attachment__sep { display: none; }
.digital-attachment__kind { font-size: 13px; color: var(--pk-muted, #6b6470); }
.digital-attachment__actions { grid-column: 2; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-start; }
/* An audiobook has one action and a player below: the button stays beside the name. */
.digital-attachment--audio .digital-attachment__head { grid-template-columns: 40px minmax(0, 1fr) auto; }
.digital-attachment--audio .digital-attachment__actions { grid-column: 3; }
.digital-attachments-list .digital-attachment__actions .ui-button { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; min-height: 0; width: auto; border-radius: 10px; font-size: 13px; font-weight: 600; line-height: 1.2; box-shadow: none; text-transform: none; letter-spacing: normal; }
.digital-attachments-list .digital-attachment__read { background: var(--pk-dark, #1b1720); color: #fff; border: 1px solid var(--pk-dark, #1b1720); }
.digital-attachments-list .digital-attachment__read:hover { background: var(--pk-button, #d70161); border-color: var(--pk-button, #d70161); color: var(--pk-button-text, #fff); }
.digital-attachments-list .digital-attachment__download { background: var(--pk-surface, #fff); color: var(--pk-ink, #1b1720); border: 1px solid var(--pk-line-2, #e2dce0); }
.digital-attachments-list .digital-attachment__download:hover { border-color: var(--pk-ink, #1b1720); color: var(--pk-ink, #1b1720); }
.digital-attachments-list .digital-attachment__download i { font-size: 12px; margin: 0; }
.digital-attachments-list audio { display: block; width: 100%; height: 34px; margin: 0; }
.digital-attachment__viewer { margin: 0; }
.digital-attachments-list iframe { width: 100%; height: 65vh; border: 0; border-radius: 10px; }
@media (max-width: 767px) { .digital-attachment-row, .digital-attachment-uploaders { grid-template-columns: minmax(0, 1fr); } }
/* Phones: the two actions share the row at equal width. */
@media (max-width: 480px) {
    .digital-attachments-list .digital-attachment__actions .ui-button { flex: 1 1 0; justify-content: center; }
    .digital-attachment--audio .digital-attachment__head { grid-template-columns: 40px minmax(0, 1fr); }
    .digital-attachment--audio .digital-attachment__actions { grid-column: 2; }
    .digital-attachment--audio .digital-attachment__actions .ui-button { flex: 0 0 auto; }
}
/* "Leggi PDF" is a link (the PDF itself without JavaScript) styled as its button. */
.digital-attachments-list a.digital-attachment__read, .digital-attachments-list a.digital-attachment__read:hover { text-decoration: none; }
