/* =========================================
   CSS Variables & Reset
========================================= */
:root {
    /* Color Palette */
    --color-primary: #D35400;
    /* Deep Saffron/Orange */
    --color-primary-hover: #E67E22;
    --color-secondary: #5C3A21;
    /* Dark Brown */
    --color-bg-light: #FAF8F5;
    /* Warm Cream */
    --color-text-main: #2C3E50;
    --color-text-muted: #7F8C8D;
    --color-white: #FFFFFF;
    --color-border: #EAECEE;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 16px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.15);

    /* Fonts */
    --font-heading: 'Noto Serif Sinhala', serif;
    --font-body: 'Noto Sans Sinhala', 'Inter', sans-serif;

    /* Transitions */
    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-bg-light);
    color: var(--color-text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    color: var(--color-secondary);
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    font-family: inherit;
}

/* =========================================
   Typography & Buttons
========================================= */
.btn-primary {
    display: inline-block;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
    color: var(--color-white);
    padding: 12px 28px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1rem;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(211, 84, 0, 0.3);
    text-align: center;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(211, 84, 0, 0.4);
}

.btn-primary:disabled {
    background: var(--color-text-muted);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn-outline {
    display: inline-block;
    background: transparent;
    color: var(--color-secondary);
    border: 2px solid var(--color-secondary);
    padding: 10px 26px;
    border-radius: 50px;
    font-weight: 600;
    transition: var(--transition-smooth);
}

.btn-outline:hover {
    background: var(--color-secondary);
    color: var(--color-white);
}

.mt-4 {
    margin-top: 2rem;
}

/* =========================================
   Navbar
========================================= */
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    z-index: 1000;
    transition: var(--transition-smooth);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo span {
    color: var(--color-primary);
}

.logo-icon {
    font-size: 1.8rem;
}

.nav-links {
    display: flex;
    gap: 30px;
}

.nav-links a {
    font-weight: 600;
    position: relative;
    color: var(--color-text-main);
    transition: color 0.3s;
}

.nav-links a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -5px;
    left: 0;
    background-color: var(--color-primary);
    transition: width 0.3s ease;
}

.nav-links a:hover {
    color: var(--color-primary);
}

.nav-links a:hover::after {
    width: 100%;
}

.cart-btn {
    background: var(--color-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--color-white);
    position: relative;
    padding: 10px 20px;
    border-radius: 30px;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(211, 84, 0, 0.3);
}

.cart-btn:hover {
    background-color: var(--color-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(211, 84, 0, 0.4);
}

.cart-badge {
    background-color: var(--color-white);
    color: var(--color-primary);
    font-size: 0.8rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 12px;
    position: absolute;
    top: -8px;
    right: -8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* =========================================
   Hero Section
========================================= */
.hero {
    position: relative;
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background:
        linear-gradient(rgba(26, 21, 15, 0.7), rgba(26, 21, 15, 0.7)),
        url('https://images.unsplash.com/photo-1594917637841-4c7b2c58ee82?ixlib=rb-4.0.3&auto=format&fit=crop&w=1920&q=80') center/cover no-repeat;
    margin-top: 70px;
    padding: 40px 20px;
    color: var(--color-white);
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
    animation: fadeIn 1s ease-out;
}

.hero-content h1 {
    font-size: 4rem;
    color: var(--color-white);
    margin-bottom: 20px;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    line-height: 1.2;
}

.hero-content p {
    font-size: 1.2rem;
    margin-bottom: 30px;
    opacity: 0.9;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================
   Book Section
========================================= */
.book-section {
    padding: 80px 30px;
    max-width: 1200px;
    margin: 0 auto;
}

.section-header {
    text-align: center;
    margin-bottom: 50px;
}

.section-header h2 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.section-divider {
    width: 60px;
    height: 4px;
    background-color: var(--color-primary);
    margin: 0 auto;
    border-radius: 2px;
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 25px;
}

.book-card {
    background: var(--color-white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    border: none;
}

.book-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(211, 84, 0, 0.12);
}

.book-cover {
    width: 100%;
    height: 320px;
    object-fit: cover;
    background-color: #fcfcfc;
}

.book-info {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.book-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 5px;
    line-height: 1.4;
    color: var(--color-secondary);
}

.book-author {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-bottom: 15px;
}

.book-price {
    font-weight: 700;
    color: var(--color-primary);
    font-size: 1.25rem;
    margin-bottom: 15px;
    margin-top: auto;
}

.book-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.btn-card {
    padding: 8px 0;
    text-align: center;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    transition: var(--transition-smooth);
}

.btn-add {
    background-color: var(--color-primary);
    color: white;
}

.btn-add:hover {
    background-color: var(--color-primary-hover);
}

.btn-preview {
    background-color: transparent;
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
}

.btn-preview:hover {
    background-color: rgba(211, 84, 0, 0.05);
}

/* =========================================
   Footer
========================================= */
.footer {
    background-color: var(--color-secondary);
    color: rgba(255, 255, 255, 0.8);
    padding: 60px 30px 20px;
    margin-top: 60px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 40px;
    margin-bottom: 40px;
}

.footer-brand h3 {
    color: var(--color-white);
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.footer-brand span {
    color: var(--color-primary);
}

.footer-brand p {
    max-width: 300px;
}

.footer-links h4 {
    color: var(--color-white);
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.footer-links a {
    display: block;
    margin-bottom: 10px;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--color-primary);
}

.footer-bottom {
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
    font-size: 0.9rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* =========================================
   Modals
========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    /* hidden by default */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: block;
    opacity: 1;
}

.modal-content {
    background: var(--color-white);
    position: absolute;
    box-shadow: var(--shadow-lg);
}

.side-modal {
    top: 0;
    right: -400px;
    width: 400px;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.modal-overlay.active .side-modal {
    right: 0;
}

.center-modal {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow: hidden;
}

.modal-overlay.active .center-modal {
    transform: translate(-50%, -50%) scale(1);
}

.modal-header {
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--color-border);
}

.auth-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
}

.close-btn {
    background: none;
    font-size: 1.5rem;
    color: var(--color-text-muted);
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--color-secondary);
}

/* Cart Specific */
.cart-items {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px 30px;
}

.cart-item {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
}

.cart-item-img {
    width: 60px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
}

.cart-item-info {
    flex-grow: 1;
}

.cart-item-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 5px;
}

.cart-item-price {
    color: var(--color-primary);
    font-weight: 700;
}

.cart-item-remove {
    background: none;
    color: #e74c3c;
    font-size: 0.85rem;
    margin-top: 5px;
    text-decoration: underline;
}

.cart-footer {
    padding: 20px 30px;
    border-top: 1px solid var(--color-border);
    background: #fcfbfa;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--color-secondary);
}

.checkout-btn {
    width: 100%;
    padding: 14px;
}

/* Preview Specific */
.preview-body {
    display: flex;
    padding: 30px;
    gap: 30px;
    overflow-y: auto;
}

.preview-image-wrapper {
    flex-shrink: 0;
    width: 250px;
}

.preview-cover {
    width: 100%;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}

.preview-text-container {
    flex-grow: 1;
    line-height: 1.8;
}

.preview-text-container h3 {
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.preview-text-container p {
    margin-bottom: 15px;
    text-align: justify;
}

/* =========================================
   Responsive Design
========================================= */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        /* simple hidden for mobile, could add hamburger */
    }

    .hero-content h1 {
        font-size: 2.5rem;
    }

    .preview-body {
        flex-direction: column;
    }

    .preview-image-wrapper {
        width: 150px;
        margin: 0 auto;
    }

    .side-modal {
        width: 100%;
        right: -100%;
    }
}

/* =========================================
   Flipbook Styles
========================================= */
#flipbook {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    margin: 0 auto;
}

#flipbook .page {
    background-color: #faf9f5;
    border: 1px solid #ddd;
    box-shadow: inset -2px 0 5px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

#flipbook .page canvas {
    width: 100%;
    height: 100%;
}

/* =========================================
   Category Filters
========================================= */
.cat-btn {
    background-color: var(--color-white);
    color: var(--color-text-main);
    border: 1px solid var(--color-border);
    padding: 10px 24px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    font-size: 0.95rem;
}

.cat-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.cat-btn.active {
    background-color: var(--color-primary);
    color: var(--color-white);
    border-color: var(--color-primary);
    box-shadow: 0 4px 10px rgba(211, 84, 0, 0.2);
}

/* =========================================
   Search Bar
========================================= */
.search-bar {
    width: 100%;
}

.search-bar input {
    width: 100%;
    max-width: 500px;
    padding: 12px 24px;
    border: 1px solid var(--color-border);
    border-radius: 50px;
    font-size: 1rem;
    font-family: var(--font-body);
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-sm);
    outline: none;
}

.search-bar input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(211, 84, 0, 0.15);
}