/* ================================================
   ONLY ToP - AI Conference Paper Search
   Clean Google-like Design with Purple Accent
   ================================================ */

:root {
    --primary: #7C3AED;
    --primary-dark: #6D28D9;
    --primary-light: #A78BFA;
    --primary-bg: #F5F3FF;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --bg-white: #FFFFFF;
    --bg-gray: #F9FAFB;
    --border: #D1D5DB;
    --border-light: #E5E7EB;
    --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);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-white);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Content Wrapper - Main + Sidebar */
.content-wrapper {
    display: flex;
    flex: 1;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    gap: 24px;
    padding: 0 24px;
}

/* ================================================
   Top Navigation
   ================================================ */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-white);
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.data-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.loaded {
    background: #10B981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.nav-btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn.login-btn {
    background: var(--primary);
    color: white;
}

.nav-btn.login-btn:hover {
    background: var(--primary-dark);
}

.nav-btn.logout-btn {
    background: var(--bg-gray);
    color: var(--text-secondary);
}

.nav-btn.logout-btn:hover {
    background: var(--border);
}

.user-info {
    display: none;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

.user-info.show {
    display: flex;
}

/* ================================================
   Main Content
   ================================================ */
.main-content {
    flex: 1;
    min-width: 0;
    padding: 40px 0;
}

/* ================================================
   Logo Section
   ================================================ */
.logo-section {
    text-align: center;
    margin-bottom: 40px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 2rem;
    font-weight: 700;
}

.logo-highlight {
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    letter-spacing: -0.02em;
}

.logo-text {
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ================================================
   Search Section
   ================================================ */
.search-section {
    display: block;
}

.search-container {
    margin-bottom: 32px;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-white);
    border: 2px solid #B8BCC4;
    border-radius: var(--radius-full);
    padding: 4px 4px 4px 20px;
    max-width: 720px;
    margin: 0 auto;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.search-bar:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.search-icon {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    padding: 12px 16px;
    background: transparent;
    color: var(--text-primary);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.match-mode-select {
    padding: 10px 12px;
    border: none;
    border-left: 1px solid var(--border);
    background: transparent;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    outline: none;
}

.search-btn {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.search-btn:hover {
    background: var(--primary-dark);
}

.search-limit-indicator {
    display: none;
    text-align: center;
    margin-top: 12px;
    padding: 8px 16px;
    background: #FEF3C7;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: #92400E;
}

/* ================================================
   Bento Grid Filters
   ================================================ */
.bento-grid {
    display: grid;
    grid-template-columns: 160px auto 1fr;
    grid-template-rows: auto;
    gap: 16px;
    margin-top: 24px;
}

/* When Most Favorited is hidden, use 2-column layout */
.bento-grid.two-columns {
    grid-template-columns: 160px 1fr;
}

.bento-card {
    background: var(--bg-white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.bento-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.conf-count {
    font-weight: 400;
    color: var(--text-muted);
}

/* Year Filter */
.bento-year {
    grid-column: 1;
    grid-row: 1;
}

.year-select {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--bg-white);
    cursor: pointer;
    color: var(--text-primary);
}

.year-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-bg);
}

/* Year Mode Buttons */
.year-mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 10px;
}

.year-mode-buttons.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.year-mode-btn {
    flex: 1;
    padding: 6px 8px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.year-mode-btn:hover {
    background: var(--bg-gray);
    border-color: var(--primary-light);
    color: var(--primary);
}

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

.area-filters {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.area-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.area-checkbox:hover {
    background: var(--bg-gray);
    border-color: var(--border-light);
}

.area-checkbox input {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

.area-label {
    font-size: 13px;
    color: var(--text-primary);
}

.area-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.area-action-btn {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

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

.area-action-deselect:hover {
    background: var(--text-muted);
    border-color: var(--text-muted);
}

/* Conference Filter */
.bento-conferences {
    grid-column: 2;
    grid-row: 1;
    width: fit-content;
    max-width: 100%;
}

/* Most Favorited Filter */
.bento-most-favorited {
    grid-column: 3;
    grid-row: 1;
    max-height: 400px;
    overflow-y: auto;
    min-width: 280px;
}

.bento-most-favorited::-webkit-scrollbar {
    width: 4px;
}

.bento-most-favorited::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.bento-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.bento-title-row .bento-title {
    margin-bottom: 0;
}

.most-favorited-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.conference-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Row container for multiple blocks */
.conference-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
}

/* Individual area block */
.conference-block {
    background: var(--bg-gray);
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px;
    display: inline-flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s;
    flex: 0 1 auto;
}

.conference-block:hover {
    border-color: var(--primary-light);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.1);
}

/* Items container within a block */
.conference-block-items {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}

.conference-area-header {
    padding: 5px 8px;
    background: var(--primary-bg);
    color: var(--primary);
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin: 0;
}

/* Area header with checkbox */
.area-header-checkbox {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.area-header-checkbox:hover {
    background: var(--primary-light);
    color: white;
}

.area-header-checkbox input {
    accent-color: var(--primary-dark);
    width: 12px;
    height: 12px;
    cursor: pointer;
    flex-shrink: 0;
}

.area-header-checkbox span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.area-header-checkbox.checked {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
}

.area-header-checkbox:not(.checked) {
    background: var(--bg-gray);
    color: var(--text-secondary);
    border-color: var(--border);
}

.conf-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    border: 1.5px solid var(--border-light);
    font-size: 13px;
    font-weight: 500;
    flex-shrink: 0;
}

.conf-checkbox:hover {
    background: var(--border-light);
    border-color: var(--border);
}

.conf-checkbox.checked {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary-dark);
}

.conf-checkbox input {
    accent-color: var(--primary);
    width: 14px;
    height: 14px;
}

/* ================================================
   Results Section
   ================================================ */
.results-section {
    margin-top: 40px;
    padding-top: 32px;
    border-top: 1.5px solid var(--border);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.results-count {
    font-size: 14px;
    color: var(--text-secondary);
}

.results-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.favorites-filter {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-gray);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
}

.favorites-filter input {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

.favorites-label {
    color: var(--text-secondary);
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.export-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

/* Papers Grid */
.papers-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.paper-card {
    background: var(--bg-white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.paper-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.paper-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.badge {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    background: var(--primary);
    color: white;
}

.badge-year {
    background: var(--text-muted);
}

.paper-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 8px;
}

.paper-title a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s;
}

.paper-title a:hover {
    color: var(--primary);
}

.paper-author {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.paper-links {
    display: flex;
    gap: 8px;
}

.paper-link {
    padding: 6px 12px;
    background: var(--bg-gray);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: all 0.2s;
}

.paper-link:hover {
    background: var(--primary);
    color: white;
}

/* No Results / Loading */
.no-results, .loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.no-results h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.no-results p {
    font-size: 14px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

/* Highlight */
.highlight {
    background: var(--primary-bg);
    color: var(--primary-dark);
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 500;
}

/* Info Box */
.info-box {
    background: var(--primary-bg);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    border-left: 3px solid var(--primary);
    color: var(--primary-dark);
}

/* ================================================
   Right Sidebar - Most Favorited
   ================================================ */
.sidebar-right {
    width: 280px;
    flex-shrink: 0;
    padding: 40px 0;
    flex-direction: column;
}

.sidebar-right.hidden {
    display: none !important;
}

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--primary-bg);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
}

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

.sidebar-toggle-btn.show {
    display: flex;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary);
}

.sidebar-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.refresh-btn-small {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
}

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

.sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Compact Favorited Card */
.mf-compact-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    transition: all 0.15s;
    cursor: pointer;
}

.mf-compact-card:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.mf-compact-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.mf-compact-rank {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.mf-compact-rank.gold {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #333;
}

.mf-compact-rank.silver {
    background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
    color: #333;
}

.mf-compact-rank.bronze {
    background: linear-gradient(135deg, #cd7f32 0%, #e6a75f 100%);
    color: white;
}

.mf-compact-rank.default {
    background: var(--bg-gray);
    color: var(--text-secondary);
}

.mf-compact-count {
    font-size: 10px;
    color: var(--primary);
    font-weight: 600;
    margin-left: auto;
}

.mf-compact-badges {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.mf-compact-badges .badge {
    font-size: 9px;
    padding: 2px 6px;
}

.mf-compact-title {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.mf-compact-title a {
    color: inherit;
    text-decoration: none;
}

.mf-compact-title a:hover {
    color: var(--primary);
}

.mf-compact-author {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mf-compact-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border-light);
}

.mf-compact-fav {
    background: none;
    border: none;
    font-size: 1em;
    cursor: pointer;
    padding: 2px;
    color: var(--text-muted);
    transition: all 0.15s;
}

.mf-compact-fav:hover,
.mf-compact-fav.favorited {
    color: var(--primary);
}

.mf-compact-link {
    font-size: 10px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 3px;
    transition: all 0.15s;
}

.mf-compact-link:hover {
    background: var(--primary);
    color: white;
}

/* ================================================
   Responsive Design
   ================================================ */

/* Medium screens - adjust block sizing */
@media (max-width: 1200px) and (min-width: 901px) {
    .conference-block {
        padding: 6px;
    }

    .conference-area-header {
        font-size: 9px;
        padding: 4px 6px;
    }

    .conf-checkbox {
        font-size: 12px;
        padding: 6px 10px;
    }
}

/* Small screens - more compact layout */
@media (max-width: 1100px) and (min-width: 901px) {
    .bento-grid {
        grid-template-columns: 140px auto 1fr;
    }

    .bento-most-favorited {
        min-width: 240px;
    }

    .mf-compact-title {
        font-size: 11px;
    }
}

@media (max-width: 900px) and (min-width: 601px) {
    .bento-grid {
        grid-template-columns: 130px 1fr;
    }

    .bento-most-favorited {
        grid-column: 1 / -1;
        grid-row: 2;
        max-height: 300px;
    }

    .sidebar-toggle-btn {
        display: none !important;
    }

    .conference-block {
        padding: 5px;
    }

    .conference-area-header {
        font-size: 9px;
        padding: 4px 6px;
    }

    .conf-checkbox {
        font-size: 11px;
        padding: 5px 8px;
        gap: 4px;
    }

    .conf-checkbox input {
        width: 12px;
        height: 12px;
    }
}

/* Tablet and mobile */
@media (max-width: 768px) {
    .main-content {
        padding: 24px 16px;
    }

    .logo {
        flex-direction: column;
        gap: 8px;
        font-size: 1.5rem;
    }

    .search-bar {
        flex-wrap: wrap;
        border-radius: var(--radius-md);
        padding: 8px;
    }

    .search-icon {
        display: none;
    }

    .search-input {
        width: 100%;
        padding: 12px;
    }

    .match-mode-select {
        border-left: none;
        border-top: 1px solid var(--border);
        flex: 1;
    }

    .search-btn {
        flex: 1;
        border-radius: var(--radius-sm);
    }

    .bento-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .bento-year {
        grid-column: 1;
        grid-row: auto;
    }

    .bento-conferences {
        grid-column: 1;
        grid-row: auto;
    }

    /* Block layout responsive - rows become columns on mobile */
    .conference-row {
        flex-direction: column;
    }

    .conference-block {
        width: 100%;
        flex: 0 0 auto;
    }

    .conference-block-items {
        justify-content: flex-start;
    }

    .conf-checkbox {
        font-size: 11px;
        padding: 4px 6px;
    }

    .area-header-checkbox {
        font-size: 10px;
    }

    .results-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .results-actions {
        width: 100%;
        justify-content: space-between;
    }

    /* Most Favorited on mobile - full width below other cards */
    .bento-most-favorited {
        grid-column: 1;
        grid-row: auto;
        max-height: 250px;
    }

    .sidebar-toggle-btn {
        display: none !important;
    }
}
