/* ==========================================================================
   Book Collection Manager — Front-end (v1.1)
   ========================================================================== */

.bcm-frontend-container {
    --bcm-primary: #4f46e5;
    --bcm-primary-dark: #4338ca;
    --bcm-primary-light: #eef2ff;
    --bcm-ink: #1e1b2e;
    --bcm-muted: #6b7280;
    --bcm-border: #e5e7eb;
    --bcm-bg: #f7f7fb;
    --bcm-card-bg: #ffffff;
    --bcm-radius: 16px;
    --bcm-radius-sm: 10px;
    --bcm-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 12px rgba(16, 24, 40, 0.06);
    --bcm-shadow-hover: 0 8px 24px rgba(79, 70, 229, 0.16);

    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 20px 60px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--bcm-ink);
    box-sizing: border-box;
}

.bcm-frontend-container *,
.bcm-frontend-container *::before,
.bcm-frontend-container *::after {
    box-sizing: border-box;
}

/* ---------- Hero / search ---------- */

.bcm-hero {
    background: linear-gradient(135deg, var(--bcm-primary) 0%, #7c3aed 100%);
    border-radius: var(--bcm-radius);
    padding: 40px 32px 28px;
    margin-bottom: 28px;
    color: #fff;
    box-shadow: var(--bcm-shadow);
}

.bcm-hero-title {
    margin: 0 0 6px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.bcm-hero-subtitle {
    margin: 0 0 24px;
    font-size: 15px;
    opacity: 0.85;
}

.bcm-search-box {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 640px;
    background: #fff;
    border-radius: 999px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.bcm-search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--bcm-muted);
    pointer-events: none;
    z-index: 1;
}

.bcm-frontend-container input.bcm-search-field {
    flex: 1;
    width: 100%;
    height: 52px;
    margin: 0 !important;
    padding: 0 44px 0 48px !important;
    font-size: 16px;
    line-height: normal;
    border: none !important;
    outline: none;
    border-radius: 999px;
    background: transparent;
    color: var(--bcm-ink);
    box-shadow: none !important;
}

.bcm-search-field::placeholder {
    color: #9ca3af;
}

.bcm-search-clear {
    position: absolute;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #f1f1f5;
    color: #6b7280;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.bcm-search-clear:hover {
    background: #e5e5ec;
}

.bcm-meta-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 18px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
}

.bcm-results-count {
    font-weight: 500;
}

.bcm-view-toggle {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.bcm-view-btn {
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    padding: 6px 9px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.2s ease, color 0.2s ease;
}

.bcm-view-btn:hover {
    color: #fff;
}

.bcm-view-btn.is-active {
    background: #fff;
    color: var(--bcm-primary);
}

/* ---------- Results grid ---------- */

.bcm-results-section {
    min-height: 200px;
    position: relative;
}

.bcm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 20px;
}

.bcm-grid.bcm-view-list {
    grid-template-columns: 1fr;
}

/* ---------- Cards ---------- */

.bcm-book-card {
    background: var(--bcm-card-bg);
    border: 1px solid var(--bcm-border);
    border-radius: var(--bcm-radius-sm);
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--bcm-shadow);
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
    opacity: 0;
    transform: translateY(10px);
    animation: bcmCardIn 0.4s ease forwards;
    display: flex;
    flex-direction: column;
}

@keyframes bcmCardIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bcm-book-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--bcm-shadow-hover);
    border-color: var(--bcm-primary);
}

.bcm-card-cover {
    position: relative;
    width: 100%;
}

.bcm-card-cover-media {
    width: 100%;
    aspect-ratio: 3 / 4;
    background: linear-gradient(135deg, #ede9fe, #e0e7ff);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.bcm-card-cover-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

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

.bcm-card-cover-placeholder {
    color: #a5b4fc;
}

.bcm-card-status {
    flex: 0 0 auto;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.bcm-card-body {
    padding: 14px 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.bcm-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.bcm-card-titles {
    min-width: 0;
    flex: 1;
}

.bcm-card-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--bcm-ink);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bcm-card-author {
    margin-top: 2px;
    font-size: 13px;
    color: var(--bcm-muted);
}

.bcm-card-info {
    margin-top: 0;
    padding-top: 8px;
    border-top: 1px solid var(--bcm-border);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
}

.bcm-card-info-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.bcm-info-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9ca3af;
}

.bcm-info-value {
    font-size: 12.5px;
    color: var(--bcm-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bcm-info-value.is-empty {
    color: #c7c9d1;
}

/* ---------- List view ---------- */

.bcm-grid.bcm-view-list .bcm-book-card {
    flex-direction: row;
    align-items: center;
}

.bcm-grid.bcm-view-list .bcm-card-cover {
    width: 56px;
    min-width: 56px;
}

.bcm-grid.bcm-view-list .bcm-card-cover-media {
    aspect-ratio: 3 / 4;
    border-radius: 6px;
}

.bcm-grid.bcm-view-list .bcm-card-body {
    flex-direction: row;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 12px 18px;
}

.bcm-grid.bcm-view-list .bcm-card-heading {
    flex: 1 1 260px;
    min-width: 180px;
    align-items: center;
}

.bcm-grid.bcm-view-list .bcm-card-title {
    -webkit-line-clamp: 1;
}

.bcm-grid.bcm-view-list .bcm-card-author {
    margin-top: 0;
}

.bcm-grid.bcm-view-list .bcm-card-info {
    margin: 0;
    padding: 0;
    border-top: none;
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 60px 150px 60px 150px;
    gap: 4px 24px;
}

.bcm-grid.bcm-view-list .bcm-info-value {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Skeleton loading ---------- */

.bcm-skeleton-grid {
    position: absolute;
    inset: 0;
}

.bcm-skeleton-card {
    border-radius: var(--bcm-radius-sm);
    overflow: hidden;
    background: var(--bcm-card-bg);
    border: 1px solid var(--bcm-border);
}

.bcm-skeleton-cover {
    aspect-ratio: 3 / 4;
    background: linear-gradient(100deg, #eee 30%, #f5f5f5 50%, #eee 70%);
    background-size: 200% 100%;
    animation: bcmShimmer 1.3s infinite;
}

.bcm-skeleton-line {
    height: 10px;
    margin: 12px 14px;
    border-radius: 4px;
    background: linear-gradient(100deg, #eee 30%, #f5f5f5 50%, #eee 70%);
    background-size: 200% 100%;
    animation: bcmShimmer 1.3s infinite;
}

.bcm-skeleton-line-sub {
    width: 60%;
}

@keyframes bcmShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---------- No results ---------- */

.bcm-no-results {
    text-align: center;
    padding: 70px 20px;
    color: var(--bcm-muted);
}

.bcm-no-results svg {
    margin-bottom: 14px;
    opacity: 0.5;
}

.bcm-no-results p {
    font-size: 16px;
    margin: 0;
}

/* ---------- Modal ---------- */

.bcm-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    inset: 0;
    background-color: rgba(17, 12, 34, 0.55);
    backdrop-filter: blur(3px);
    overflow: auto;
}

.bcm-modal-dialog {
    position: relative;
    margin: 40px auto;
    max-width: 720px;
    width: 92%;
}

.bcm-modal-content {
    background-color: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    animation: bcmModalIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

@keyframes bcmModalIn {
    from {
        transform: translateY(24px) scale(0.98);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.bcm-modal-header {
    padding: 24px 28px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    background: linear-gradient(135deg, var(--bcm-primary) 0%, #7c3aed 100%);
    color: #fff;
}

.bcm-modal-header h2 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
}

.bcm-modal-header .bcm-modal-author {
    margin: 0;
    font-size: 14px;
    opacity: 0.85;
}

.bcm-modal-close {
    flex: 0 0 auto;
    background: rgba(255, 255, 255, 0.18);
    border: none;
    font-size: 22px;
    line-height: 1;
    color: #fff;
    cursor: pointer;
    padding: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.bcm-modal-close:hover {
    background: rgba(255, 255, 255, 0.32);
    transform: rotate(90deg);
}

.bcm-modal-body {
    padding: 26px 28px 30px;
    display: grid;
    grid-template-columns: minmax(0, 180px) 1fr;
    gap: 26px;
}

.bcm-modal-image {
    width: 100%;
}

.bcm-modal-image img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.bcm-modal-image-placeholder {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 12px;
    background: linear-gradient(135deg, #ede9fe, #e0e7ff);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a5b4fc;
}

.bcm-modal-details {
    min-width: 0;
}

.bcm-modal-description {
    margin: 0 0 20px;
    font-size: 14px;
    line-height: 1.6;
    color: #374151;
    white-space: pre-line;
}

.bcm-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px 20px;
}

.bcm-detail-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0;
    border: none;
}

.bcm-detail-label {
    font-weight: 600;
    color: #9ca3af;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.bcm-detail-value {
    color: var(--bcm-ink);
    font-size: 14px;
}

.bcm-status-badge {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: inline-block;
    width: fit-content;
}

.bcm-status-badge.available,
.bcm-card-status.available {
    background-color: #d1fae5;
    color: #065f46;
}

.bcm-status-badge.not-available,
.bcm-card-status.not-available {
    background-color: #fee2e2;
    color: #991b1b;
}

.bcm-status-badge.archived,
.bcm-card-status.archived {
    background-color: #e5e7eb;
    color: #374151;
}

/* ---------- Responsive ---------- */

@media screen and (max-width: 768px) {
    .bcm-frontend-container {
        padding: 20px 14px 40px;
    }

    .bcm-hero {
        padding: 28px 20px 22px;
    }

    .bcm-hero-title {
        font-size: 22px;
    }

    .bcm-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 14px;
    }

    .bcm-modal-body {
        grid-template-columns: 1fr;
    }

    .bcm-modal-image {
        max-width: 160px;
        margin: 0 auto;
    }
}

@media screen and (max-width: 480px) {
    .bcm-grid.bcm-view-list .bcm-card-body {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .bcm-grid.bcm-view-list .bcm-card-heading {
        width: 100%;
    }

    .bcm-grid.bcm-view-list .bcm-card-info {
        width: 100%;
        grid-template-columns: 1fr 1fr;
    }
}
