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

:root {
    --bg-dark: #f8fafc; /* Sleek light slate */
    --bg-card: rgba(255, 255, 255, 0.85); /* Clean card transparency */
    --border-color: rgba(30, 41, 59, 0.08); /* Very clean slate border */
    --accent-purple: #2563eb; /* Vibrant Royal Blue */
    --accent-blue: #0ea5e9; /* Vivid Sky Blue */
    --accent-orange: #ff6b35; /* Premium Coral Orange */
    --text-main: #0f172a; /* Slate 900 for high-contrast reading */
    --text-muted: #64748b; /* Slate 500 for clean captions */
    --glass-blur: blur(25px);
    --transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    --box-shadow-premium: 0 30px 60px -15px rgba(15, 23, 42, 0.18), 0 10px 30px -10px rgba(15, 23, 42, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.05) 0%, transparent 35%),
        radial-gradient(circle at 100% 100%, rgba(249, 115, 22, 0.05) 0%, transparent 35%);
    background-attachment: fixed;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.02);
}
::-webkit-scrollbar-thumb {
    background: rgba(124, 58, 237, 0.2);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(124, 58, 237, 0.4);
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 20px;
    box-shadow: var(--box-shadow-premium);
}

.glass-card {
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    padding: 24px;
    transition: var(--transition);
    box-shadow: 0 10px 20px -10px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
}

.glass-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-purple);
    box-shadow: 0 20px 30px -10px rgba(37, 99, 235, 0.12);
}

/* Header / Navigation */
header {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 5%;
}

.logo {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-main);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo span {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 5px;
    border-left: 1px solid rgba(0, 0, 0, 0.15);
    padding-left: 8px;
}

.nav-links {
    display: flex;
    gap: 20px;
    align-items: center;
    list-style: none;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: var(--transition);
}

.nav-links a:hover, .nav-links a.active {
    color: var(--text-main);
}

.user-badge {
    background: rgba(124, 58, 237, 0.08);
    border: 1px solid rgba(124, 58, 237, 0.2);
    color: #7c3aed;
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.credits-pill {
    background: rgba(234, 88, 12, 0.08);
    border: 1px solid rgba(234, 88, 12, 0.25);
    color: #ea580c;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 700;
}

/* Layout container */
.container {
    width: 100%;
    max-width: 100%;
    margin: 40px auto;
    padding: 0 5%;
}

/* Auth Pages */
.auth-wrapper {
    min-height: 80vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.auth-card {
    width: 100%;
    max-width: 450px;
    padding: 40px;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 14px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text-main);
    font-size: 14.5px;
    transition: var(--transition);
    outline: none;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.01);
}

.form-control:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

select.form-control option {
    background-color: #ffffff;
    color: var(--text-main);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    outline: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
    color: white;
    box-shadow: 0 10px 20px -10px rgba(37, 99, 235, 0.5), 0 4px 8px -2px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px -8px rgba(37, 99, 235, 0.6), 0 4px 12px -2px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--text-main);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
    box-shadow: 0 10px 20px -10px rgba(15, 23, 42, 0.12);
}

.btn-orange {
    background: linear-gradient(135deg, #ff6b35 0%, #f97316 100%);
    color: white;
    box-shadow: 0 10px 20px -10px rgba(255, 107, 53, 0.5), 0 4px 8px -2px rgba(255, 107, 53, 0.25);
}

.btn-orange:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px -8px rgba(255, 107, 53, 0.6), 0 4px 12px -2px rgba(255, 107, 53, 0.3);
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    transform: none !important;
    box-shadow: none !important;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #065f46;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #991b1b;
}

/* Dashboard / Grid Layouts */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 3fr;
    gap: 30px;
}

@media (max-width: 900px) {
    .dash-grid {
        grid-template-columns: 1fr;
    }
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.stat-card h3 {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-main);
}

.stat-card .icon-bg {
    position: absolute;
    right: -20px;
    bottom: -20px;
    font-size: 90px;
    opacity: 0.04;
}

/* Books Grid & Cards */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.book-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.book-cover-wrapper {
    position: relative;
    padding-top: 135%;
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(0,0,0,0.02), rgba(0,0,0,0.01));
    border: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.book-cover-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
    background: linear-gradient(135deg, #f5f3ff 0%, #e0e7ff 100%);
    border-radius: 8px;
    overflow: hidden;
}

/* Spine effect for a realistic book look */
.book-cover-placeholder::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 12px;
    height: 100%;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.12) 0%, rgba(0, 0, 0, 0.01) 80%);
    z-index: 5;
}

/* Glossy reflection effect */
.book-cover-placeholder::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0) 50%);
    z-index: 4;
}

.book-cover-placeholder i {
    font-size: 44px;
    color: var(--accent-purple);
    margin-bottom: 15px;
    z-index: 6;
    filter: drop-shadow(0 4px 6px rgba(124, 58, 237, 0.15));
}

.book-cover-placeholder .book-title {
    font-weight: 800;
    font-size: 15px;
    line-height: 1.4;
    color: var(--text-main);
    z-index: 6;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.book-card-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.book-card h4 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 5px;
    line-height: 1.4;
}

.book-card .author {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 12px;
}

.book-card .meta-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.pill {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    color: var(--text-muted);
}

.pill-orange {
    background: rgba(234, 88, 12, 0.08);
    border: 1px solid rgba(234, 88, 12, 0.15);
    color: #ea580c;
}

/* Detail Book Page */
.book-detail-wrapper {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 40px;
}

@media (max-width: 768px) {
    .book-detail-wrapper {
        grid-template-columns: 1fr;
    }
}

.book-detail-cover {
    width: 100%;
    aspect-ratio: 1/1.4;
    border-radius: 12px;
    background: linear-gradient(45deg, #eff6ff, #fdf4ff);
    border: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 30px;
}

.book-detail-cover h2 {
    font-size: 24px;
    margin-bottom: 10px;
}

.purchase-options-box {
    margin-top: 20px;
    padding: 24px;
    background: rgba(124, 58, 237, 0.03);
    border: 1px solid rgba(124, 58, 237, 0.12);
    border-radius: 12px;
}

.purchase-option-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.purchase-option-row:last-child {
    border-bottom: none;
}

.page-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.page-item-box {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    transition: var(--transition);
}

.page-item-box.unlocked {
    border-color: rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.04);
}

.page-item-box .status-text {
    font-size: 11px;
    margin-top: 8px;
}

/* Secure Book Reader Interface */
.reader-container {
    display: grid;
    grid-template-columns: 280px 1fr 350px;
    height: calc(100vh - 65px);
    overflow: hidden;
}

@media (max-width: 1100px) {
    .reader-container {
        grid-template-columns: 200px 1fr;
    }
    .reader-sidebar-ai {
        display: none;
    }
}

@media (max-width: 768px) {
    .reader-container {
        grid-template-columns: 1fr;
    }
    .reader-sidebar-pages {
        display: none;
    }
}

.reader-sidebar {
    background: rgba(255, 255, 255, 0.95);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.reader-sidebar-ai {
    background: rgba(255, 255, 255, 0.95);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.sidebar-title {
    padding: 20px;
    font-size: 16px;
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-list {
    overflow-y: auto;
    flex-grow: 1;
    list-style: none;
}

.sidebar-list li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    transition: var(--transition);
}

.sidebar-list li a:hover, .sidebar-list li.active a {
    background: rgba(124, 58, 237, 0.05);
    color: var(--text-main);
}

.sidebar-list li.active a {
    border-left: 3px solid var(--accent-purple);
}

/* Center Reader Area */
.reader-viewport {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: #e5e7eb; /* Soft visual distinction for the PDF sheet */
}

.reader-toolbar {
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reader-content-canvas {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 30px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.page-image-container {
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    max-width: 100%;
    position: relative;
    user-select: none;
    -webkit-user-drag: none;
}

.page-image-container img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* Anti-copy transparent blocker */
.copy-blocker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    cursor: default;
}

/* Chat Assistant inside reader */
.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    font-size: 13.5px;
    line-height: 1.5;
}

.chat-bubble.ai {
    background: rgba(124, 58, 237, 0.05);
    border: 1px solid rgba(124, 58, 237, 0.12);
    color: var(--text-main);
    align-self: flex-start;
    border-top-left-radius: 2px;
}

.chat-bubble.user {
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.12);
    color: var(--text-main);
    align-self: flex-end;
    border-top-right-radius: 2px;
}

.chat-sources {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.source-badge {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.08);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.source-badge:hover {
    background: rgba(124, 58, 237, 0.12);
    color: var(--accent-purple);
}

.chat-input-area {
    padding: 15px;
    border-top: 1px solid var(--border-color);
    background: #ffffff;
    display: flex;
    gap: 10px;
}

/* Wallet Card Styles */
.wallet-card {
    background: linear-gradient(135deg, #eff6ff 0%, #f5f3ff 100%);
    border: 1px solid rgba(37, 99, 235, 0.15);
    padding: 35px 40px;
    border-radius: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--box-shadow-premium);
}

.wallet-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.1) 0%, transparent 70%);
}

.package-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.package-card {
    text-align: center;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.8);
}

.package-card.selected {
    border-color: var(--accent-orange);
    background: rgba(234, 88, 12, 0.03);
}

/* Typography elements */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--text-main);
}

p {
    color: var(--text-muted);
    line-height: 1.6;
}

/* Search results snippet list */
.snippet-item {
    margin-top: 10px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.01);
    border-radius: 6px;
    border-left: 2px solid var(--accent-purple);
    font-size: 13px;
}
