@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

:root {
    --bg-color: #0d1117;
    --text-color: #e6edf3;
    --primary: #58a6ff;
    --primary-hover: #1f6feb;
    --accent: #bc8cff;
    --card-bg: rgba(22, 27, 34, 0.6);
    --border: rgba(48, 54, 61, 0.8);
    --glass-border: rgba(255, 255, 255, 0.1);
    --radius: 12px;
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,0.2) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,0.15) 0, transparent 50%);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Glassmorphic Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.glass-panel:hover {
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-2px);
}

/* Typography */
h1, h2, h3 {
    margin-bottom: 1rem;
    font-weight: 700;
}

h1 {
    font-size: 2.5rem;
    background: linear-gradient(to right, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
}

/* Navbar */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #58a6ff, #3fb950);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links a {
    margin-left: 1.5rem;
    font-weight: 600;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #8b949e;
}

input[type="text"],
input[type="password"],
input[type="file"],
textarea, select {
    width: 100%;
    padding: 0.8rem 1rem;
    background: #010409;
    border: 1px solid var(--border);
    color: var(--text-color);
    border-radius: 6px;
    font-family: inherit;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.3);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.8rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #3b82f6);
    color: #fff;
    box-shadow: 0 4px 14px 0 rgba(88, 166, 255, 0.39);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), #2563eb);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(88, 166, 255, 0.5);
    color: #fff;
}

.btn-block {
    width: 100%;
}

/* Book Grid */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.book-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(88, 166, 255, 0.2);
    border-color: rgba(88, 166, 255, 0.5);
}

.book-cover {
    width: 100%;
    height: 300px;
    object-fit: cover;
    border-bottom: 1px solid var(--border);
}

.book-info {
    padding: 1.2rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.book-title {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.book-author {
    font-size: 0.9rem;
    color: #8b949e;
    margin-bottom: 1rem;
}

.book-actions {
    margin-top: auto;
}

/* Utility */
.text-center { text-align: center; }
.mt-2 { margin-top: 2rem; }
.mb-2 { margin-bottom: 2rem; }
.alert { padding: 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alert-error { background: rgba(248, 81, 73, 0.1); border: 1px solid rgba(248, 81, 73, 0.4); color: #ff7b72; }
.alert-success { background: rgba(46, 160, 67, 0.1); border: 1px solid rgba(46, 160, 67, 0.4); color: #3fb950; }

/* Tabs Layout for Admin book detail */
.tabs-container {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.tab-btn {
    background: transparent;
    color: var(--text-color);
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: rgba(255,255,255,0.05);
}

.tab-btn.active {
    border-bottom-color: var(--primary);
    color: var(--primary);
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s;
}

.tab-content.active {
    display: block;
}

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

/* Full Page Reader Styles */
.reader-container {
    position: fixed;
    top: 60px; /* Below navbar */
    left: 0;
    right: 0;
    bottom: 0;
    background: #000; /* Dark backdrop for focus */
    display: flex;
    flex-direction: column;
    z-index: 90;
    overflow: hidden;
    user-select: none; /* Disable text selection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.reader-header {
    background: rgba(13, 17, 23, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
}

.reader-viewport {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
    background: radial-gradient(circle, #1a1f26 0%, #0d1117 100%);
}

.reader-footer {
    background: rgba(13, 17, 23, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    padding: 0.8rem 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.flipbook-wrapper {
    position: relative;
    box-shadow: 0 30px 60px rgba(0,0,0,0.8);
    transition: transform 0.3s ease;
}

/* Turn.js overrides for better looks */
.flipbook .page {
    background-color: #fdfdfd;
    box-shadow: inset 0 0 100px rgba(0,0,0,0.05);
    position: relative; /* For absolutely positioned page numbers */
}

.page-content {
    padding: 3rem 3rem 4rem 3rem; /* Extra bottom padding for page number */
    color: #1a1f26; /* Default color, can be overridden by inline style */
    height: 100%;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.1) transparent;
}



.page-content::-webkit-scrollbar {
    width: 8px; /* Slightly wider */
}

.page-content::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.02); /* Very subtle track */
}

.page-content::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.2); /* More prominent thumb */
    border-radius: 10px;
    border: 2px solid #fdfdfd; /* Gap between thumb and edge */
}

.page-content::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0,0,0,0.4); /* Darker on hover */
}



.flipbook .page-content h2, .scroll-content h2, .swipe-content h2 {
    color: #000 !important; /* Pure black */
    font-weight: 700 !important; /* Bold */
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.page-number {
    position: absolute;
    bottom: 20px;
    width: 100%;
    text-align: center;
    font-size: 0.8rem;
    color: #888;
    pointer-events: none;
}

/* Page shadow effect */
.flipbook .shadow {
    box-shadow: 0 0 20px rgba(0,0,0,0.5) !important;
}

/* Mode Scroll */
.reader-viewport.scroll-mode {
    display: block;
    overflow-y: auto;
    padding: 2rem;
    scrollbar-width: thin;
}

.scroll-mode .flipbook-wrapper {
    display: none; /* Hide turn.js container */
}

.scroll-mode .scroll-content {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.scroll-mode .page {
    position: relative;
    width: 100%;
    min-height: 500px;
    background: #fdfdfd;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 0;
    overflow: visible; /* Let it grow */
}

.scroll-mode .page-content {
    overflow-y: visible; /* No internal scroll for scroll mode */
    height: auto;
}

/* Mode Swipe */
.reader-viewport.swipe-mode {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 0; 
    gap: 0;
    /* Use padding to align start/end */
    scroll-padding: 0; 
}




.swipe-mode .flipbook-wrapper {
    display: none;
}

.swipe-mode .swipe-content {
    display: flex;
    height: 100%;
    align-items: center;
}

.swipe-mode .page {
    scroll-snap-align: center;
    width: 100% !important; /* Take full viewport width so neighbors are hidden */
    min-width: 100% !important;
    margin: 0 !important;
    height: 100%;
    flex-shrink: 0;
    background: transparent; /* Background of the viewport will show around the card */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s;
}

.swipe-mode .page-content {
    background: #fdfdfd;
    width: 600px; /* Constrain text width on desktop */
    max-width: 95vw;
    height: 90%; /* Larger height on desktop */
    margin: 0 auto;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    overflow-y: auto; /* Vertically scrollable */
    padding: 3rem 3rem 5rem 3rem; 
    position: relative;
    /* Ensure scrollbar is always ready */
    scrollbar-gutter: stable;
}





.swipe-mode .swipe-content {
    display: flex;
    height: 100%;
    align-items: center;
    width: 100%; /* Ensure container is full but children are constrained on desktop */
}

/* Scroll Mode like PDF */
.scroll-mode .scroll-content {
    max-width: 600px; /* Match 1 flip page width on desktop */
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 2rem 0;
}


.scroll-mode .page {
    position: relative;
    width: 100%;
    min-height: auto; /* Let it grow naturally */
    background: #fdfdfd;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    border-radius: 4px;
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.1);
}

.scroll-mode .page-content {
    overflow-y: visible;
    height: auto;
    padding: 4rem 3rem 5rem 3rem; /* Match Swipe mode internal padding */
}



/* Mobile Adjustments */
@media (max-width: 767px) {
    .reader-container {
        top: 0;
        z-index: 1000;
    }

    .reader-header {
        padding: 0.5rem 1rem;
    }

    .reader-header h3 {
        font-size: 1rem;
    }

    .reader-viewport {
        padding: 0 !important; /* No black space around the content on mobile */
    }

    /* No longer hiding Flip mode */
    #reader-mode option[value="flip"] {
        display: block !important;
    }


    /* Shared Page Style for Swipe/Scroll on Mobile */
    .swipe-mode .page {
        width: 100vw !important;
        min-width: 100vw !important;
        margin: 0 !important;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .swipe-mode .page-content {
        width: 100% !important; /* Full width inside page at mobile */
        max-width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
        padding: 3rem 2.5rem 5rem 2.5rem !important;
    }

    .scroll-mode .page {
        width: 100vw !important;
        min-width: 100vw !important;
        margin: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        border: none !important;
    }

    .swipe-mode .swipe-content, .scroll-mode .scroll-content {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        gap: 0 !important;
    }

    .page-content {
        padding: 3rem 2.5rem 5rem 2.5rem; /* Large internal padding for text */
    }


    .reader-footer {
        padding: 0.5rem 1rem;
        gap: 10px;
    }

    .flipbook-wrapper {
        width: 100% !important;
        height: auto !important;
    }
}

/* Responsive Utilities */
.desktop-only { display: inline-flex !important; }
.mobile-only { display: none !important; }

@media (max-width: 767px) {
    .desktop-only { display: none !important; }
    .mobile-only { display: inline-flex !important; }
}

