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

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --text-color: #333;
    --bg-color: #f8f9fa;
    --white: #ffffff;
    --border-color: #dee2e6;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
}

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

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

/* Header */
header {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 1rem 0;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

header h1 {
    font-size: 1.5rem;
    margin: 0;
}

header h1 a {
    color: var(--white);
    text-decoration: none;
}

nav {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

nav a {
    color: var(--white);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

nav a:hover,
nav a.active {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 3rem 0;
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    color: var(--white);
    margin-bottom: 2rem;
    border-radius: 8px;
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

.search-box {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    gap: 0.5rem;
}

.search-box input {
    flex: 1;
    padding: 0.75rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
}

.search-box button {
    padding: 0.75rem 2rem;
    background-color: var(--accent-color);
    color: var(--white);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.search-box button:hover {
    background-color: #c0392b;
}

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.stat-item {
    background: var(--white);
    padding: 2rem;
    text-align: center;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stat-item h3 {
    font-size: 2.5rem;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
}

.stat-item p {
    color: var(--text-color);
    font-size: 1.1rem;
}

/* Collections */
.collections {
    margin-bottom: 3rem;
}

.collections h2 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.collection-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
}

.collection-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.collection-card h3 {
    margin-bottom: 0.5rem;
}

.collection-card h3 a {
    color: var(--primary-color);
    text-decoration: none;
}

.collection-card h3 a:hover {
    color: var(--secondary-color);
}

.collection-card p {
    color: #666;
    margin-bottom: 1rem;
}

.item-count {
    display: inline-block;
    background-color: var(--bg-color);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.9rem;
    color: var(--text-color);
}

/* Items Grid */
.recent-items {
    margin-bottom: 3rem;
}

.recent-items h2 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.item-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: transform 0.3s;
}

.item-card:hover {
    transform: translateY(-3px);
}

.item-card h3 {
    margin-bottom: 0.5rem;
}

.item-card h3 a {
    color: var(--primary-color);
    text-decoration: none;
}

.item-card h3 a:hover {
    color: var(--secondary-color);
}

.item-card .author {
    color: var(--secondary-color);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.item-card .abstract {
    color: #666;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.item-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    color: #999;
}

.item-meta .collection {
    background-color: var(--bg-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

/* Language switcher */
.lang-switcher {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.lang-switcher a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 0.95rem;
}
.lang-switcher a.active-lang {
    font-weight: bold;
    text-decoration: underline;
}
.lang-switcher a:hover {
    color: var(--white);
}

/* Main layout with sidebar (DSpace-style) — бічна панель зліва */
.main-with-sidebar {
    display: grid;
    grid-template-columns: 260px 1fr;
    grid-template-areas: "sidebar content";
    gap: 2rem;
    margin-top: 1.5rem;
    align-items: start;
}

.main-with-sidebar .site-sidebar {
    grid-area: sidebar;
    grid-column: 1;
    width: 260px;
    min-width: 260px;
    max-width: 260px;
}

.main-with-sidebar .main-content {
    grid-area: content;
    grid-column: 2;
    min-width: 0;
}

.site-sidebar {
    background: var(--white);
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 20px;
}

.sidebar-section {
    margin-bottom: 1.5rem;
}
.sidebar-section:last-child {
    margin-bottom: 0;
}

.sidebar-title {
    font-size: 1rem;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-list {
    list-style: none;
}
.sidebar-list li {
    margin-bottom: 0.35rem;
}
.sidebar-list a {
    display: block;
    padding: 0.4rem 0;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}
.sidebar-list a:hover,
.sidebar-list a.active {
    background-color: var(--bg-color);
    color: var(--secondary-color);
}
.sidebar-list .count {
    color: #999;
    font-size: 0.85rem;
}
.sidebar-user {
    font-weight: 500;
    color: var(--primary-color);
}
.facet-list a {
    font-size: 0.9rem;
}

/* Browse Layout (legacy, kept for compatibility) */
.browse-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

.sidebar {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    height: fit-content;
    position: sticky;
    top: 20px;
}

.sidebar h2 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.collection-list {
    list-style: none;
}

.collection-list li {
    margin-bottom: 0.5rem;
}

.collection-list a {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.collection-list a:hover,
.collection-list a.active {
    background-color: var(--bg-color);
    color: var(--secondary-color);
}

.collection-list .count {
    color: #999;
    font-size: 0.9rem;
}

.content h1 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.items-list {
    margin-top: 2rem;
}

.item-row {
    background: var(--white);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.item-row h3 {
    margin-bottom: 0.5rem;
}

.item-row h3 a {
    color: var(--primary-color);
    text-decoration: none;
}

.item-row h3 a:hover {
    color: var(--secondary-color);
}

.no-results {
    text-align: center;
    padding: 3rem;
    color: #999;
    font-size: 1.1rem;
}

/* Item Detail */
.item-detail {
    background: var(--white);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-top: 2rem;
}

.item-detail h1 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.item-info {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.info-row {
    display: flex;
    margin-bottom: 0.75rem;
}

.info-row strong {
    min-width: 150px;
    color: var(--primary-color);
}

.abstract,
.description {
    margin-bottom: 2rem;
}

.abstract h2,
.description h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.files {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.files h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.file-list {
    list-style: none;
}

.file-list li {
    padding: 1rem;
    background: var(--bg-color);
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

.file-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 500;
}

.file-link:hover {
    text-decoration: underline;
}

.file-size {
    color: #999;
    font-size: 0.9rem;
}

.file-description {
    margin-top: 0.5rem;
    color: #666;
    font-size: 0.9rem;
}

/* Forms */
.submit-form {
    background: var(--white);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-width: 800px;
    margin: 2rem auto;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: #999;
    font-size: 0.9rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.form-actions button {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

.form-actions button[type="submit"] {
    background-color: var(--secondary-color);
    color: var(--white);
}

.form-actions button[type="submit"]:hover {
    background-color: #2980b9;
}

.form-actions button[type="button"] {
    background-color: var(--border-color);
    color: var(--text-color);
}

.form-actions button[type="button"]:hover {
    background-color: #ccc;
}

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

.modal-content {
    background-color: var(--white);
    margin: 10% auto;
    padding: 2rem;
    border-radius: 8px;
    max-width: 400px;
    position: relative;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
}

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

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

.modal-content input {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.modal-content button {
    padding: 0.75rem;
    background-color: var(--secondary-color);
    color: var(--white);
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Admin */
.admin-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 1rem 2rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-color);
    transition: all 0.3s;
}

.tab-btn:hover,
.tab-btn.active {
    color: var(--secondary-color);
    border-bottom-color: var(--secondary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.admin-items {
    display: grid;
    gap: 1rem;
}

.admin-item-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.admin-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.admin-actions button,
.admin-actions a {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.9rem;
}

.admin-actions button:first-child {
    background-color: var(--secondary-color);
    color: var(--white);
}

.admin-actions button:last-child {
    background-color: var(--accent-color);
    color: var(--white);
}

.admin-actions a {
    background-color: var(--bg-color);
    color: var(--text-color);
}

.collection-form {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

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

.collections-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.collection-admin-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

/* Footer */
footer {
    background-color: var(--primary-color);
    color: var(--white);
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
}

/* Responsive */
@media (max-width: 768px) {
    .main-with-sidebar,
    .browse-layout {
        grid-template-columns: 1fr;
        grid-template-areas: "sidebar" "content";
    }
    
    .main-with-sidebar .site-sidebar {
        grid-column: auto;
        width: 100%;
        min-width: 0;
        max-width: none;
    }
    
    .main-with-sidebar .main-content {
        grid-column: auto;
    }
    
    .site-sidebar,
    .sidebar {
        position: static;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    nav {
        margin-top: 1rem;
        width: 100%;
    }
    
    .hero h2 {
        font-size: 2rem;
    }
    
    .search-box {
        flex-direction: column;
    }
}
