* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Mobile-first header */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 0.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Navigation optimized for mobile */
nav {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    position: sticky;
    top: 60px;
    z-index: 99;
}

.nav-container {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    padding: 0.25rem 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.nav-container::-webkit-scrollbar {
    display: none;
}

.nav-item {
    padding: 0.6rem 0.8rem;
    border-radius: 16px;
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.3);
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.8rem;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.nav-item:hover,
.nav-item.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-1px);
}

/* Main content */
main {
    padding: 0 0.75rem 1.5rem;
}

/* Mobile-first grid layout */
#book-gallery {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    width: 100%;
}

/* Card design optimized for mobile */
.book-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.book-card:active {
    transform: scale(0.98);
}

.book-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

/* Mobile layout for book content */
.top-section {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 0.75rem 0;
    align-items: flex-start;
}

/* Image area for mobile */
.image-area {
    flex-shrink: 0;
    width: 90px;
    height: 120px;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.image-area img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

/* Details area for mobile */
.details-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.details-area h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.4rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.author {
    color: #666;
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Price container with discount badge */
.price-container {
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.price {
    font-size: 1.1rem;
    font-weight: 700;
    color: #667eea;
}

.original-price {
    font-size: 0.8rem;
    color: #999;
    text-decoration: line-through;
    font-weight: 400;
}

.discount-badge {
    background: #ff4757;
    color: white;
    padding: 0.15rem 0.4rem;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: bold;
}

/* Status badges */
.bestseller-badge {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background: #ffa502;
    color: white;
    padding: 0.2rem 0.4rem;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: bold;
    z-index: 1;
}

.new-badge {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background: #2ed573;
    color: white;
    padding: 0.2rem 0.4rem;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: bold;
    z-index: 1;
}

/* Mobile button layout */
.button-group-top {
    display: flex;
    gap: 0.4rem;
    margin-top: auto;
}

.btn {
    flex: 1;
    padding: 0.5rem;
    border-radius: 6px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.buy-button-top {
    background: linear-gradient(135deg, #fad60eff, #ffaf02ff);
    color: white;
}

.buy-button-top:active {
    transform: scale(0.95);
}

.detail-button-top {
    background: rgba(108, 117, 125, 0.1);
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.detail-button-top:active {
    background: #6c757d;
    color: white;
}

/* Bottom section for mobile */
.bottom-section {
    padding: 0.75rem;
    background: rgba(248, 249, 250, 0.5);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.bottom-section h4 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: #333;
}

.bottom-section p {
    color: #666;
    line-height: 1.5;
    font-size: 0.8rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 2rem 1rem;
    color: white;
    font-size: 1rem;
}

/* Error message */
.error-message {
    text-align: center;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    margin: 1rem;
    color: #d32f2f;
}

/* Mobile modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    width: 100%;
    max-width: 450px;
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: #ff4757;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.modal-image {
    width: 120px;
    height: auto;
    border-radius: 6px;
    margin: 0 auto 1rem;
    display: block;
}

/* Footer */
footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1.25rem 0.75rem;
    text-align: center;
    margin-top: 1.5rem;
    color: #666;
    font-size: 0.8rem;
}

/* Contact section */
.contact-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1.5rem 0.75rem;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    margin: 0.75rem;
}

.contact-grid {
    display: grid;
    gap: 1rem;
    margin: 1.25rem 0;
}

.contact-card {
    background: rgba(102, 126, 234, 0.1);
    padding: 1.25rem;
    border-radius: 10px;
}

.contact-btn {
    background: #25D366;
    color: white;
    padding: 0.6rem 1.25rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    -webkit-tap-highlight-color: transparent;
}

.contact-btn:active {
    transform: scale(0.95);
}

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

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

.book-card {
    animation: fadeIn 0.5s ease-out;
}

/* Tablet responsive (min-width: 480px) */
@media (min-width: 480px) {
    main {
        padding: 0 1rem 2rem;
    }
    
    header {
        padding: 1.25rem;
    }
    
    header h1 {
        font-size: 1.7rem;
    }
    
    #book-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
    
    .top-section {
        gap: 1rem;
        padding: 1.25rem 1rem 0;
    }
    
    .image-area {
        width: 100px;
        height: 135px;
    }
    
    .details-area h3 {
        font-size: 1rem;
    }
    
    .price {
        font-size: 1.2rem;
    }
    
    .btn {
        font-size: 0.8rem;
        padding: 0.6rem;
    }
}

/* Desktop responsive (min-width: 768px) */
@media (min-width: 768px) {
    main {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 1.5rem 2.5rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    #book-gallery {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
    
    .nav-container {
        justify-content: center;
        gap: 0.6rem;
    }
    
    .nav-item {
        font-size: 0.9rem;
        padding: 0.7rem 1rem;
    }
    
    .book-card {
        transition: all 0.3s ease, transform 0.2s ease;
    }
    
    .book-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    }
    
    .top-section {
        padding: 1.5rem 1.25rem 0;
        gap: 1.25rem;
    }
    
    .image-area {
        width: 120px;
        height: 160px;
    }
    
    .details-area h3 {
        font-size: 1.1rem;
    }
    
    .price {
        font-size: 1.3rem;
    }
    
    .btn {
        font-size: 0.85rem;
        padding: 0.65rem;
    }
    
    .bottom-section {
        padding: 1rem 1.25rem;
    }
    
    .modal-content {
        max-width: 500px;
        padding: 2rem;
    }
    
    .modal-image {
        width: 150px;
    }
}

/* Large desktop responsive (min-width: 1024px) */
@media (min-width: 1024px) {
    #book-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
    
    .top-section {
        display: grid;
        grid-template-columns: 150px 1fr;
        gap: 1.5rem;
        align-items: start;
        padding: 1.5rem;
    }
    
    .image-area {
        width: 100%;
        height: 200px;
    }
    
    .details-area {
        height: 100%;
        justify-content: space-between;
    }
    
    .details-area h3 {
        font-size: 1.2rem;
        -webkit-line-clamp: 3;
    }
    
    .price {
        font-size: 1.4rem;
    }
    
    .btn {
        font-size: 0.9rem;
        padding: 0.7rem;
    }
    
    .bottom-section {
        padding: 1.5rem;
    }
    
    .bottom-section p {
        font-size: 0.85rem;
    }
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
    .book-card:hover {
        transform: none;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    }
    
    .nav-item:hover {
        transform: none;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .image-area img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .book-card {
        animation: none;
    }
    
    * {
        transition: none !important;
    }
}