/* Minimal CSS */
:root {
    --primary: #333;
    --bg: #fdfdfd;
    --border: #ddd;
    --text: #222;
}

* {
    box-sizing: border-box;
}

body {
    font-family: sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

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

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

h1,
h2,
h3 {
    margin-top: 0;
}

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

a:hover {
    text-decoration: underline;
}

/* Header Search */
.header-search {
    position: relative;
    display: flex;
    align-items: center;
}

.header-search input {
    padding: 8px 35px 8px 15px;
    border: 1px solid #ccc;
    border-radius: 20px;
    /* Rounded for modern look */
    font-size: 14px;
    width: 800px;
    /* Wider */
    max-width: 100%;
    /* Responsive */
    outline: none;
    transition: border-color 0.2s;
}

.header-search input:focus {
    border-color: var(--primary);
}

.header-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    pointer-events: none;
    width: 16px;
    height: 16px;
}

/* Grid for Index */
.pdf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 30px;
}

.pdf-item {
    border: 1px solid var(--border);
    padding: 15px;
    text-align: center;
}

.pdf-item img {
    width: 100%;
    height: auto;
    aspect-ratio: 210/297;
    /* A4 Ratio */
    object-fit: contain;
    background-color: #f9f9f9;
    /* Placeholder */
    display: block;
    margin-bottom: 15px;
}

/* Similar PDFs */
.similar-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.similar-item {
    border: 1px solid var(--border);
    padding: 10px;
    text-align: center;
}

.similar-item img {
    width: 100%;
    height: auto;
    aspect-ratio: 210/297;
    object-fit: contain;
    background-color: #f9f9f9;
    display: block;
    margin-bottom: 10px;
}

.similar-item span {
    font-size: 14px;
    font-weight: bold;
}

/* Product Layout (Download Page) */
.product-layout {
    display: flex;
    gap: 60px;
    margin-bottom: 60px;
}

.product-image {
    flex: 1;
    max-width: 50%;
    text-align: center;
}

.product-image img {
    width: auto;
    max-width: 100%;
    max-height: 500px;
    aspect-ratio: 210/297;
    object-fit: contain;
    background-color: #f9f9f9;
    display: block;
    border: 1px solid #eee;
    margin: 0 auto;
    /* Center if smaller */
}

.product-info {
    flex: 1;
}

.product-description {
    margin: 20px 0 30px;
    font-size: 16px;
    line-height: 1.8;
    color: #444;
}

.download-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.button {
    display: inline-block;
    padding: 15px 30px;
    background: #f8f8f8;
    border: 1px solid #ccc;
    color: #333;
    text-decoration: none;
    cursor: pointer;
    font-size: 16px;
    text-align: center;
    transition: background 0.2s;
}

.button:hover {
    background: #eee;
    text-decoration: none;
}

/* Similar Posts Section */
.similar-section {
    border-top: 1px solid var(--border);
    padding-top: 40px;
}

.similar-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.similar-item {
    text-align: center;
}

.similar-item img {
    width: 100%;
    height: auto;
    margin-bottom: 10px;
    display: block;
}

/* Form */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    font-family: inherit;
}

/* Site Brand */
.site-brand {
    font-size: 1.17em;
    font-weight: bold;
    color: var(--text);
    text-decoration: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    header {
        flex-direction: column !important;
        text-align: center;
        gap: 15px;
        align-items: center !important;
    }

    .back-link {
        display: none;
    }

    .site-brand {
        order: 1;
        margin-bottom: 10px;
    }

    header h1 {
        margin-bottom: 0;
        width: 100%;
        order: 1;
        /* For index.php */
    }

    .header-search {
        width: 100%;
        max-width: 100%;
        justify-content: center;
        order: 2;
    }

    .header-search input {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
        /* Ensure padding doesn't overflow */
    }

    .pdf-grid,
    .similar-list {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }

    .pdf-item {
        padding: 10px;
    }

    .pdf-item h3 {
        font-size: 14px;
    }

    .product-layout {
        flex-direction: column;
        gap: 20px;
    }

    .product-info {
        display: contents;
    }

    .product-info h1 {
        order: 1;
        font-size: 24px;
        margin-bottom: 15px;
        width: 100%;
    }

    .product-image {
        order: 2;
        max-width: 100%;
        text-align: center;
        /* Center the image */
    }

    .product-image img {
        max-height: 180px;
        width: auto;
        /* Maintain aspect ratio */
    }

    .download-buttons {
        order: 3;
        margin-bottom: 20px;
        width: 100%;
    }

    .product-description {
        order: 4;
        margin-top: 0;
        width: 100%;
    }

    .button {
        padding: 12px 10px;
        /* Reduced padding */
        font-size: 14px;
        /* Smaller font */
        width: 100%;
        /* Full width */
        box-sizing: border-box;
    }
}

/* Admin Panel */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 250px;
    background: #f4f4f4;
    border-right: 1px solid var(--border);
    padding: 20px;
    flex-shrink: 0;
}

.admin-sidebar h2 {
    margin-top: 0;
    font-size: 20px;
    margin-bottom: 20px;
}

.admin-sidebar ul {
    list-style: none;
    padding: 0;
}

.admin-sidebar li {
    margin-bottom: 10px;
}

.admin-sidebar a {
    display: block;
    padding: 10px;
    background: #fff;
    border: 1px solid #ddd;
    color: #333;
    text-decoration: none;
}

.admin-sidebar a:hover {
    background: #eee;
}

.admin-content {
    flex: 1;
    padding: 40px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.admin-table th,
.admin-table td {
    border: 1px solid var(--border);
    padding: 10px;
    text-align: left;
}

.admin-table th {
    background: #f9f9f9;
}

.action-btn {
    padding: 5px 10px;
    font-size: 12px;
    margin-right: 5px;
    text-decoration: none;
    border: 1px solid #ccc;
    background: #f0f0f0;
    color: #333;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.pagination .button {
    padding: 8px 14px;
    font-size: 14px;
    text-decoration: none;
    background-color: #f0f0f0;
    color: #333;
    border-radius: 4px;
    border: 1px solid #ddd;
    transition: background-color 0.2s, color 0.2s;
}

.pagination .button:hover:not(.active) {
    background-color: #e0e0e0;
}

.pagination .button.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
    cursor: default;
    font-weight: bold;
}

.pagination .ellipsis {
    padding: 0 5px;
    color: #777;
    font-size: 14px;
}

/* Footer */
footer {
    margin-top: 80px;
    border-top: 4px solid var(--primary);
    /* Stronger divider */
    padding-top: 60px;
    padding-bottom: 40px;
    background: #f4f4f4;
    color: #333;
    /* Full width background trick */
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    padding-left: calc(50vw - 50%);
    padding-right: calc(50vw - 50%);
}

.footer-content {
    display: flex;
    flex-wrap: wrap;
    gap: 60px;
    margin-bottom: 40px;
    max-width: 1440px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 20px;
}

.footer-col {
    flex: 1;
    min-width: 250px;
}

.footer-logo {
    font-weight: bold;
    font-size: 1.4em;
    display: block;
    margin-bottom: 15px;
    color: var(--primary);
}

.footer-col p {
    font-size: 0.95em;
    line-height: 1.6;
    max-width: 400px;
}

.footer-col .footer-heading {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.1em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: bold;
    display: block;
    /* Ensure it behaves like a block element */
}

.footer-col ul {
    list-style: none;
    padding: 0;
}

.footer-col li {
    margin-bottom: 10px;
}

.footer-col a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s;
}

.footer-col a:hover {
    color: var(--primary);
}

.footer-bottom {
    text-align: center;
    font-size: 0.9em;
    color: #444;
    border-top: 1px solid #ddd;
    padding-top: 30px;
    margin-top: 20px;
    max-width: 1440px;
    margin-left: auto;
    margin-right: auto;
}

/* Search Page */
.search-container {
    text-align: center;
    margin-bottom: 40px;
}

.search-form {
    max-width: 500px;
    margin: 0 auto;
    display: flex;
    gap: 10px;
}

.search-form input {
    flex: 1;
    padding: 10px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.search-form button {
    padding: 10px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

.search-form button:hover {
    opacity: 0.9;
}

/* FAQ Section */
.faq-section {
    margin-top: 60px;
    border-top: 1px solid #eee;
    padding-top: 40px;
}

.faq-section h3 {
    margin-bottom: 30px;
    font-size: 1.5em;
}

.faq-item {
    margin-bottom: 25px;
}

.faq-question {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 10px;
    color: #333;
}

.faq-answer {
    font-weight: normal;
    color: #555;
    line-height: 1.6;
}