/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
.header {
    background-color: #232f3e;
    color: white;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-top {
    padding: 10px 0;
}

.header-top .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo h1 {
    color: #ffd700;
    font-size: 24px;
    font-weight: bold;
}

.logo h1 i {
    margin-right: 8px;
}

/* Search Container */
.search-container {
    flex: 1;
    max-width: 600px;
    margin: 0 20px;
    position: relative;
}

.search-box {
    display: flex;
    background-color: white;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.search-category {
    padding: 12px;
    border: none;
    background-color: #e6e6e6;
    font-size: 14px;
    outline: none;
    cursor: pointer;
}

#search-input {
    flex: 1;
    padding: 12px;
    border: none;
    outline: none;
    font-size: 14px;
}

.search-btn {
    background-color: #ffd700;
    border: none;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.search-btn:hover {
    background-color: #e6c200;
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    display: none;
    z-index: 1001;
}

.suggestion-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
}

.suggestion-item:hover {
    background-color: #f5f5f5;
}

/* User Menu */
.user-menu {
    display: flex;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dropdown {
    position: relative;
}

.dropdown-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

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

.dropdown-content {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: white;
    min-width: 200px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border-radius: 4px;
    display: none;
    z-index: 1002;
}

.dropdown-content a {
    display: block;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s;
}

.dropdown-content a:hover {
    background-color: #f5f5f5;
}

.login-btn {
    background-color: #ffd700;
    color: #232f3e;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 4px;
    font-weight: bold;
    transition: background-color 0.3s;
}

.login-btn:hover {
    background-color: #e6c200;
}

/* Header Navigation */
.header-nav {
    background-color: #37475a;
    padding: 8px 0;
}

.main-nav ul {
    display: flex;
    list-style: none;
    gap: 20px;
    flex-wrap: wrap;
}

.main-nav a {
    color: white;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background-color 0.3s;
    display: block;
}

.main-nav a:hover,
.main-nav a.active {
    background-color: #ffd700;
    color: #232f3e;
}

/* Main Layout */
.main-container {
    display: flex;
    gap: 20px;
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
}

/* Sidebar */
.sidebar {
    width: 280px;
    flex-shrink: 0;
}

.sidebar-section {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sidebar-section h3 {
    color: #232f3e;
    margin-bottom: 15px;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.category-item:hover {
    background-color: #e9ecef;
}

.category-item.active {
    background-color: #ffd700;
    color: #232f3e;
}

.category-count {
    background-color: #6c757d;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

/* Price Filter */
.price-filter {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.price-range {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.price-range label {
    font-weight: 500;
    color: #232f3e;
}

.price-range input {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    outline: none;
}

.filter-btn {
    background-color: #232f3e;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
}

.filter-btn:hover {
    background-color: #37475a;
}

/* Checkbox Styles */
.checkbox-container {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid #ddd;
    border-radius: 3px;
    position: relative;
    display: inline-block;
}

input[type="checkbox"]:checked + .checkmark {
    background-color: #ffd700;
    border-color: #ffd700;
}

input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: -2px;
    left: 2px;
    color: #232f3e;
    font-weight: bold;
}

input[type="checkbox"] {
    display: none;
}

/* Main Content */
.main-content {
    flex: 1;
}

.featured-section,
.all-books-section,
.search-results {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.featured-section h2,
.all-books-section h2,
.search-results h2 {
    color: #232f3e;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Filter Controls */
.filter-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-controls select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    outline: none;
    background-color: white;
}

/* Books Grid */
.books-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)) !important;
    gap: 18px !important;
    margin-bottom: 20px;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
    list-style: none;
    clear: both;
    overflow: hidden;
}

.book-card {
    background-color: white;
    border-radius: 8px;
    padding: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    position: relative;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 350px;
    max-width: 220px;
    width: 100%;
    justify-self: center;
}

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

.book-card .book-cover {
    height: 220px;
    width: 150px;
    object-fit: cover;
    border-radius: 6px;
    margin: 0 auto 14px auto;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    display: block;
}

.book-card .book-cover:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.book-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0 6px;
}

.book-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: #1f2937;
    font-size: 14px;
    line-height: 1.4;
    min-height: 40px;
    display: flex;
    align-items: flex-start;
}

.book-author {
    color: #6b7280;
    font-size: 12px;
    margin-bottom: 12px;
    min-height: 16px;
}

.book-price-section {
    margin-bottom: 12px;
}

.book-price {
    color: #111827;
    font-size: 17px;
    font-weight: 700;
}

.add-to-cart-btn {
    background-color: #fbbf24 !important;
    color: #1f2937 !important;
    border-radius: 25px;
    min-width: 120px;
    max-width: 130px;
    font-weight: 600;
    padding: 6px 8px;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.2s ease;
    font-size: 13px;
    position: relative;
    z-index: 5;
    border: none;
}

.add-to-cart-btn:hover {
    background-color: #f59e0b !important;
    color: #1f2937 !important;
    transform: translateY(-1px);
    text-decoration: none;
}

.discount-price {
    color: #e47911;
    font-weight: bold;
    font-size: 16px;
}

.full-price {
    color: #999;
    text-decoration: line-through;
    font-size: 12px;
}

.discount-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: #e47911;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Override for discount badge in HTML */
.book-card .absolute.top-2.right-2 {
    z-index: 15 !important;
    top: 8px !important;
    right: 8px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
    font-weight: 600 !important;
    border-radius: 4px !important;
}

/* Price styling improvements */
.line-through {
    text-decoration: line-through !important;
    font-size: 12px !important;
}

/* Book card link styles */
.book-card a {
    text-decoration: none;
    color: inherit;
}

.book-card a:hover {
    text-decoration: none;
}

/* Category page specific styling */
.books-grid .book-card .book-title a:hover {
    color: #000000 !important;
}

/* Improved grid spacing and alignment */
.books-grid {
    place-items: start;
    justify-content: center;
    align-items: start;
}

/* Better text rendering */
.book-title, .book-author, .book-price {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

/* Related Books section specific styling */
.related-books-section .add-to-cart-btn,
.related-books-section .related-btn {
    background-color: #fbbf24 !important;
    color: #1f2937 !important;
    border: none !important;
    padding: 4px 8px !important;
    font-size: 11px !important;
    min-width: 80px !important;
    max-width: 100px !important;
    border-radius: 20px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
}

.related-books-section .add-to-cart-btn:hover,
.related-books-section .related-btn:hover {
    background-color: #f59e0b !important;
    color: #1f2937 !important;
    text-decoration: none !important;
}

/* Force override any conflicting styles */
a.related-btn {
    background-color: #fbbf24 !important;
    color: #1f2937 !important;
    border: none !important;
    text-decoration: none !important;
}

a.related-btn:hover,
a.related-btn:focus,
a.related-btn:active,
a.related-btn:visited {
    background-color: #f59e0b !important;
    color: #1f2937 !important;
    text-decoration: none !important;
}

/* Force grid layout over any conflicting styles */
.books-grid {
    display: grid !important;
    grid-auto-rows: max-content !important;
}

.books-grid > * {
    display: flex !important;
    flex-direction: column !important;
}

/* Override any floating or positioning that might break grid */
.books-grid .book-card {
    float: none !important;
    position: relative !important;
    clear: none !important;
}

/* Load More */
.load-more {
    text-align: center;
    margin-top: 30px;
}

#load-more-btn {
    background-color: #ffd700;
    color: #232f3e;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    transition: background-color 0.3s;
}

#load-more-btn:hover {
    background-color: #e6c200;
}

/* Footer */
.footer {
    background-color: #232f3e;
    color: white;
    margin-top: 40px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
    padding: 40px 0;
}

.footer-section h4 {
    color: #ffd700;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-section p {
    margin-bottom: 15px;
    line-height: 1.6;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 8px;
}

.footer-section ul li a {
    color: white;
    text-decoration: none;
    transition: color 0.3s;
}

.footer-section ul li a:hover {
    color: #ffd700;
}

.social-links {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.social-links a {
    color: white;
    font-size: 20px;
    transition: color 0.3s;
}

.social-links a:hover {
    color: #ffd700;
}

.contact-info p {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.footer-bottom {
    border-top: 1px solid #37475a;
    padding: 20px 0;
}

.footer-bottom-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-links {
    display: flex;
    gap: 20px;
}

.footer-links a {
    color: white;
    text-decoration: none;
    transition: color 0.3s;
}

.footer-links a:hover {
    color: #ffd700;
}

/* Loading Spinner */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #ffd700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Author and Publisher Items */
.author-item,
.publisher-item {
    padding: 5px 0;
    cursor: pointer;
    color: #007bff;
    transition: color 0.3s;
}

.author-item:hover,
.publisher-item:hover {
    color: #ffd700;
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
        gap: 16px;
    }
}

@media (max-width: 1200px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 14px;
    }
    
    .book-card {
        min-height: 320px;
        max-width: 200px;
    }
    
    .book-card .book-cover {
        height: 200px;
        width: 135px;
    }
}

@media (max-width: 1024px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }
    
    .book-card {
        min-height: 300px;
        max-width: 180px;
    }
    
    .book-card .book-cover {
        height: 180px;
        width: 125px;
    }
}

@media (max-width: 992px) {
    .add-to-cart-btn {
        min-width: 120px;
        max-width: 130px;
        padding: 4px;
        font-size: 13px;
        border-radius: 28px;
    }
}

@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        order: 2;
    }
    
    .main-content {
        order: 1;
    }
    
    .header-top .container {
        flex-direction: column;
        gap: 15px;
    }
    
    .search-container {
        margin: 0;
        max-width: 100%;
    }
    
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
        justify-content: center;
    }
    
    .book-card {
        padding: 10px;
        min-height: 280px;
        max-width: 160px;
    }
    
    .book-card .book-cover {
        height: 160px;
        width: 110px;
    }
    
    .book-title {
        font-size: 13px;
        min-height: 32px;
    }
    
    .book-author {
        font-size: 11px;
    }
    
    .book-price {
        font-size: 15px;
    }
    
    .add-to-cart-btn {
        min-width: 90px;
        max-width: 100px;
        padding: 4px 6px;
        font-size: 11px;
        border-radius: 20px;
    }
    
    .main-nav ul {
        justify-content: center;
    }
    
    .footer-bottom-content {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 8px;
        justify-content: center;
    }
    
    .book-card {
        padding: 8px;
        min-height: 260px;
        max-width: 140px;
    }
    
    .book-card .book-cover {
        height: 140px;
        width: 95px;
    }
    
    .book-title {
        font-size: 12px;
        min-height: 28px;
        margin-bottom: 6px;
        line-height: 1.3;
    }
    
    .book-author {
        font-size: 10px;
        margin-bottom: 8px;
    }
    
    .book-price {
        font-size: 14px;
    }
    
    .add-to-cart-btn {
        min-width: 75px;
        max-width: 85px;
        padding: 3px 4px;
        font-size: 10px;
        border-radius: 15px;
    }
}

/* Index Page Specific Styles - Override Tailwind to ensure books grid works properly */
.books-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)) !important;
    gap: 18px !important;
    margin-bottom: 20px;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
    place-items: start;
    justify-content: center;
}

@media (max-width: 1400px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)) !important;
        gap: 16px !important;
    }
}

@media (max-width: 1200px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
        gap: 14px !important;
    }
}

@media (max-width: 768px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        gap: 12px !important;
    }
}

@media (max-width: 480px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
        gap: 10px !important;
    }
}

/* Book Description HTML Styling */
.book-description p {
    margin-bottom: 1rem;
}

.book-description h1, .book-description h2, .book-description h3, 
.book-description h4, .book-description h5, .book-description h6 {
    font-weight: 600;
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
    color: #1e293b;
}

.book-description h1 { font-size: 1.5rem; }
.book-description h2 { font-size: 1.375rem; }
.book-description h3 { font-size: 1.25rem; }
.book-description h4 { font-size: 1.125rem; }
.book-description h5 { font-size: 1rem; }
.book-description h6 { font-size: 0.875rem; }

.book-description strong, .book-description b {
    font-weight: 600;
    color: #1e293b;
}

.book-description em, .book-description i {
    font-style: italic;
}

.book-description u {
    text-decoration: underline;
}

.book-description ul {
    list-style-type: disc;
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.book-description ol {
    list-style-type: decimal;
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.book-description li {
    margin-bottom: 0.25rem;
}

.book-description blockquote {
    border-left: 4px solid #3b82f6;
    padding-left: 1rem;
    margin: 1rem 0;
    font-style: italic;
    color: #475569;
    background-color: #f8fafc;
    padding: 1rem;
    border-radius: 0.25rem;
}

.book-description a {
    color: #3b82f6;
    text-decoration: underline;
}

.book-description a:hover {
    color: #2563eb;
}

.book-description div {
    margin-bottom: 0.5rem;
}
