/* === GLOBAL STYLES === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: #e8ecef;
    color: #1a2632;
    min-height: 100vh;
}

/* === COLOR PALETTE === */
:root {
    --primary: #2563eb;        /* Blue */
    --primary-light: #dbeafe;
    --secondary: #1e293b;      /* Dark slate */
    --accent: #f59e0b;         /* Amber */
    --success: #10b981;
    --danger: #ef4444;
    --bg-light: #ffffff;
    --bg-neutral: #f2f5f9;
    --border: #e0e6ec;
    --text-primary: #1a2632;
    --text-secondary: #617a92;
}

/* === TYPOGRAPHY === */
h1, h2, h3 { font-weight: 600; line-height: 1.2; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }

p, span { line-height: 1.5; }
button, input { font-family: inherit; }

/* === UTILITIES === */
.container {
    max-width: 100%;
    margin: 0 auto;
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

/* === NAVIGATION BAR === */
.nav-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--bg-light);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
    position: sticky;
    top: 0;
    z-index: 100;
}

.menu-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    color: var(--secondary);
    transition: background 0.2s;
    flex-shrink: 0;
}

.menu-btn:hover {
    background-color: var(--bg-neutral);
}

/* Search wrapper */
.search-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background-color: var(--bg-neutral);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    transition: all 0.2s;
}

.search-wrapper:focus-within {
    background-color: var(--bg-light);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1), inset 0 0 0 1px var(--primary);
}

.search-wrapper input {
    border: none;
    background: transparent;
    width: 100%;
    padding: 8px 0;
    font-size: 14px;
    outline: none;
    color: var(--text-primary);
}

.search-wrapper input::placeholder {
    color: var(--text-secondary);
}

/* Dropdown menu */
.dropdown-menu {
    background-color: var(--bg-light);
    padding: 8px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    display: none;
    flex-direction: column;
    position: absolute;
    top: 60px;
    left: 16px;
    width: calc(100% - 32px);
    z-index: 200;
    animation: slideDown 0.2s ease;
}

.dropdown-menu.show {
    display: flex;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-menu a {
    padding: 16px 20px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 15px;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.dropdown-menu a:last-child {
    border-bottom: none;
}

.dropdown-menu a:hover {
    background-color: var(--bg-neutral);
}

.dropdown-menu a:active {
    background-color: var(--primary-light);
}

/* === SECTION HEADER === */
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 24px 16px 12px 16px;
}

.section-head h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.section-head span {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* === BOOK GRID === */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 0 16px 24px 16px;
}

.book-card {
    background: var(--bg-light);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.15s, box-shadow 0.2s;
    cursor: pointer;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.12);
}

.book-img {
    width: 100%;
    aspect-ratio: 2 / 3;
    background-color: var(--bg-neutral);
    object-fit: cover;
    display: block;
}

.book-name {
    padding: 10px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.3;
    border-top: 1px solid var(--border);
    word-break: break-word;
}

/* === MODAL === */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 300;
    animation: fadeIn 0.2s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.fullscreen {
    background-color: rgba(0, 0, 0, 0.8);
}

.modal.fullscreen .modal-content {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    animation: slideInFull 0.3s ease;
    background: #000;
    flex-direction: column;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInFull {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--bg-light);
    border-radius: 12px;
    width: 95%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
}

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

/* Modal header */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-light);
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    flex: 1;
    padding-left: 12px;
}

.modal-header .back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-primary);
    border-radius: 6px;
    transition: all 0.2s;
    margin-right: 8px;
}

.modal-header .back-btn:hover {
    background-color: var(--bg-neutral);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

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

/* Modal body */
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal.fullscreen .modal-body {
    padding: 30px;
    background: var(--bg-light);
}

/* Modal scrollbar styling */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: var(--bg-neutral);
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* PDF Fullscreen Viewer */
.pdf-viewer-fullscreen {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background: #000;
}

.pdf-header {
    padding: 12px 16px;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

.pdf-header .back-btn {
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #fff;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-header .back-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.pdf-container {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #000;
}

.pdf-container canvas {
    max-width: 100%;
    height: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.pdf-footer {
    padding: 16px;
    background: #1a1a1a;
    border-top: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-shrink: 0;
}

.pdf-page-info {
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    min-width: 70px;
    text-align: center;
}

.book-detail {
    display: flex;
    gap: 16px;
}

.book-cover-container {
    flex-shrink: 0;
}

.book-cover {
    width: 120px;
    height: 180px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-neutral);
}

.book-info {
    flex: 1;
}

.book-info h2 {
    margin-bottom: 4px;
}

.book-author {
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 12px;
}

.book-description {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* PDF Viewer */
.pdf-viewer {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    display: flex;
    flex-direction: column;
}

.pdf-viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--bg-neutral);
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.pdf-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pdf-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.pdf-btn:hover:not(:disabled) {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

.pdf-btn:disabled {
    background: #9ca3af;
    color: #fff;
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.pdf-btn i {
    font-size: 16px;
}

.pdf-page-info {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: center;
}

#pdf-canvas {
    max-width: 100%;
    display: block;
    margin: 0 auto;
}

/* === FORMS === */
.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-primary);
    font-size: 14px;
}

input[type="text"],
input[type="email"],
input[type="file"],
textarea,
select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s;
    color: var(--text-primary);
    background: var(--bg-light);
}

input[type="text"]::placeholder,
input[type="email"]::placeholder,
textarea::placeholder {
    color: var(--text-secondary);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="file"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1), inset 0 0 0 1px var(--primary);
}

textarea {
    resize: vertical;
    min-height: 110px;
    font-family: inherit;
    line-height: 1.5;
}

input[type="file"] {
    padding: 10px;
    cursor: pointer;
}

input[type="file"]::file-selector-button {
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
    margin-right: 12px;
}

input[type="file"]::file-selector-button:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

/* Enhanced File Input Styling */
.file-input-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

.file-input-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 20px 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #dbeafe 100%);
    border: 2px solid var(--primary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--primary);
    font-weight: 600;
    font-size: 15px;
    pointer-events: none;
    position: relative;
}

.file-input-label::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(90deg, rgba(37, 99, 235, 0), rgba(37, 99, 235, 0.1), rgba(37, 99, 235, 0));
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.file-input-wrapper:hover .file-input-label {
    border-color: #1d4ed8;
    background: linear-gradient(135deg, #e0f2fe 0%, #bfdbfe 100%);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.file-input-wrapper:hover .file-input-label::before {
    opacity: 1;
}

.file-input-label i {
    font-size: 20px;
    color: var(--primary);
    min-width: 24px;
    transition: transform 0.3s ease;
}

.file-input-wrapper:hover .file-input-label i {
    transform: scale(1.15);
}

/* === BUTTONS === */
.btn {
    padding: 11px 22px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.btn:active {
    transform: scale(0.98);
}

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

.btn-primary:hover {
    background-color: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background-color: var(--bg-neutral);
    color: var(--text-primary);
    border: 1.5px solid var(--border);
}

.btn-secondary:hover {
    background-color: var(--border);
    border-color: #cbd5e1;
}

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

.btn-danger:hover {
    background-color: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(239, 68, 68, 0.3);
}

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

.btn-success:hover {
    background-color: #059669;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(16, 185, 129, 0.3);
}

.btn-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 28px;
}

.btn-group .btn {
    flex: 1;
    min-width: 120px;
}

/* === ADMIN PANEL === */
.admin-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px 16px;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.admin-form {
    background: var(--bg-light);
    padding: 28px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 32px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.admin-form h2 {
    margin-bottom: 24px;
    font-size: 20px;
    color: var(--text-primary);
}

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

.admin-form .form-group {
    margin-bottom: 20px;
}

.admin-form small {
    display: block;
    color: var(--text-secondary);
    margin-top: 6px;
    font-size: 12px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

.books-table {
    background: var(--bg-light);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    width: 100%;
    border-collapse: collapse;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.books-table thead {
    background: linear-gradient(135deg, var(--bg-neutral) 0%, var(--primary-light) 100%);
    border-bottom: 2px solid var(--border);
}

.books-table th {
    padding: 16px;
    text-align: left;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.books-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-primary);
}

.books-table tbody tr {
    transition: background 0.2s ease;
}

.books-table tbody tr:hover {
    background-color: var(--primary-light);
}

.books-table tbody tr:last-child td {
    border-bottom: none;
}

.table-actions {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.alert {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-info {
    background-color: #dbeafe;
    color: #0c4a6e;
    border: 1px solid #7dd3fc;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .nav-bar {
        gap: 8px;
        padding: 8px 12px;
    }

    .section-head {
        margin: 16px 12px 8px 12px;
    }

    .book-grid {
        padding: 0 12px 16px 12px;
        gap: 10px;
    }

    .book-name {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .admin-form {
        padding: 16px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .book-detail {
        flex-direction: column;
    }

    .book-cover {
        width: 100%;
        height: auto;
    }
}
