:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --background-color: #f8fafc;
    --card-background: #ffffff;
    --text-color: #1e293b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --error-color: #ef4444;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

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

header {
    background-color: var(--card-background);
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 20px;
    margin: 0;
    padding: 0;
}

nav a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s;
}

nav a:hover,
nav a.active {
    background-color: var(--primary-color);
    color: white;
}

.card {
    background: var(--card-background);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

h1,
h2,
h3 {
    margin-top: 0;
    color: var(--text-color);
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="file"],
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: var(--secondary-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    table-layout: fixed;
}

/* Table column widths */
table th:nth-child(1),
table td:nth-child(1) {
    width: 70px;
}

/* Title - wider with ellipsis */
table th:nth-child(2),
table td:nth-child(2) {
    width: 35%;
    min-width: 250px;
    max-width: 400px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Title - wider */
table th:nth-child(3),
table td:nth-child(3) {
    width: 110px;
}

/* EAN13 */
table th:nth-child(4),
table td:nth-child(4) {
    width: 60px;
}

/* EAN5 */
table th:nth-child(5),
table td:nth-child(5) {
    width: 50px;
}

/* Lang */
table th:nth-child(6),
table td:nth-child(6) {
    width: 50px;
}

/* DPI */

/* Author - with ellipsis */
table th:nth-child(7),
table td:nth-child(7) {
    width: 80px;
    max-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* PubDate */
table th:nth-child(8),
table td:nth-child(8) {
    width: 90px;
}

/* Publisher - with ellipsis */
table th:nth-child(9),
table td:nth-child(9) {
    width: 80px;
    max-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* PDF */
table th:nth-child(10),
table td:nth-child(10) {
    width: 90px;
}

table td:nth-child(2) {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #f1f5f9;
    font-weight: 600;
    color: #475569;
}

tr:hover {
    background-color: #f8fafc;
}

.thumbnail-img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    /* OR cover, depending on preference */
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background-color: #eee;
}

.action-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9rem;
}

.action-btn.disabled {
    background-color: #cbd5e1;
    cursor: not-allowed;
    pointer-events: none;
}

.flash-messages {
    margin-bottom: 1.5rem;
}

.flash-msg {
    padding: 1rem;
    border-radius: 6px;
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Specific to Search Page */
.search-bar {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 2rem;
}

.search-bar .form-group {
    margin-bottom: 0;
    flex-grow: 1;
}

.search-bar button {
    height: 46px;
    /* Match input height roughly */
}

.login-container {
    max-width: 400px;
    margin: 4rem auto;
    padding: 2rem;
    background: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.login-container h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
}

.login-container .form-group {
    text-align: center;
}

.login-container input[type="text"],
.login-container input[type="password"] {
    width: 50%;
    margin: 0 auto;
    display: block;
}

.login-container label {
    text-align: left;
    width: 50%;
    margin: 0 auto 0.5rem auto;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
    min-width: 80px;
}

.action-form {
    display: inline-block;
}

.btn-danger {
    background-color: var(--error-color);
}

.btn-danger:hover {
    background-color: #dc2626;
    /* Darker red */
}

/* Ensure actions cell aligns items */
td .action-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.button-group {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* User Management Form Inputs */
.user-management input[type="text"],
.user-management input[type="password"] {
    width: 150px;
}

.inline-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form input[type="text"],
.inline-form input[type="password"] {
    width: 140px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    margin-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.page-info {
    color: #64748b;
    font-size: 0.9rem;
}

.page-controls {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.page-btn {
    display: inline-block;
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-color);
    background: var(--card-background);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.page-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.page-jump {
    display: flex;
    gap: 8px;
    align-items: center;
}

.page-jump input {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-align: center;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--card-background);
    border-radius: 12px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 28px;
    font-weight: bold;
    color: #64748b;
    cursor: pointer;
    z-index: 10;
}

.modal-close:hover {
    color: var(--error-color);
}

.modal-body {
    display: flex;
    gap: 2rem;
    padding: 2rem;
}

.modal-image {
    flex: 0 0 250px;
}

.modal-image img {
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.modal-info {
    flex: 1;
}

.modal-info h2 {
    margin: 0 0 1.5rem 0;
    color: var(--primary-color);
    font-size: 1.4rem;
}

.modal-table {
    width: 100%;
    table-layout: auto;
}

.modal-table th {
    width: 80px;
    text-align: left;
    padding: 0.5rem;
    color: #64748b;
    font-weight: 500;
    background: transparent;
}

.modal-table td {
    padding: 0.5rem;
    word-break: break-word;
}

@media (max-width: 600px) {
    .modal-body {
        flex-direction: column;
    }

    .modal-image {
        flex: none;
        text-align: center;
    }

    .modal-image img {
        max-width: 200px;
    }
}

/* Results Header */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.top-pagination {
    display: flex;
    align-items: center;
    gap: 5px;
}

.page-nav-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-color);
    background: var(--card-background);
    cursor: pointer;
    transition: all 0.2s;
}

.page-nav-btn:hover:not(.disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.page-nav-btn.disabled {
    color: #cbd5e1;
    cursor: not-allowed;
}

/* Scroll to Top Button */
#scrollTopBtn {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 30px;
    z-index: 99;
    font-size: 18px;
    border: none;
    outline: none;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s, transform 0.3s;
    text-align: center;
}

#scrollTopBtn:hover {
    background-color: #2563eb;
    transform: translateY(-3px);
}