/* ==========================================================================
   CFPlease — Custom Properties & Theming
   ========================================================================== */

:root,
[data-theme="light"] {
    --color-bg: #ffffff;
    --color-surface: #f8f9fa;
    --color-surface-hover: #e9ecef;
    --color-border: #dee2e6;
    --color-text: #212529;
    --color-text-secondary: #6c757d;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-text: #ffffff;
    --color-success: #16a34a;
    --color-danger: #dc2626;
    --color-badge-new: #16a34a;
    --color-badge-updated: #2563eb;
    --color-badge-active: #16a34a;
    --color-badge-expired: #9ca3af;
    --color-overlay: rgba(0, 0, 0, 0.5);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-card-hover: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-panel: 0 8px 30px rgba(0, 0, 0, 0.12);
    --radius: 8px;
    --radius-sm: 4px;
}

[data-theme="dark"] {
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-surface-hover: #334155;
    --color-border: #334155;
    --color-text: #e2e8f0;
    --color-text-secondary: #94a3b8;
    --color-primary: #60a5fa;
    --color-primary-hover: #3b82f6;
    --color-primary-text: #0f172a;
    --color-success: #4ade80;
    --color-danger: #f87171;
    --color-badge-new: #4ade80;
    --color-badge-updated: #60a5fa;
    --color-badge-active: #4ade80;
    --color-badge-expired: #64748b;
    --color-overlay: rgba(0, 0, 0, 0.7);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-card-hover: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-panel: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button {
    cursor: pointer;
    font: inherit;
}

code {
    background: var(--color-surface);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.75rem 2rem;
}

.nav-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
}

.nav-logo:hover {
    text-decoration: none;
    color: var(--color-primary);
}

.nav-version {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    color: var(--color-text-secondary);
    font-size: 0.85rem;
}

.btn-icon:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

/* Show/hide theme labels based on current theme */
[data-theme="light"] .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark { display: inline; }
[data-theme="dark"] .theme-icon-light { display: inline; }
[data-theme="dark"] .theme-icon-dark { display: none; }

/* ==========================================================================
   Page Layout
   ========================================================================== */

.main-content {
    max-width: 1400px;
    margin: 0 auto;
}

.page-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 2rem;
    padding: 1.5rem 2rem;
}

/* ==========================================================================
   Filter Panel
   ========================================================================== */

.filter-panel {
    position: sticky;
    top: 4rem;
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
    padding-right: 0.5rem;
}

.filter-group {
    margin-bottom: 1.25rem;
}

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

.filter-group select,
.filter-group input[type="search"],
.filter-group input[type="number"],
.filter-group input[type="text"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 0.9rem;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: -1px;
}

.filter-subgroup {
    margin-top: 0.5rem;
}

.filter-subgroup label {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.25rem;
}

.tag-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.tag-clear {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    cursor: pointer;
}

.tag-clear:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.tag-checkboxes {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    background: var(--color-bg);
}

.tag-checkbox {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0;
    font-size: 0.85rem;
    cursor: pointer;
}

.tag-checkbox input[type="checkbox"] {
    margin: 0;
    accent-color: var(--color-primary);
}

.tag-count {
    color: var(--color-text-secondary);
    font-size: 0.8rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
    accent-color: var(--color-primary);
}

.view-toggle {
    display: flex;
    gap: 0.25rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.view-btn {
    flex: 1;
    padding: 0.4rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    text-align: center;
}

.view-btn:hover {
    background: var(--color-surface-hover);
}

.view-btn.active {
    background: var(--color-primary);
    color: var(--color-primary-text);
    border-color: var(--color-primary);
}

/* ==========================================================================
   Results
   ========================================================================== */

.results-container {
    min-height: 400px;
}

.results-header {
    margin-bottom: 1rem;
}

.results-count {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin: 0;
}

/* Card grid view */
.results-grid[data-view="cards"] {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

/* Row/list view */
.results-grid[data-view="rows"] {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.results-grid[data-view="rows"] .cfp-card {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
}

.results-grid[data-view="rows"] .cfp-card-header {
    flex: 0 0 auto;
    min-width: 250px;
    margin-bottom: 0;
}

.results-grid[data-view="rows"] .cfp-card-body {
    flex: 1;
}

.results-grid[data-view="rows"] .cfp-card-desc {
    display: none;
}

.results-grid[data-view="rows"] .cfp-card-actions {
    flex: 0 0 auto;
    margin-top: 0;
    padding-top: 0;
}

/* ==========================================================================
   CFP Card
   ========================================================================== */

.cfp-card {
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
    box-shadow: var(--shadow-card);
}

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

.cfp-card:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.cfp-card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.cfp-card-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    color: var(--color-text);
}

.cfp-card-year {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.cfp-card-body {
    flex: 1;
}

.cfp-card-desc {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin: 0 0 0.75rem 0;
    line-height: 1.4;
}

.cfp-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-bottom: 0.75rem;
}

.cfp-meta-item {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.cfp-expired {
    color: var(--color-danger);
}

.cfp-location-type {
    text-transform: capitalize;
}

.cfp-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.cfp-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.75rem;
}

/* ==========================================================================
   Badges
   ========================================================================== */

.cfp-badges {
    display: flex;
    gap: 0.35rem;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-new {
    background: var(--color-badge-new);
    color: #fff;
}

.badge-updated {
    background: var(--color-badge-updated);
    color: #fff;
}

.badge-active {
    background: var(--color-badge-active);
    color: #fff;
}

.badge-expired {
    background: var(--color-badge-expired);
    color: #fff;
}

/* ==========================================================================
   Tags
   ========================================================================== */

.tag {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: var(--color-surface-hover);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.tag-more {
    font-style: italic;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-primary-text);
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    color: var(--color-primary-text);
}

.btn-secondary {
    background: transparent;
    border-color: var(--color-border);
    color: var(--color-text);
}

.btn-secondary:hover {
    background: var(--color-surface-hover);
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--color-text);
    text-decoration: none;
    cursor: pointer;
}

.pagination-link:hover {
    background: var(--color-surface-hover);
    text-decoration: none;
}

.pagination-current {
    background: var(--color-primary);
    color: var(--color-primary-text);
    border-color: var(--color-primary);
    cursor: default;
}

.pagination-ellipsis {
    padding: 0 0.25rem;
    color: var(--color-text-secondary);
}

.pagination-prev,
.pagination-next {
    padding: 0 0.75rem;
}

/* ==========================================================================
   Detail Panel (Modal/Overlay)
   ========================================================================== */

.detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
}

.detail-overlay[aria-hidden="false"] {
    pointer-events: auto;
}

.detail-panel {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem;
    overflow-y: auto;
}

.detail-panel-backdrop {
    position: fixed;
    inset: 0;
    background: var(--color-overlay);
}

.detail-panel-content {
    position: relative;
    width: 100%;
    max-width: 700px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-panel);
    margin-top: 2rem;
}

.detail-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-secondary);
    line-height: 1;
    padding: 0.25rem;
}

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

.detail-header {
    margin-bottom: 1.5rem;
}

.detail-header h2 {
    font-size: 1.4rem;
    margin: 0 0 0.5rem 0;
}

.detail-section {
    margin-bottom: 1.25rem;
}

.detail-section h3 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    margin: 0 0 0.5rem 0;
}

.detail-fields {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 1rem;
    margin: 0;
}

.detail-fields dt {
    font-weight: 500;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

.detail-fields dd {
    margin: 0;
    font-size: 0.9rem;
}

.format-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.format-list li {
    padding: 0.25rem 0;
    font-size: 0.9rem;
}

.detail-actions {
    display: flex;
    gap: 0.75rem;
    margin: 1.5rem 0;
}

.detail-sources {
    font-size: 0.85rem;
}

.detail-sources ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.detail-sources li {
    padding: 0.25rem 0;
}

.detail-sources time {
    color: var(--color-text-secondary);
    font-size: 0.8rem;
}

.detail-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    color: var(--color-text-secondary);
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: var(--color-text);
}

.empty-state-desc {
    color: var(--color-text-secondary);
    margin: 0;
}

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

@media (max-width: 768px) {
    .nav-bar {
        padding: 0.75rem 1rem;
    }

    .page-layout {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    .filter-panel {
        position: static;
        max-height: none;
        padding-right: 0;
    }

    .results-grid[data-view="cards"] {
        grid-template-columns: 1fr;
    }

    .results-grid[data-view="rows"] .cfp-card {
        flex-direction: column;
        align-items: stretch;
    }

    .results-grid[data-view="rows"] .cfp-card-header {
        min-width: 0;
    }

    .detail-panel {
        padding: 1rem;
    }

    .detail-panel-content {
        padding: 1.25rem;
        margin-top: 1rem;
    }
}
