/* CSS Reset & Variables */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.01em;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-dark) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

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

.btn-secondary:hover {
    background: var(--border);
    border-color: var(--text-light);
}

.btn-search {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 16px 32px;
    font-size: 1rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.btn-search:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
}

/* Auth Section */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
}

.auth-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    animation: pulse 15s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.auth-card {
    background: var(--bg-card);
    padding: 48px 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
}

.logo {
    text-align: center;
    margin-bottom: 36px;
}

.logo h1 {
    font-size: 2.2rem;
    color: var(--primary);
    font-weight: 700;
}

.logo p {
    color: var(--text-light);
    margin-top: 8px;
    font-size: 1rem;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 28px;
    background: var(--bg);
    padding: 6px;
    border-radius: var(--radius-sm);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    border-radius: var(--radius-xs);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-light);
    transition: var(--transition);
}

.tab-btn.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: var(--shadow);
}

.tab-btn:hover:not(.active) {
    color: var(--text);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    margin-bottom: 22px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-group .hint {
    display: block;
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.auth-form .btn {
    width: 100%;
    margin-top: 12px;
    padding: 14px 24px;
}

.error-message {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 16px;
    text-align: center;
    padding: 10px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--radius-xs);
}

.success-message {
    color: var(--success);
    font-size: 0.875rem;
    margin-top: 16px;
    text-align: center;
    padding: 10px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: var(--radius-xs);
}

/* Search Section */
.search-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--bg) 0%, #e2e8f0 100%);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 40px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header h1 {
    font-size: 1.4rem;
    color: var(--primary);
    font-weight: 700;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

#user-email {
    color: var(--text-light);
    font-size: 0.875rem;
    padding: 8px 16px;
    background: var(--bg);
    border-radius: var(--radius-xs);
}

.main-content {
    flex: 1;
    padding: 48px 40px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Search Box */
.search-box {
    margin-bottom: 48px;
}

.search-input-wrapper {
    display: flex;
    gap: 12px;
    background: var(--bg-card);
    padding: 10px 12px 10px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 2px solid transparent;
    transition: var(--transition);
}

.search-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: var(--shadow-xl), 0 0 0 4px rgba(79, 70, 229, 0.1);
}

#search-input {
    flex: 1;
    padding: 14px 0;
    border: none;
    font-size: 1.1rem;
    background: transparent;
    color: var(--text);
}

#search-input:focus {
    outline: none;
}

#search-input::placeholder {
    color: var(--text-muted);
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 80px;
}

.spinner {
    width: 52px;
    height: 52px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    color: var(--text-light);
    font-size: 1rem;
    font-weight: 500;
}

/* Results */
.results-section {
    margin-top: 20px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.results-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

#results-count {
    color: var(--text-light);
    font-size: 0.9rem;
    background: var(--bg);
    padding: 8px 16px;
    border-radius: var(--radius-xs);
}

.results-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Book Card - List Style */
.book-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    border: 1px solid transparent;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.book-image-container {
    flex-shrink: 0;
    width: 140px;
    min-height: 180px;
    background: linear-gradient(135deg, var(--bg) 0%, var(--border) 100%);
    position: relative;
    overflow: hidden;
}

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

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

.book-image.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--text-muted);
    background: linear-gradient(135deg, #f0f4f8 0%, #e2e8f0 100%);
    height: 100%;
}

.book-content {
    padding: 20px 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.book-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 10px;
}

.book-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

.book-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.book-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 10px;
}

.book-author {
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 600;
}

.book-publisher {
    color: var(--text-light);
    font-size: 0.85rem;
    font-weight: 500;
}

.book-category {
    display: inline-block;
    background: linear-gradient(135deg, var(--bg) 0%, var(--border-light) 100%);
    color: var(--text-light);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 20px;
    margin-right: 8px;
}

.book-description {
    color: var(--text-light);
    font-size: 0.875rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 10px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-top: 48px;
    padding: 24px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

.pagination-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.pagination-btn:disabled {
    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

.pagination-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#page-info {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    padding: 10px 20px;
    background: var(--bg);
    border-radius: var(--radius-xs);
}

/* No Results */
.no-results {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-light);
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.no-results-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.no-results h3 {
    font-size: 1.4rem;
    color: var(--text);
    margin-bottom: 12px;
}

.no-results p {
    font-size: 1rem;
    margin-bottom: 4px;
}

.no-results .hint {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
    backdrop-filter: blur(8px);
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    max-width: 720px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg);
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    transition: var(--transition);
    z-index: 10;
}

.modal-close:hover {
    background: var(--danger);
    color: white;
    transform: rotate(90deg);
}

#modal-body {
    padding: 36px;
}

.modal-image {
    width: 100%;
    max-height: 320px;
    object-fit: contain;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 28px;
}

.modal-title {
    font-size: 1.6rem;
    margin-bottom: 20px;
    color: var(--text);
    font-weight: 700;
}

.modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 24px;
}

.modal-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.modal-meta-item .label {
    color: var(--text-light);
    font-weight: 500;
}

.modal-meta-item .value {
    font-weight: 600;
    color: var(--text);
}

.modal-category {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    font-size: 0.875rem;
    padding: 10px 20px;
    border-radius: 24px;
    margin-bottom: 24px;
    font-weight: 600;
}

.modal-description {
    color: var(--text);
    line-height: 1.8;
    font-size: 1rem;
}

.modal-description h4 {
    margin-bottom: 16px;
    color: var(--text);
    font-weight: 700;
    font-size: 1.1rem;
}

/* Footer */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 20px 40px;
    text-align: center;
}

.footer p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
        padding: 16px 20px;
    }
    
    .header-right {
        flex-direction: column;
        gap: 12px;
    }
    
    .search-input-wrapper {
        flex-direction: column;
        padding: 12px;
    }
    
    .btn-search {
        width: 100%;
    }
    
    .book-card {
        flex-direction: column;
    }
    
    .book-image-container {
        width: 100%;
        height: 200px;
        min-height: auto;
    }
    
    .main-content {
        padding: 24px 16px;
    }
    
    .auth-card {
        padding: 28px 20px;
    }
    
    .results-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .pagination {
        flex-direction: column;
        gap: 16px;
        padding: 20px;
    }
    
    .pagination-btn {
        width: 100%;
        justify-content: center;
    }
    
    .modal-content {
        margin: 10px;
    }
    
    #modal-body {
        padding: 24px;
    }
    
    .footer {
        padding: 16px 20px;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1.8rem;
    }
    
    .header h1 {
        font-size: 1.2rem;
    }
    
    #search-input {
        font-size: 1rem;
    }
    
    .book-title {
        font-size: 1rem;
    }
}
