/* styles.css - Modern, Premium Glassmorphism Theme for Ebook Library */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    /* Color Palette */
    --bg-base: #090d16;
    --bg-surface: rgba(22, 28, 45, 0.75);
    --bg-surface-hover: rgba(30, 41, 59, 0.85);
    --bg-card: rgba(15, 23, 42, 0.6);
    
    --color-primary: #6366f1; /* Indigo */
    --color-secondary: #a855f7; /* Purple */
    --color-accent: #10b981; /* Emerald */
    --color-danger: #ef4444; /* Red */
    
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --gradient-card-placeholder: linear-gradient(135deg, #1e1b4b 0%, #311042 100%);
    --gradient-glow: 0 0 20px rgba(99, 102, 241, 0.4);
    
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #0f172a;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-focus: rgba(99, 102, 241, 0.5);
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.08) 0%, transparent 40%);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

/* Header & Navigation */
header {
    background: rgba(9, 13, 22, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-link {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: var(--font-heading);
}

.logo-icon {
    width: 28px;
    height: 28px;
    fill: var(--color-primary);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.nav-user strong {
    color: var(--text-primary);
}

.badge {
    background: var(--gradient-primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition-smooth);
    border: none;
    outline: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover {
    box-shadow: var(--gradient-glow);
    transform: translateY(-2px);
    opacity: 0.95;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-danger:hover {
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
    transform: translateY(-2px);
}

.btn-icon {
    padding: 0.6rem;
    border-radius: 50%;
}

/* Main Container */
main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
}

/* Glassmorphism Panel */
.panel {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Forms */
.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-smooth);
}

.form-control:focus {
    border-color: var(--border-color-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
    background: rgba(15, 23, 42, 0.8);
}

/* Auth Pages (Centered Panels) */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    padding: 2rem;
}

.auth-panel {
    max-width: 420px;
    width: 100%;
    animation: fadeIn 0.5s ease-out;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-muted);
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Library Controls (Search & Filters) */
.library-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-box input {
    padding-left: 2.75rem;
}

.search-box::before {
    content: "";
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
}

.filter-select {
    min-width: 150px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 14px;
    padding-right: 2.5rem;
    appearance: none;
    cursor: pointer;
}

/* Books Shelf Layout */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 2rem 1.5rem;
}

/* Book Card */
.book-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: var(--transition-smooth);
    overflow: hidden;
}

.book-card:hover {
    transform: translateY(-8px);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3), 0 0 15px rgba(99, 102, 241, 0.1);
}

.book-cover-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 2/3;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 0.75rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.book-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-smooth);
}

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

.book-cover-placeholder {
    width: 100%;
    height: 100%;
    background: var(--gradient-card-placeholder);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.25rem 1rem;
    text-align: center;
    position: relative;
}

.placeholder-logo {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-primary);
}

.placeholder-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 2px 4px rgba(0,0,0,0.6);
}

.placeholder-author {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Format Tag */
.format-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.2rem 0.5rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: var(--radius-sm);
    z-index: 2;
}

.format-badge.epub { border-color: #6366f1; color: #a5b4fc; }
.format-badge.pdf { border-color: #ef4444; color: #fca5a5; }
.format-badge.mobi { border-color: #10b981; color: #6ee7b7; }
.format-badge.azw3 { border-color: #f59e0b; color: #fcd34d; }

.book-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 0.5rem;
}

.book-title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Progress bar inside card */
.card-progress-wrapper {
    background: rgba(255,255,255,0.05);
    height: 4px;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.75rem;
    display: block;
}

.card-progress-bar {
    background: var(--gradient-primary);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

.card-progress-text {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    margin-top: -0.5rem;
    margin-bottom: 0.75rem;
}

.card-progress-percentage {
    color: var(--color-primary);
    font-weight: 600;
}

/* Book Actions Buttons */
.book-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.book-actions .btn {
    padding: 0.5rem;
    font-size: 0.8rem;
}

.book-actions .btn-full {
    grid-column: span 2;
}

/* Admin Dashboard CSS */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
}

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

.dashboard-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

/* Table Style */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.modern-table th, .modern-table td {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.modern-table th {
    background: rgba(15, 23, 42, 0.4);
    font-weight: 600;
    color: var(--text-muted);
}

.modern-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.modern-table img {
    border-radius: 4px;
    object-fit: cover;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 350px;
    width: 100%;
}

.toast {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 4px solid var(--color-primary);
}

.toast.success { border-left-color: var(--color-accent); }
.toast.error { border-left-color: var(--color-danger); }
.toast.info { border-left-color: var(--color-primary); }

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.15rem;
}

.toast-message {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.toast-close {
    cursor: pointer;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
}

.toast-close:hover {
    color: var(--text-primary);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(9, 13, 22, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    padding: 2rem;
    position: relative;
    transform: scale(0.9);
    transition: var(--transition-smooth);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.5rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.modal-close:hover {
    color: var(--text-primary);
}

/* Reader View (read.php specific) */
.reader-body {
    background: #121212;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.reader-header {
    background: #1a1a1a;
    border-bottom: 1px solid #2a2a2a;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.reader-title-area {
    display: flex;
    flex-direction: column;
}

.reader-book-title {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.reader-book-author {
    font-size: 0.75rem;
    color: #aaa;
}

.reader-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.reader-container {
    flex: 1;
    display: flex;
    position: relative;
    height: calc(100vh - 60px);
}

/* Epub reader layout */
#epub-viewer-area {
    flex: 1;
    width: 100%;
    height: 100%;
    background: #181818;
    position: relative;
}

/* Navigation overlays */
.epub-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    font-size: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: var(--transition-smooth);
    opacity: 0;
}

#epub-viewer-area:hover .epub-nav-btn {
    opacity: 1;
}

.epub-nav-btn:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.epub-prev { left: 20px; }
.epub-next { right: 20px; }

/* PDF Canvas layout */
.pdf-reader-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    background: #1e1e1e;
}

#pdf-canvas-container {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    background: white;
    max-width: 100%;
    margin-bottom: 2rem;
}

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

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Settings view styling */
.settings-section {
    margin-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

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