@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #dbeafe;
    --accent: #f59e0b;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --success-dark: #059669;
    --match-bg: #ecfdf5;
    --match-border: #6ee7b7;
    --connection-bg: #fef3c7;
    --connection-border: #fbbf24;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 24px rgba(0,0,0,0.12);
    --sidebar-width: 300px;
    --sidebar-bg: #0f172a;
    --sidebar-text: #e2e8f0;
    --sidebar-muted: #94a3b8;
    --sidebar-border: #1e293b;
    --sidebar-input-bg: #1e293b;
}

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

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

/* Header — compact */
header {
    background: var(--sidebar-bg);
    color: white;
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.header-content {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

.header-content h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.tagline {
    opacity: 0.5;
    font-size: 0.82rem;
    font-weight: 400;
}

/* App Layout — sidebar + main */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    max-width: 1400px;
    margin: 0 auto;
}

/* ─── Dark Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
    background: var(--sidebar-bg);
    padding: 1rem;
    overflow-y: auto;
    max-height: calc(100vh - 52px);
    position: sticky;
    top: 0;
    color: var(--sidebar-text);
}

.sidebar-section {
    padding-bottom: 0.85rem;
    margin-bottom: 0.85rem;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-section:last-of-type {
    border-bottom: none;
}

.sidebar-section h3 {
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
    color: var(--sidebar-text);
}

.sidebar-section.completed h3 {
    color: var(--success);
}

.sidebar label {
    color: var(--sidebar-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
}

.sidebar .status {
    color: var(--sidebar-muted);
    font-size: 0.8rem;
}

.sidebar .status.active {
    color: var(--success);
}

.sidebar input[type="text"],
.sidebar input[type="url"],
.sidebar input[type="date"] {
    background: var(--sidebar-input-bg);
    border: 1px solid var(--sidebar-border);
    color: var(--sidebar-text);
    font-size: 0.82rem;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.sidebar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.25);
}

.sidebar input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-small {
    padding: 0.4rem 0.65rem;
    font-size: 0.78rem;
    background: var(--primary);
    color: white;
    border-radius: 6px;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-search {
    margin-top: 0.75rem;
    padding: 0.6rem;
    font-size: 0.85rem;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    border-radius: 8px;
    letter-spacing: -0.01em;
}

.btn-search:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #6d28d9 100%);
    box-shadow: 0 4px 16px rgba(99,102,241,0.35);
}

.link-small {
    display: inline-block;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--primary);
    text-decoration: none;
    opacity: 0.8;
}

.link-small:hover { opacity: 1; }

/* Manual location input */
.manual-input {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.35rem;
}

.manual-input input {
    flex: 1;
    min-width: 0;
}

/* Generic form inputs (main area) */
input[type="text"],
input[type="url"],
input[type="date"] {
    width: 100%;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    transition: border-color 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 0.25rem;
    margin-top: 0.5rem;
}

/* Profile */
.profile-hint {
    font-size: 0.75rem;
    color: var(--sidebar-muted);
    margin-top: 0.5rem;
    line-height: 1.5;
    opacity: 0.8;
}

.profile-status {
    margin-top: 0.6rem;
}

.profile-status .detected-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.3rem;
}

.profile-status .detected-field {
    display: inline-flex;
    align-items: center;
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border: 1px solid rgba(110, 231, 183, 0.25);
    padding: 0.12rem 0.45rem;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 500;
}

.profile-status .status-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--success);
    margin-bottom: 0.15rem;
}

/* Analysis steps animation */
.analysis-step {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--sidebar-muted);
    padding: 0.2rem 0;
    transition: color 0.3s;
}

.analysis-step.active {
    color: var(--primary);
}

.analysis-step.done {
    color: var(--success);
}

.analysis-step .step-icon {
    width: 16px;
    text-align: center;
    font-size: 0.7rem;
}

/* Radius slider */
.radius-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

input[type="range"] {
    flex: 1;
    accent-color: var(--primary);
    height: 4px;
}

#radius-value {
    font-weight: 600;
    font-size: 0.8rem;
    white-space: nowrap;
    min-width: 42px;
    color: var(--sidebar-text);
}

.date-inputs {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.date-inputs input {
    flex: 1;
    min-width: 0;
    font-size: 0.78rem;
    padding: 0.4rem 0.45rem;
}

.date-inputs span {
    color: var(--sidebar-muted);
    font-size: 0.75rem;
}

/* ─── Main Content ─────────────────────────────────────────────────────────── */
.main-content {
    padding: 0;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.results-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Pill filter tabs with sliding highlight */
.filter-tabs {
    display: flex;
    background: var(--bg);
    border-radius: 24px;
    padding: 3px;
    gap: 2px;
}

.tab {
    padding: 0.35rem 0.9rem;
    border: none;
    background: none;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-light);
    border-radius: 20px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab:hover {
    color: var(--text);
    background: rgba(0,0,0,0.04);
}

.tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(59,130,246,0.25);
}

/* Map */
#map-container {
    border-bottom: 1px solid var(--border);
}

#map {
    height: 320px;
}

/* Leaflet popup overrides */
.leaflet-popup-content-wrapper {
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    border-radius: 10px;
    box-shadow: var(--shadow-md);
}

/* ─── Event Cards ──────────────────────────────────────────────────────────── */
#events-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 0;
    padding: 0;
}

.event-card {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    opacity: 0;
    animation: cardFadeIn 0.35s ease forwards;
}

.event-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: transparent;
    transition: background 0.2s;
    border-radius: 0 2px 2px 0;
}

.event-card:hover {
    background: #f1f5f9;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    z-index: 2;
}

.event-card:hover::before {
    background: var(--primary);
}

.event-card.field-match {
    background: linear-gradient(135deg, var(--match-bg) 0%, #f0fdf8 100%);
}

.event-card.field-match::before {
    background: linear-gradient(180deg, var(--success) 0%, #14b8a6 100%);
}

.event-card.connection-match {
    background: linear-gradient(135deg, var(--connection-bg) 0%, #fffbeb 100%);
}

.event-card.connection-match::before {
    background: linear-gradient(180deg, var(--accent) 0%, #f97316 100%);
}

.event-card.connection-match:hover::before,
.event-card.field-match:hover::before {
    width: 4px;
}

/* Staggered card entrance */
@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.event-date {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.event-title {
    font-size: 0.9rem;
    font-weight: 700;
    margin: 0.15rem 0;
    line-height: 1.35;
    letter-spacing: -0.01em;
}

.event-speaker {
    font-size: 0.82rem;
    color: var(--text);
    margin-bottom: 0.15rem;
}

.event-meta {
    font-size: 0.73rem;
    color: var(--text-light);
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

.event-tags {
    display: flex;
    gap: 0.2rem;
    flex-wrap: wrap;
    margin-top: 0.35rem;
}

.event-tag {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    background: #f1f5f9;
    color: var(--text-light);
    font-weight: 500;
}

.event-tag.match {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success-dark);
    border: 1px solid rgba(110, 231, 183, 0.4);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.12rem 0.45rem;
    border-radius: 10px;
    margin-left: 0.35rem;
    vertical-align: middle;
}

.badge-match {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success-dark);
}

.badge-connection {
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
}

.connection-info {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.73rem;
    color: #b45309;
    margin-top: 0.3rem;
    font-weight: 500;
}

.connection-info svg {
    width: 14px;
    height: 14px;
}

/* ─── Modal ────────────────────────────────────────────────────────────────── */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 1.75rem;
    max-width: 580px;
    width: 92%;
    max-height: 82vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0,0,0,0.2);
    animation: modalSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
    from { transform: translateY(16px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    background: var(--bg);
    border: 1px solid var(--border);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    line-height: 1;
}

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

.speaker-detail-header {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.speaker-avatar {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    flex-shrink: 0;
    color: white;
}

.speaker-detail-header h3 {
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.speaker-detail-header p {
    color: var(--text-light);
    font-size: 0.82rem;
}

.talk-detail {
    background: var(--bg);
    border-radius: 10px;
    padding: 1rem;
    margin: 1rem 0;
    border: 1px solid var(--border);
}

.talk-detail h4 {
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
    letter-spacing: -0.01em;
}

.talk-detail p {
    font-size: 0.82rem;
    color: var(--text-light);
    line-height: 1.55;
}

.detail-row {
    display: flex;
    gap: 0.5rem;
    margin: 0.3rem 0;
    font-size: 0.82rem;
}

.detail-label {
    font-weight: 600;
    min-width: 68px;
    color: var(--text-light);
}

.action-links {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.action-links a {
    font-size: 0.82rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--primary);
    border-radius: 8px;
    transition: all 0.15s;
}

.action-links a:hover {
    background: var(--primary);
    color: white;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.empty-state h3 {
    margin-bottom: 0.35rem;
    font-size: 1rem;
}

.empty-state p {
    color: var(--text-light);
    font-size: 0.85rem;
}

/* Loading */
.loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--sidebar-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Footer */
footer {
    text-align: center;
    padding: 1.25rem;
    color: var(--text-light);
    font-size: 0.75rem;
    border-top: 1px solid var(--border);
}

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: static;
        max-height: none;
        display: grid;
        grid-template-columns: 1fr 1fr 1fr auto;
        gap: 0.75rem;
        align-items: start;
    }
    .sidebar-section {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }
    .btn-search {
        align-self: end;
    }
    .main-content {
        max-height: none;
    }
    #events-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .sidebar {
        grid-template-columns: 1fr;
    }
    .header-content {
        flex-direction: column;
        gap: 0.15rem;
    }
}
