:root {
    --bg-color: #f4f6f8;
    --text-color: #2c3e50;
    --header-bg: #ffffff;
    --border-color: #e1e8ed;
    --primary-color: #e67e22;
    --primary-hover: #d35400;
    --btn-bg: #f8f9fa;
    --btn-text: #2c3e50;
    --card-bg: #ffffff;
    --shadow: 0 4px 6px rgba(0,0,0,0.05);
}

[data-theme="dark"] {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --header-bg: #1e1e1e;
    --border-color: #333333;
    --primary-color: #e67e22;
    --primary-hover: #d35400;
    --btn-bg: #2d2d2d;
    --btn-text: #e0e0e0;
    --card-bg: #1e1e1e;
    --shadow: 0 4px 6px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}
a { color: var(--primary-color); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* Header */
.public-header, .admin-header {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.header-content {
    max-width: 1600px; margin: 0 auto;
    display: flex; justify-content: space-between; align-items: center;
}
.logo-title { display: flex; align-items: center; gap: 15px; }
.logo { max-height: 50px; border-radius: 4px; }
.logo-title h1 { font-size: 1.5rem; font-weight: 600; margin: 0; }
.theme-toggle {
    background: none; border: none; font-size: 1.5rem; cursor: pointer;
}
.admin-nav { display: flex; align-items: center; gap: 15px; }

.header-actions { display: flex; align-items: center; gap: 15px; }
.icon-link { font-size: 1.5rem; text-decoration: none; background: none; border: none; cursor: pointer; color: inherit; transition: opacity 0.2s; }
.icon-link:hover { opacity: 0.7; text-decoration: none; }

/* Buttons */
.btn {
    padding: 8px 16px; background-color: var(--btn-bg); color: var(--btn-text);
    border: 1px solid var(--border-color); border-radius: 6px; cursor: pointer; 
    text-decoration: none; font-weight: 500; display: inline-block; text-align: center;
    transition: all 0.2s;
}
.btn.primary { background-color: var(--primary-color); color: white; border: none; }
.btn.primary:hover { background-color: var(--primary-hover); text-decoration: none; }
.btn.success { background-color: #27ae60; color: white; border: none; }
.btn.error { background-color: #e74c3c; color: white; border: none; }
.btn.small { padding: 4px 10px; font-size: 0.85rem; }
.btn:hover { opacity: 0.9; text-decoration: none; }
.full-width { width: 100%; }

/* Cards & Forms */
.card {
    background: var(--card-bg); border-radius: 8px; box-shadow: var(--shadow);
    padding: 25px; margin-bottom: 20px;
}
.card h2 { margin-bottom: 20px; font-size: 1.2rem; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; }

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.form-group label { font-size: 0.9rem; font-weight: 600; }
.form-row { display: flex; gap: 15px; }
.form-row .form-group { flex: 1; }
.upload-form input[type="text"], .upload-form input[type="number"], .upload-form select, .upload-form textarea { 
    padding: 10px; border: 1px solid var(--border-color); border-radius: 6px;
    background: var(--bg-color); color: var(--text-color); font-family: inherit;
}
.file-upload-group input[type="file"] {
    padding: 15px; border: 2px dashed var(--border-color); border-radius: 6px;
    background: var(--bg-color); width: 100%; cursor: pointer;
}
.checkbox-group label { display: flex; align-items: center; gap: 10px; font-weight: normal; cursor: pointer; }

/* Admin Grid Layout */
.admin-grid { display: grid; grid-template-columns: 350px 1fr 300px; gap: 30px; align-items: start; }
.admin-sidebar { position: sticky; top: 20px; }
.admin-content { min-width: 0; } /* min-width 0 allows table responsiveness */

/* Admin Table */
.card-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; margin-bottom: 15px; }
.card-header h2 { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
.table-actions { font-size: 0.9rem; }
.table-responsive { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { 
    padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--border-color);
}
.admin-table th { background-color: var(--bg-color); font-weight: 600; font-size: 0.9rem; }
.main-row { cursor: pointer; transition: background-color 0.2s; }
.main-row:hover { background-color: var(--bg-color); }
.details-row { display: none; background-color: var(--bg-color); }
.details-row.open { display: table-row; }
.details-content { padding: 15px; border-left: 4px solid var(--primary-color); font-size: 0.9rem; }
.details-content p { margin-bottom: 5px; }

.mini-thumb { width: 40px; height: 40px; border-radius: 4px; overflow: hidden; background: #eee; }
.mini-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.status { padding: 4px 10px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.status.pending { background: #fef3c7; color: #92400e; }
.status.published { background: #d1fae5; color: #065f46; }

/* Admin Extras */
.todo-list { display: flex; flex-direction: column; gap: 10px; margin-top: 15px; }
.todo-item { display: flex; align-items: center; justify-content: space-between; padding: 10px; background: var(--bg-color); border-radius: 6px; font-size: 0.85rem; }
.todo-link { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 10px; }
.todo-meta { color: #888; margin-right: 10px; font-size: 0.8rem; }
.qr-generator { display: flex; flex-direction: column; gap: 15px; }
.qr-display { display: flex; flex-direction: column; align-items: center; background: #fff; padding: 15px; border-radius: 6px; border: 1px solid var(--border-color); }
.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }

.ml-10 { margin-left: 10px; }
.edit-row { display: none; background-color: #f8f9fa; }
.edit-row.open { display: table-row; }
.edit-form { padding: 15px; border-top: 1px dashed var(--border-color); border-bottom: 2px solid var(--primary-color); overflow-x: auto; }
.edit-form .form-row { display: flex; flex-wrap: wrap; gap: 15px; }
.edit-form .form-group { flex: 1 1 150px; min-width: 150px; }
.edit-form input { width: 100%; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px; box-sizing: border-box; }

/* Toasts */
.toast-container { position: fixed; bottom: 30px; right: 30px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; }
.toast {
    background: #333; color: #fff; padding: 15px 25px; border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2); font-weight: 500;
    transform: translateX(120%); transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1);
    display: flex; align-items: center; gap: 10px;
}
.toast.show { transform: translateX(0); }
.toast.success { background-color: #27ae60; }
.toast.error { background-color: #e74c3c; }

/* Filters */
.filters-toggle { margin-bottom: 15px; }
.filters-toggle a { font-weight: bold; }
.filters-panel {
    background-color: var(--card-bg); border: 1px solid var(--border-color);
    padding: 20px; border-radius: 8px; margin-bottom: 30px; box-shadow: var(--shadow);
}
.filters-form { display: flex; flex-wrap: wrap; gap: 15px; align-items: flex-end; }
.filters-form select, .filters-form input {
    padding: 10px; border: 1px solid var(--border-color); border-radius: 6px;
    background-color: var(--bg-color); color: var(--text-color); min-width: 150px;
}

/* Gallery */
.gallery-section h2 { margin-bottom: 20px; }
.gallery {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 25px;
}
.gallery-item {
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px;
    overflow: hidden; transition: transform 0.2s, box-shadow 0.2s; box-shadow: var(--shadow);
}
.gallery-item:hover { transform: translateY(-5px); box-shadow: 0 8px 15px rgba(0,0,0,0.1); }
.item-link { display: block; color: inherit; text-decoration: none; position: relative; }
.thumb-container { position: relative; width: 100%; aspect-ratio: 3/4; overflow: hidden; background: #eee; }
.thumb-container img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }

/* Date Badge on Thumbnail */
.date-badge {
    position: absolute; top: 10px; right: 10px;
    background: rgba(255, 255, 255, 0.95);
    color: #333; padding: 5px 10px; border-radius: 6px;
    text-align: center; line-height: 1.2; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    display: flex; flex-direction: column; z-index: 2;
}
[data-theme="dark"] .date-badge { background: rgba(30, 30, 30, 0.95); color: #fff; }
.date-badge .month { font-size: 0.85rem; font-weight: bold; text-transform: uppercase; }
.date-badge .year { font-size: 0.75rem; }

.item-meta { padding: 15px; text-align: center; }
.item-meta .journal { font-weight: bold; font-size: 1rem; margin: 0; }

/* Lightbox */
.lightbox {
    display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
}
.lightbox.active { display: flex; flex-direction: column; }
.lb-close {
    position: absolute; top: 15px; right: 25px; color: #f1f1f1; font-size: 40px; 
    font-weight: bold; cursor: pointer; z-index: 1001; transition: color 0.2s;
}
.lb-close:hover { color: #fff; }
.lb-content {
    display: flex; flex: 1; align-items: center; justify-content: center; position: relative;
    padding: 40px 20px 20px 20px;
}
.lb-nav {
    color: white; font-size: 40px; cursor: pointer; padding: 20px; user-select: none;
    transition: opacity 0.2s; opacity: 0.7;
}
.lb-nav:hover { opacity: 1; }
.lb-image-wrapper {
    max-width: 80vw; max-height: 85vh; display: flex; justify-content: center; align-items: center;
    overflow: hidden; /* To contain zoomed image */
}
.lb-img {
    max-width: 100%; max-height: 85vh; object-fit: contain;
    cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1);
}
.lb-img.zoomed { transform: scale(2.5); cursor: zoom-out; }
.lb-caption {
    text-align: center; color: #ccc; padding: 15px; font-size: 1.2rem; min-height: 60px;
}

/* Empty state */
.empty-state { text-align: center; padding: 50px 20px; color: #888; }
.public-footer { text-align: center; padding: 20px; border-top: 1px solid var(--border-color); margin-top: 40px; }

/* Media Queries */
@media (max-width: 1200px) {
    .admin-grid { grid-template-columns: 300px 1fr 250px; gap: 20px; }
}

@media (max-width: 900px) {
    .admin-grid { display: flex; flex-direction: column; }
    .admin-sidebar { flex: auto; width: 100%; position: static; display: none; }
    .admin-sidebar.mobile-open { display: block; }
    .mobile-actions-toggle { display: block !important; }
}

@media (max-width: 600px) {
    .header-content { flex-direction: column; text-align: center; gap: 10px; }
    .admin-nav { margin-top: 10px; }
    .form-row { flex-direction: column; }
    .gallery { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .lb-image-wrapper { max-width: 100vw; }
    .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); padding: 10px; }
    .lb-prev { left: 0; }
    .lb-next { right: 0; }
}
