@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

:root {
    --bg-color: #f8f9fa;
    --sidebar-bg: #ffffff;
    --text-color: #2c3e50;
    --text-muted: #95a5a6;
    --border-color: #eaecf0;
    --accent-color: #3498db;
    --accent-hover: #2980b9;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --sidebar-width: 260px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    box-shadow: var(--shadow-sm);
    z-index: 20;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-color);
    text-decoration: none;
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    margin-top: 15px;
    font-weight: 500;
    color: var(--text-color);
}

.reload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    width: 24px;
    height: 24px;
    transition: all 0.3s ease;
    text-decoration: none;
    margin-left: auto;
    /* Push to right */
}

.reload-btn:hover {
    color: var(--accent-color);
    transform: rotate(180deg);
}

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.sort-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 0;
    /* Override previous margin */
}

.sort-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sort-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.sort-item:hover {
    background-color: #f0f4f8;
    color: var(--accent-color);
}

.footer-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Image Toggle Switch */
.toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-color);
    font-weight: 500;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-color);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--accent-color);
}

input:checked+.slider:before {
    -webkit-transform: translateX(20px);
    -ms-transform: translateX(20px);
    transform: translateX(20px);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 32px 48px;
    overflow-y: auto;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.clerk-link a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    transition: all 0.2s;
}

.clerk-link a:hover {
    border-color: var(--text-muted);
    color: var(--text-color);
}

/* Table */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background-color: #fff;
    box-shadow: var(--shadow-sm);
    border-radius: 12px;
    overflow: hidden;
}

th,
td {
    padding: 12px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #fafbfc;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    z-index: 10;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background-color: #fafbfc;
}

.rank {
    width: 50px;
    text-align: center;
    color: var(--text-muted);
    font-weight: 500;
}

.image-cell {
    width: 120px;
    text-align: center;
}

.image-cell img {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    object-fit: cover;
    box-shadow: var(--shadow-sm);
    cursor: zoom-in;
    transition: transform 0.2s;
}

.image-cell img:hover {
    transform: scale(1.05);
}

.title-cell {
    vertical-align: middle;
}

.title-text {
    font-size: 0.95rem;
    font-weight: 400;
    /* Normal weight */
    vertical-align: middle;
}

.magnet-icon {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    /* Smaller */
    height: 24px;
    /* Smaller */
    border-radius: 50%;
    background-color: #f8f9fa;
    transition: all 0.2s;
    font-size: 1rem;
    /* Smaller icon */
}

.magnet-icon:hover {
    background-color: #e3f2fd;
    color: var(--accent-color);
}

/* Hide Images State */
body.hide-images .image-cell,
body.hide-images th.image-col {
    display: none;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: flex;
    opacity: 1;
    align-items: center;
    justify-content: center;
}

.modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s;
}

.modal.show .modal-content {
    transform: scale(1);
}

.close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: 300;
    transition: 0.2s;
    cursor: pointer;
    z-index: 1001;
}


/* Detail Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.gallery-item {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    background-color: #f0f0f0;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
    display: block;
}

.gallery-item img:hover {
    transform: scale(1.05);
}

.description-text {
    white-space: pre-wrap;
    line-height: 1.6;
    color: var(--text-color);
}