/* ============================================
   Q-SEnSE Publications Database - Stylesheet
   Author: Antoni Czolgowski
   ============================================ */

/* CSS Variables */
:root {
    /* CU Boulder Colors */
    --gold: #CFB87C;
    --gold-dark: #A89157;
    --gold-light: #E8D9A8;
    --black: #000000;
    --white: #FFFFFF;
    
    /* Extended Palette */
    --gray-50: #FAFAFA;
    --gray-100: #F5F5F5;
    --gray-200: #EEEEEE;
    --gray-300: #E0E0E0;
    --gray-400: #BDBDBD;
    --gray-500: #9E9E9E;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;
    
    /* Semantic Colors */
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-600);
    --text-muted: var(--gray-500);
    --border-color: var(--gray-300);
    --bg-primary: var(--white);
    --bg-secondary: var(--gray-50);
    
    /* Type Colors */
    --journal-color: #1565C0;
    --arxiv-color: #B71C1C;
    --proceedings-color: #2E7D32;
    
    /* Typography */
    --font-display: 'DM Serif Display', Georgia, serif;
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Prevent SVG from growing infinitely */
svg {
    display: inline-block;
    vertical-align: middle;
    max-width: 100%;
    max-height: 100%;
}

/* Default icon size */
svg:not(.title-logo):not([class]) {
    width: 1em;
    height: 1em;
}

/* Force all inline SVG icons to reasonable size */
.investigators-filter svg,
.dropdown-search svg,
.dropdown-info svg,
.investigators-label svg,
.investigator-tag svg,
.investigator-checkbox svg,
.search-box svg {
    width: 20px !important;
    height: 20px !important;
    flex-shrink: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   Top Navigation (Minimal)
   ============================================ */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-xl);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--gray-700);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.back-link:hover {
    color: var(--gold-dark);
    background: rgba(207, 184, 124, 0.1);
}

.back-link svg {
    width: 18px;
    height: 18px;
}

.nav-links {
    display: flex;
    gap: var(--space-lg);
}

.nav-links a {
    color: var(--gray-600);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.nav-links a:hover {
    color: var(--gold-dark);
    background: rgba(207, 184, 124, 0.1);
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: var(--space-2xl) var(--space-xl);
}

/* Title Section */
.title-section {
    margin-bottom: var(--space-2xl);
}

.title-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xl);
}

.title-logo {
    width: 210px;
    height: auto;
    flex-shrink: 0;
}

.title-text {
    text-align: left;
}

.title-text h2 {
    font-family: var(--font-display);
    font-size: 2.25rem;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.subtitle span {
    font-weight: 600;
    color: var(--gold-dark);
}

/* ============================================
   Filters Section
   ============================================ */
.filters-section {
    margin-bottom: var(--space-xl);
}

.filters-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    align-items: flex-end;
    box-shadow: var(--shadow-sm);
}

.search-box {
    flex: 1;
    min-width: 280px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--gray-400);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: var(--space-md) var(--space-md) var(--space-md) 48px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(207, 184, 124, 0.2);
}

.search-box input::placeholder {
    color: var(--gray-400);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.filter-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-group select {
    padding: var(--space-md) var(--space-lg) var(--space-md) var(--space-md);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 1rem;
    background: var(--white);
    cursor: pointer;
    min-width: 150px;
    transition: all var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23757575' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(207, 184, 124, 0.2);
}

.clear-btn {
    padding: var(--space-md) var(--space-lg);
    background: transparent;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.clear-btn:hover {
    border-color: var(--gray-400);
    color: var(--text-primary);
    background: var(--gray-100);
}

/* ============================================
   Investigators Filter (Multi-Select)
   ============================================ */
.investigators-filter-container {
    margin-top: var(--space-md);
}

.investigators-filter {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    position: relative;
}

.investigators-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-radius: var(--radius-lg);
}

.investigators-header:hover {
    background: var(--gray-50);
}

.investigators-filter.open .investigators-header {
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.investigators-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
}

.investigators-label svg {
    width: 20px;
    height: 20px;
    color: var(--gold-dark);
}

.investigators-selected {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    align-items: center;
    min-height: 32px;
}

.placeholder-text {
    color: var(--gray-400);
    font-size: 0.9rem;
    font-style: italic;
}

.investigator-tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
    color: var(--gray-800);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    animation: tagAppear 0.2s ease;
}

@keyframes tagAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.investigator-tag button {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
    margin-left: var(--space-xs);
    cursor: pointer;
    color: var(--gray-700);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    transition: all var(--transition-fast);
}

.investigator-tag button:hover {
    background: rgba(0, 0, 0, 0.15);
    color: var(--gray-900);
}

.investigator-tag button svg {
    width: 12px;
    height: 12px;
}

.clear-all-tags {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: var(--gray-200);
    color: var(--gray-600);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.clear-all-tags:hover {
    background: var(--gray-300);
    color: var(--gray-800);
}

.dropdown-arrow {
    width: 20px;
    height: 20px;
    color: var(--gray-400);
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

.investigators-filter.open .dropdown-arrow {
    transform: rotate(180deg);
}

/* Dropdown Panel */
.investigators-dropdown {
    display: none;
    border-top: none;
}

.investigators-filter.open .investigators-dropdown {
    display: block;
}

.dropdown-search {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--gray-200);
    position: relative;
}

.dropdown-search svg {
    position: absolute;
    left: calc(var(--space-lg) + var(--space-sm));
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--gray-400);
    pointer-events: none;
}

.dropdown-search input {
    width: 100%;
    padding: var(--space-sm) var(--space-sm) var(--space-sm) 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.dropdown-search input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(207, 184, 124, 0.2);
}

.dropdown-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.dropdown-info svg {
    width: 16px;
    height: 16px;
    color: var(--gold-dark);
    flex-shrink: 0;
}

.dropdown-info strong {
    color: var(--gold-dark);
}

.investigators-list {
    list-style: none;
    max-height: 280px;
    overflow-y: auto;
    padding: var(--space-sm) 0;
}

.investigators-list::-webkit-scrollbar {
    width: 8px;
}

.investigators-list::-webkit-scrollbar-track {
    background: var(--gray-100);
}

.investigators-list::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

.investigators-list::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

.investigator-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.investigator-item:hover {
    background: var(--gray-100);
}

.investigator-item.selected {
    background: rgba(207, 184, 124, 0.15);
}

.investigator-item.hidden {
    display: none;
}

.investigator-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--gray-400);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.investigator-item.selected .investigator-checkbox {
    background: var(--gold);
    border-color: var(--gold-dark);
}

.investigator-checkbox svg {
    width: 12px;
    height: 12px;
    color: var(--white);
    opacity: 0;
    transform: scale(0.5);
    transition: all var(--transition-fast);
}

.investigator-item.selected .investigator-checkbox svg {
    opacity: 1;
    transform: scale(1);
}

.investigator-name {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.investigator-name .surname {
    font-weight: 600;
}

.no-results {
    padding: var(--space-lg);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================================
   Results Info
   ============================================ */
.results-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding: 0 var(--space-sm);
    flex-wrap: wrap;
    gap: var(--space-md);
}

#results-count {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.sort-controls label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.sort-controls select {
    padding: var(--space-sm) var(--space-lg) var(--space-sm) var(--space-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.9rem;
    background: var(--white);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23757575' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

/* ============================================
   Table Section
   ============================================ */
.table-section {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.table-container {
    overflow-x: auto;
}

#publications-table {
    width: 100%;
    border-collapse: collapse;
}

#publications-table thead {
    background: linear-gradient(135deg, var(--gray-800) 0%, var(--gray-900) 100%);
    color: var(--white);
}

#publications-table th {
    padding: var(--space-md) var(--space-lg);
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    position: relative;
}

#publications-table th.col-date {
    width: 100px;
}

#publications-table th.col-title {
    min-width: 300px;
}

#publications-table th.col-authors {
    min-width: 200px;
}

#publications-table th.col-type {
    width: 140px;
}

#publications-table th.col-doi {
    width: 100px;
}

.sort-indicator {
    margin-left: var(--space-xs);
    opacity: 0.6;
    font-size: 0.75rem;
}

#publications-table tbody tr {
    border-bottom: 1px solid var(--gray-200);
    transition: background-color var(--transition-fast);
}

#publications-table tbody tr:hover {
    background-color: rgba(207, 184, 124, 0.08);
}

#publications-table tbody tr:last-child {
    border-bottom: none;
}

#publications-table td {
    padding: var(--space-md) var(--space-lg);
    vertical-align: top;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Date Cell */
.date-cell {
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Title Cell */
.title-cell {
    color: var(--text-primary);
    font-weight: 500;
}

/* Authors Cell */
.authors-cell {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Type Badge */
.type-badge {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.type-badge.journal {
    background: rgba(21, 101, 192, 0.1);
    color: var(--journal-color);
}

.type-badge.arxiv {
    background: rgba(183, 28, 28, 0.1);
    color: var(--arxiv-color);
}

.type-badge.proceedings {
    background: rgba(46, 125, 50, 0.1);
    color: var(--proceedings-color);
}

/* DOI Link */
.doi-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--gold-dark);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.doi-link:hover {
    background: rgba(207, 184, 124, 0.15);
    color: var(--gold-dark);
}

.doi-link svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ============================================
   Loading & Empty States
   ============================================ */
.loading-state,
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-3xl);
    text-align: center;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: var(--space-md);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--gray-300);
    margin-bottom: var(--space-md);
}

.empty-state p {
    margin-bottom: var(--space-md);
}

.empty-state button {
    padding: var(--space-sm) var(--space-lg);
    background: var(--gold);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--black);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.empty-state button:hover {
    background: var(--gold-dark);
}

/* ============================================
   Footer
   ============================================ */
.footer {
    background: var(--gray-900);
    color: var(--gray-300);
    padding: var(--space-xl) var(--space-xl);
    margin-top: auto;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    text-align: left;
    padding-left: var(--space-lg);
}

.footer-content h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--gold);
    margin-bottom: var(--space-md);
}

.nsf-disclaimer {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--gray-400);
    max-width: 800px;
    margin-bottom: var(--space-md);
}

.footer-email {
    display: inline-block;
    color: var(--gold);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    padding: var(--space-sm) 0;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.footer-email:hover {
    color: var(--gold-light);
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1024px) {
    .filters-container {
        flex-direction: column;
    }
    
    .search-box {
        min-width: 100%;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-group select {
        width: 100%;
    }
    
    .clear-btn {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .top-nav {
        flex-direction: column;
        gap: var(--space-md);
        padding: var(--space-md);
    }
    
    .main-content {
        padding: var(--space-lg);
    }
    
    .title-wrapper {
        flex-direction: column;
        text-align: center;
    }
    
    .title-text {
        text-align: center;
    }
    
    .title-logo {
        width: 180px;
    }
    
    .title-text h2 {
        font-size: 1.75rem;
    }
    
    #publications-table th,
    #publications-table td {
        padding: var(--space-sm) var(--space-md);
    }
    
    .results-info {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .footer {
        padding: var(--space-lg);
    }
    
    .footer-content h3 {
        font-size: 1.1rem;
    }
    
    .nsf-disclaimer {
        font-size: 0.8rem;
    }
    
    /* Investigators Filter Mobile */
    .investigators-header {
        flex-wrap: wrap;
    }
    
    .investigators-label {
        width: 100%;
        margin-bottom: var(--space-xs);
    }
    
    .investigators-selected {
        width: calc(100% - 28px);
    }
    
    .dropdown-arrow {
        position: absolute;
        right: var(--space-lg);
        top: var(--space-md);
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .top-nav,
    .filters-section,
    .results-info,
    .footer {
        display: none;
    }
    
    .table-section {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    #publications-table thead {
        background: #f0f0f0 !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact;
    }
}
