:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --accent-color: #bb86fc;
    --error-color: #cf6679;
    --success-color: #03dac6;
    --border-color: #333333;
    --shadow-color: rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

a {
    color: var(--accent-color);
    text-decoration: none;
}

button {
    cursor: pointer;
    font-family: inherit;
}

.hidden {
    display: none !important;
}

/* Header Styles */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--bg-color);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
}

nav {
    position: relative;
}

#menu-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    display: block;
}

#menu-toggle svg {
    fill: var(--text-primary);
}

.menu {
    position: absolute;
    right: 0;
    top: 100%;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
    display: none;
    flex-direction: column;
    min-width: 150px;
    box-shadow: 0 4px 6px var(--shadow-color);
}

.menu.active {
    display: flex;
}

.menu a {
    margin: 0.5rem 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

.menu a svg {
    margin-right: 0.5rem;
    fill: var(--text-primary);
}

#cart-count {
    background-color: var(--accent-color);
    color: var(--bg-color);
    border-radius: 50%;
    padding: 0.1rem 0.4rem;
    font-size: 0.8rem;
    margin-left: 0.25rem;
}

/* Main Content Styles */
main {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.active-section {
    display: block;
}

.hidden-section {
    display: none;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 2rem 1rem;
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.hero p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Button Styles */
.primary-btn {
    background-color: var(--accent-color);
    color: var(--bg-color);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-weight: bold;
    transition: opacity 0.2s;
}

.primary-btn:hover {
    opacity: 0.9;
}

.secondary-btn {
    background-color: transparent;
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-weight: bold;
    transition: background-color 0.2s;
}

.secondary-btn:hover {
    background-color: rgba(187, 134, 252, 0.1);
}

.back-btn {
    display: flex;
    align-items: center;
    background: none;
    border: none;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.back-btn svg {
    fill: var(--text-primary);
    margin-right: 0.5rem;
}

/* Section Headers */
.section-header {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5rem;
}

section h2 {
    margin-bottom: 1.5rem;
    position: relative;
}

section h2::after {
    content: '';
    position: absolute;
    bottom: -0.5rem;
    left: 0;
    width: 3rem;
    height: 3px;
    background-color: var(--accent-color);
}

/* PDF Grid */
.pdf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.pdf-card {
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.pdf-card:hover {
    transform: translateY(-5px);
}

.pdf-thumbnail {
    aspect-ratio: 3/4;
    background-color: var(--border-color);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pdf-info {
    padding: 0.75rem;
}

.pdf-title {
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.pdf-author {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.pdf-price {
    font-size: 1rem;
    font-weight: bold;
    color: var(--accent-color);
}

/* Filter Container */
.filter-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

#category-filter, #search {
    padding: 0.75rem;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
}

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

/* PDF Details */
#pdf-detail-content {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
}

.pdf-detail-header {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5rem;
}

.pdf-detail-info {
    flex-grow: 1;
}

.pdf-detail-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.pdf-detail-author {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.pdf-detail-thumbnail {
    width: 200px;
    aspect-ratio: 3/4;
    background-color: var(--border-color);
    margin: 1rem auto;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.pdf-detail-thumbnail .pdf-cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pdf-detail-description {
    margin-bottom: 1.5rem;
}

.pdf-detail-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.pdf-detail-price {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
}

.pdf-detail-category {
    display: inline-block;
    background-color: rgba(187, 134, 252, 0.1);
    color: var(--accent-color);
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    font-size: 0.8rem;
}

/* Account Section */
.account-container {
    max-width: 400px;
    margin: 0 auto;
}

.auth-form {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.auth-form h3 {
    margin-bottom: 1.5rem;
    text-align: center;
}

.auth-form form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-form input {
    padding: 0.75rem;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
}

.auth-form p {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Cart Section */
#cart-items {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.cart-item {
    display: flex;
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 1rem;
}

.cart-item-thumbnail {
    width: 60px;
    height: 80px;
    background-color: var(--border-color);
    border-radius: 4px;
    margin-right: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.cart-item-thumbnail .pdf-cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-item-info {
    flex-grow: 1;
}

.cart-item-title {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.cart-item-author {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.cart-item-price {
    color: var(--accent-color);
    font-weight: bold;
}

.cart-item-remove {
    background: none;
    border: none;
    color: var(--error-color);
    font-size: 0.9rem;
    margin-top: 0.5rem;
    align-self: flex-start;
    display: flex;
    align-items: center;
}

.cart-item-remove svg {
    fill: var(--error-color);
    margin-right: 0.25rem;
    width: 16px;
    height: 16px;
}

.cart-summary {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
}

.subtotal {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    font-weight: bold;
}

#empty-cart-message {
    text-align: center;
    padding: 2rem;
    background-color: var(--card-bg);
    border-radius: 8px;
}

#empty-cart-message p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* PDF Embed Styles */
.pdf-embed-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 129.4%; /* Aspect ratio for A4 paper */
    margin: 1rem 0;
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
}

.pdf-embed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

/* Hide old preview styles */
.preview-navigation,
.preview-nav-btn,
.preview-pages-container,
.preview-page,
.page-content {
    display: none;
}

/* Footer Styles */
footer {
    background-color: var(--card-bg);
    padding: 2rem 1rem;
    margin-top: 3rem;
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.footer-section h3 {
    margin-bottom: 1rem;
    color: var(--accent-color);
}

.footer-section a {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.footer-section p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.footer-bottom {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Welcome Popup Styles */
.welcome-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.welcome-popup.show {
    opacity: 1;
}

.welcome-popup.fade-out {
    opacity: 0;
}

.popup-content {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    position: relative;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 8px 16px var(--shadow-color);
}

.popup-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    z-index: 2;
}

.popup-close svg {
    fill: var(--text-primary);
}

.popup-image {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.popup-image svg {
    fill: var(--accent-color);
    margin-bottom: 1.5rem;
}

.popup-text h2 {
    color: var(--accent-color);
    margin-bottom: 1rem;
}

.popup-text p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Media Queries */
@media (min-width: 768px) {
    .pdf-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
    
    .filter-container {
        flex-direction: row;
    }
    
    #category-filter {
        max-width: 200px;
    }
    
    .footer-content {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .footer-section {
        flex: 1;
    }
    
    .pdf-detail-header {
        flex-direction: row;
        gap: 1.5rem;
    }
    
    .pdf-detail-thumbnail {
        margin: 0;
    }
    
    #menu-toggle {
        display: none;
    }
    
    .menu {
        position: static;
        display: flex;
        flex-direction: row;
        gap: 1.5rem;
        background-color: transparent;
        border: none;
        padding: 0;
        box-shadow: none;
    }
    
    .menu a {
        margin: 0;
    }
}

@media (min-width: 1024px) {
    .pdf-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
    
    .hero h1 {
        font-size: 2.5rem;
    }
}