@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;
    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;
    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --primary: 240 5.9% 10%;
    --primary-foreground: 0 0% 98%;
    --accent: 240 4.8% 95.9%;
    --accent-foreground: 240 5.9% 10%;
    --radius: 0.5rem;
}

.satsigne-library-shell {
    font-family: 'Inter', sans-serif;
    color: hsl(var(--foreground));
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    text-align: left;
}

/* 1. Header & Toolbar */
.satsigne-library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 24px;
    border-bottom: 1px solid hsl(var(--border));
    margin-bottom: 32px;
    gap: 20px;
}

.search-container {
    position: relative;
    flex: 1;
    max-width: 400px;
    display: flex;
    align-items: center;
}

.search-container i, .search-container svg {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: hsl(var(--muted-foreground));
    pointer-events: none;
}

.search-container input {
    width: 100%;
    height: 40px;
    padding: 0 12px 0 40px;
    border: 1px solid hsl(var(--input));
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: all 0.2s;
    background: transparent;
}

.search-container input:focus {
    outline: none;
    border-color: hsl(var(--primary));
}

.view-switcher {
    display: flex;
    background: hsl(var(--muted));
    padding: 4px;
    border-radius: var(--radius);
}

.view-btn {
    background: transparent;
    border: none;
    padding: 6px;
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    color: hsl(var(--muted-foreground));
    display: flex;
}

.view-btn.active {
    background: hsl(var(--background));
    color: hsl(var(--primary));
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* 2. Main Layout */
.satsigne-library-main {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 40px;
}

.satsigne-library-main.no-sidebar {
    grid-template-columns: 1fr;
}

/* 3. Sidebar */
.satsigne-library-sidebar h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 16px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: hsl(var(--muted-foreground));
}

.cat-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cat-list li {
    margin-bottom: 4px;
}

.cat-list a {
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    padding: 8px 12px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    text-align: left;
}

.cat-list a:hover, .cat-list a.active {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.cat-list .count {
    font-size: 0.75rem;
    background: hsl(var(--muted));
    padding: 2px 6px;
    border-radius: 999px;
    margin-left: auto; /* Keeps the count on the right, but we can change this to margin-left: 4px if you want it right next to text */
}

/* 4. Books Grid */
.satsigne-continue-banner {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border-radius: 1rem;
    padding: 40px;
    margin-bottom: 40px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.banner-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 40px;
    position: relative;
    z-index: 2;
}

.banner-left { flex: 1; }
.banner-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: #38bdf8; margin-bottom: 12px; }
.banner-left h2 { font-size: 2.25rem; font-weight: 800; margin: 0 0 8px; letter-spacing: -0.02em; }
.banner-left .author { font-size: 1.125rem; color: #94a3b8; margin-bottom: 24px; }

.banner-progress-wrap { margin-bottom: 32px; max-width: 400px; }
.progress-text { font-size: 0.875rem; color: #94a3b8; margin-bottom: 8px; }
.progress-text span { color: #fff; font-weight: 700; }
.banner-progress-wrap .satsigne-progress-container { background: rgba(255,255,255,0.1); height: 8px; }
.banner-progress-wrap .satsigne-progress-fill { background: #38bdf8; }

.banner-right { width: 180px; flex-shrink: 0; }
.banner-right img { width: 100%; border-radius: 0.5rem; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.3); transform: rotate(5deg); transition: transform 0.3s ease; }
.satsigne-continue-banner:hover .banner-right img { transform: rotate(0deg) scale(1.05); }

@media (max-width: 768px) {
    .banner-content { flex-direction: column; text-align: center; gap: 32px; }
    .banner-right { order: -1; width: 140px; }
    .banner-left h2 { font-size: 1.75rem; }
    .banner-progress-wrap { margin-left: auto; margin-right: auto; }
}

.satsigne-library-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 32px;
}

@media (min-width: 768px) {
    .satsigne-library-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1200px) {
    .satsigne-library-grid { grid-template-columns: repeat(3, 1fr); }
}

.satsigne-book-card {
    border: 1px solid hsl(var(--border));
    background: hsl(var(--background));
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.satsigne-book-card:hover {
    border-color: hsl(var(--primary) / 0.2);
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -10px rgba(0,0,0,0.1);
}

.satsigne-book-cover {
    height: 360px;
    background-size: cover;
    background-position: center;
    position: relative;
    border-bottom: 1px solid hsl(var(--border));
    overflow: hidden;
}

.cover-actions {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 5;
}

.satsigne-book-cover:hover .cover-actions {
    opacity: 1;
}

.quick-view-btn {
    background: #fff;
    color: #0f172a;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.satsigne-book-cover:hover .quick-view-btn {
    transform: translateY(0);
}

.satsigne-locked-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.scn-btn i, .scn-btn svg {
    width: 18px !important;
    height: 18px !important;
    stroke-width: 2px;
    display: inline-block;
    flex-shrink: 0;
}

.view-btn i, .view-btn svg {
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0;
}

/* Modal Styles */
.satsigne-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.satsigne-modal.active { display: flex; }

.satsigne-modal-content {
    background: #fff;
    width: 90%;
    max-width: 900px;
    border-radius: 1rem;
    position: relative;
    overflow: hidden;
    animation: modalSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.close-modal {
    position: absolute;
    top: 20px; right: 20px;
    background: #f1f5f9;
    border: none;
    width: 32px; height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    color: #0f172a;
    transition: background 0.2s;
}

.close-modal:hover {
    background: #e2e8f0;
}

.modal-body { display: flex; }

.modal-left { width: 40%; background: #f8fafc; padding: 40px; display: flex; align-items: center; justify-content: center; }
.modal-left img { width: 100%; border-radius: 0.5rem; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); }

.modal-right { width: 60%; padding: 40px; display: flex; flex-direction: column; }
.modal-right h2 { font-size: 2rem; margin: 0 0 8px; font-weight: 700; color: #0f172a; }
.modal-author { font-size: 1.125rem; color: #64748b; margin: 0 0 24px; }
.modal-description { font-size: 1rem; color: #334155; line-height: 1.6; margin-bottom: 32px; flex-grow: 1; }
.modal-actions { display: flex; gap: 16px; }
.modal-actions .scn-btn { width: auto; min-width: 150px; }

/* Modal Preview Styling */
.satsigne-modal-preview {
    margin-top: 24px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    padding: 0;
}

.preview-header {
    padding: 16px 40px;
    font-size: 0.875rem;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.preview-canvas-list {
    max-height: 500px;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

.preview-page-wrapper {
    background: #fff;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    width: fit-content;
}

.preview-page-wrapper canvas, .preview-img {
    max-width: 100%;
    height: auto !important;
    display: block;
}

.preview-img {
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    border-radius: 2px;
}

.preview-page-wrapper .page-label {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    margin-top: 8px;
    text-transform: uppercase;
}

.preview-placeholder, .preview-error {
    padding: 40px;
    color: #64748b;
    font-size: 0.875rem;
    font-weight: 500;
}

.preview-error { color: #ef4444; }

@media (max-width: 768px) {
    .preview-canvas-list { max-height: 400px; padding: 16px; }
}

.satsigne-book-info {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-grow: 1;
}

.info-top h3 {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0 0 4px;
    letter-spacing: -0.02em;
}

.info-top .author {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    margin: 0;
}

.reading-meta {
    display: flex;
    gap: 12px;
}

.meta-item {
    font-size: 0.75rem;
    font-weight: 600;
    color: hsl(var(--muted-foreground));
    display: flex;
    align-items: center;
    gap: 4px;
}

.meta-item i { width: 14px; height: 14px; }
.meta-item.locked { color: #f59e0b; }

.satsigne-progress-container {
    height: 6px;
    background: hsl(var(--muted));
    border-radius: 999px;
    overflow: hidden;
}

.satsigne-progress-fill {
    height: 100%;
    background: hsl(var(--primary));
}

.scn-btn-primary, .scn-btn-outline {
    height: 42px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: var(--radius);
    font-size: 13px; /* Slightly smaller for better fit */
    font-weight: 600;
    text-decoration: none !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    box-sizing: border-box;
    white-space: nowrap;
    cursor: pointer;
}

/* List View Styles */
.list-view {
    display: flex !important;
    flex-direction: column !important;
    gap: 20px !important;
}

.list-view .satsigne-book-card {
    flex-direction: row;
    height: 180px;
    align-items: stretch;
}

.list-view .satsigne-book-cover {
    width: 130px;
    height: 100%;
    flex-shrink: 0;
    border-bottom: none;
    border-right: 1px solid hsl(var(--border));
}

.list-view .satsigne-book-info {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    padding: 24px 32px;
}

.list-view .info-top { width: 40%; }
.list-view .reading-meta { width: 20%; flex-direction: column; gap: 4px; }
.list-view .satsigne-progress-container { display: none; } /* Hide in list for cleanliness */
.list-view .scn-btn-primary, .list-view .satsigne-locked-actions { width: 180px; }

.scn-btn-primary {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground)) !important;
    border: 1px solid hsl(var(--primary));
}

.scn-btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.scn-btn-outline {
    border: 1px solid hsl(var(--border));
    color: hsl(var(--foreground)) !important;
    background: transparent;
}

.scn-btn-outline:hover {
    background: hsl(var(--accent));
    border-color: hsl(var(--border));
}

.satsigne-locked-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.modal-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.modal-actions .scn-btn-primary, 
.modal-actions .scn-btn-outline {
    flex: 1;
    width: auto;
}

/* Badges */
.completed-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #10b981;
    color: #fff;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
}

.lock-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.lock-overlay i { width: 40px; height: 40px; color: hsl(var(--primary)); }

/* 5. Empty State Refinement */
.satsigne-empty-library {
    padding: 80px 40px;
    text-align: center;
    background: #fff;
    border: 2px dashed hsl(var(--border));
    border-radius: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.satsigne-empty-library i, .satsigne-empty-library svg {
    width: 64px;
    height: 64px;
    color: hsl(var(--muted-foreground));
    opacity: 0.5;
}

.satsigne-empty-library p {
    font-size: 1.125rem;
    font-weight: 600;
    color: hsl(var(--muted-foreground));
    margin: 0;
}

/* 6. Responsiveness */
@media (max-width: 1024px) {
    .satsigne-library-main { grid-template-columns: 200px 1fr; gap: 20px; }
}

@media (max-width: 768px) {
    .satsigne-library-main { grid-template-columns: 1fr; }
    .satsigne-library-sidebar { display: none; } /* On mobile we might want a drawer, but for now we hide it */
    .satsigne-library-header { flex-direction: column; align-items: stretch; }
    .search-container { max-width: none; }
}

@media (max-width: 480px) {
    .satsigne-library-grid { grid-template-columns: 1fr; }
    .list-view .satsigne-book-card { flex-direction: column; height: auto; }
    .list-view .satsigne-book-cover { width: 100%; height: 250px; border-right: none; border-bottom: 1px solid hsl(var(--border)); }
}
