/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f4f5f7; color: #333333; }

/* Google Places Autocomplete dropdown — must float above everything */
.pac-container { z-index: 10000 !important; }

/* ===== Sidebar ===== */
.hc-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 58px;
    background: #333333; z-index: 200; display: flex; flex-direction: column;
    align-items: center; padding: 12px 0;
}
.hc-sidebar-logo { width: 32px; height: 32px; object-fit: contain; margin-bottom: 20px; }
.hc-nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    width: 48px; height: 48px; border-radius: 8px; margin-bottom: 4px;
    color: #999; text-decoration: none; font-size: 9px; font-weight: 600;
    letter-spacing: 0.5px; transition: all 0.15s;
}
.hc-nav-item:link, .hc-nav-item:visited { color: #999; text-decoration: none; }
.hc-nav-item svg { width: 20px; height: 20px; fill: currentColor; margin-bottom: 2px; }
.hc-nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.hc-nav-item.active { background: #F5A623; color: #fff; }
.hc-nav-item.active:link, .hc-nav-item.active:visited { color: #fff; }
.hc-nav-spacer { flex: 1; }
.hc-nav-user {
    font-size: 9px; color: #999; text-align: center; line-height: 1.3;
    margin-bottom: 8px;
}
.hc-nav-logout {
    font-size: 9px; color: #666; text-decoration: none; padding: 4px;
    border-radius: 4px; transition: all 0.15s;
}
.hc-nav-logout:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* ===== Topbar ===== */
.hc-topbar {
    position: fixed; top: 0; left: 58px; right: 0; height: 52px;
    background: #fff; border-bottom: 1px solid #e5e7eb; z-index: 100;
    display: flex; align-items: center; padding: 0 20px; gap: 12px;
}
.hc-topbar-logo { height: 28px; }
.hc-topbar-divider { width: 1px; height: 28px; background: #e5e7eb; }
.hc-topbar-title { font-size: 15px; font-weight: 600; color: #333; }

/* ===== Content Area ===== */
.hc-content { margin-left: 58px; margin-top: 52px; padding: 20px; min-height: calc(100vh - 52px); }

/* ===== Cards ===== */
.metric-card {
    background: #fff; border-radius: 8px; padding: 16px 20px;
    border-left: 3px solid #F5A623; box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.metric-card-label { font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.metric-card-value { font-size: 22px; font-weight: 700; color: #333; margin-top: 4px; }

/* ===== Buttons ===== */
.btn-primary {
    background: #F5A623; color: #fff; border: none; padding: 8px 16px;
    border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer;
    transition: background 0.15s;
}
.btn-primary:hover { background: #e09500; }
.btn-outline {
    background: transparent; color: #333; border: 1px solid #d1d5db;
    padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all 0.15s;
}
.btn-outline:hover { border-color: #F5A623; color: #F5A623; }

/* ===== Chips ===== */
.filter-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: #FFF3DC; color: #333; padding: 4px 10px;
    border-radius: 12px; font-size: 12px; font-weight: 500;
}
.filter-chip-x { cursor: pointer; color: #999; font-size: 14px; line-height: 1; }
.filter-chip-x:hover { color: #333; }

/* ===== Filter Panel (Drawer) ===== */
.filter-panel-drawer {
    position: fixed; right: 0; top: 52px; bottom: 0; width: 360px;
    background: #FBF5EA; border-left: 1px solid #e5e7eb;
    box-shadow: -4px 0 16px rgba(0,0,0,0.08); z-index: 50;
    display: flex; flex-direction: column;
}
.filter-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid rgba(0,0,0,0.06);
    background: #FBF5EA;
}
.filter-panel-header h3 { font-size: 15px; font-weight: 600; color: #222; }
.filter-panel-close {
    background: none; border: none; cursor: pointer; color: #555;
    font-size: 20px; line-height: 1; padding: 4px; border-radius: 4px;
}
.filter-panel-close:hover { background: rgba(0,0,0,0.05); }
.filter-panel-reset {
    background: none; border: none; cursor: pointer; color: #F5A623;
    font-size: 13px; font-weight: 600; padding: 4px 8px;
}
.filter-panel-reset:hover { color: #e09500; }
.filter-panel-body {
    flex: 1; overflow-y: auto; padding: 18px;
    display: flex; flex-direction: column; gap: 18px;
}
.filter-panel-footer {
    display: flex; gap: 10px; padding: 12px 18px;
    border-top: 1px solid rgba(0,0,0,0.06); background: #fff;
}
.filter-btn-clear, .filter-btn-apply { flex: 1; padding: 10px 14px; font-size: 14px; }
.filter-btn-apply { background: #D88A10; }
.filter-btn-apply:hover { background: #b87508; }

.filter-section { display: flex; flex-direction: column; gap: 10px; }
.filter-section-title {
    font-size: 16px; font-weight: 700; color: #222; margin: 0;
}

.filter-search-wrap { position: relative; }
.filter-search-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: #8a7a5c; pointer-events: none;
}
.filter-search-input {
    width: 100%; padding: 10px 12px 10px 36px;
    background: #F4EAD5; border: 1px solid transparent; border-radius: 8px;
    font-size: 13px; color: #333; transition: border-color 0.15s;
}
.filter-search-input::placeholder { color: #a08d6a; }
.filter-search-input:focus {
    outline: none; border-color: #F5A623; background: #fff;
}

.filter-picker-caret {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; color: #8a7a5c;
    padding: 4px; border-radius: 4px; display: flex; align-items: center;
}
.filter-picker-caret svg { width: 16px; height: 16px; }
.filter-picker-caret:hover { background: rgba(0,0,0,0.05); color: #222; }

.filter-picker-dropdown {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60;
    background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12); max-height: 220px; overflow-y: auto;
    padding: 4px;
}
.filter-picker-dropdown[hidden] { display: none; }
.filter-picker-option {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 10px; font-size: 13px; color: #333; border-radius: 6px;
    cursor: pointer; user-select: none;
}
.filter-picker-option:hover { background: #FFF3DC; }
.filter-picker-option.option-hidden { display: none; }
.filter-picker-check { width: 14px; height: 14px; color: #F5A623; opacity: 0; }
.filter-picker-option.active .filter-picker-check { opacity: 1; }
.filter-picker-option.active { font-weight: 600; color: #D88A10; }

.chip-toggle-grid {
    display: flex; flex-wrap: wrap; gap: 6px; max-height: 180px; overflow-y: auto;
    padding: 2px;
}
.chip-toggle {
    display: inline-flex; align-items: center; gap: 4px;
    background: #F4EAD5; color: #444; border: 1px solid transparent;
    padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all 0.12s; white-space: nowrap;
}
.chip-toggle:hover { background: #ead8b0; }
.chip-toggle.active {
    background: #F5A623; color: #fff;
}
.chip-toggle.active:hover { background: #e09500; }
.chip-toggle-x { opacity: 0; width: 0; overflow: hidden; transition: all 0.12s; font-size: 14px; }
.chip-toggle.active .chip-toggle-x { opacity: 1; width: auto; margin-left: 2px; }
.chip-toggle.chip-hidden { display: none; }

.filter-range-card {
    background: #F4EAD5; border-radius: 10px; padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
}
.filter-range-header {
    display: flex; align-items: center; gap: 8px;
    font-size: 14px; font-weight: 700; color: #222;
}
.filter-range-header svg { width: 18px; height: 18px; color: #D88A10; }
.filter-range-inputs {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.filter-range-label {
    display: block; font-size: 10px; font-weight: 600; color: #8a7a5c;
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px;
}
.filter-range-input {
    width: 100%; padding: 8px 10px; background: #F9F1DF;
    border: 1px solid transparent; border-radius: 6px; font-size: 14px;
    color: #222; transition: all 0.15s;
}
.filter-range-input::placeholder { color: #b5a07a; }
.filter-range-input:focus {
    outline: none; border-color: #F5A623; background: #fff;
}

.filter-preview-card {
    background:
        linear-gradient(rgba(20,14,0,0.85), rgba(20,14,0,0.85)),
        repeating-linear-gradient(45deg, rgba(245,166,35,0.25) 0 1px, transparent 1px 14px),
        repeating-linear-gradient(-45deg, rgba(245,166,35,0.25) 0 1px, transparent 1px 14px);
    color: #F5A623; border-radius: 10px; padding: 18px;
    display: flex; align-items: center; gap: 10px;
    font-size: 13px;
}
.filter-preview-card svg { width: 18px; height: 18px; }
.filter-preview-card strong { color: #fff; font-weight: 700; }

/* ===== Drop Zone ===== */
.drop-zone {
    border: 2px dashed #d1d5db; border-radius: 8px; padding: 40px;
    text-align: center; color: #888; transition: all 0.2s; cursor: pointer;
}
.drop-zone:hover, .drop-zone.dragover { border-color: #F5A623; background: #FFF3DC; color: #333; }
.drop-zone:focus { outline: none; border-color: #F5A623; box-shadow: 0 0 0 3px rgba(245,166,35,0.22); }

/* HTMX shows these while the associated request is active. */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: block; }

/* ===== Forms ===== */
.form-input {
    width: 100%; padding: 8px 12px; border: 1px solid #d1d5db;
    border-radius: 6px; font-size: 13px; transition: border-color 0.15s;
}
.form-input:focus { outline: none; border-color: #F5A623; box-shadow: 0 0 0 2px rgba(245,166,35,0.2); }
.form-label { display: block; font-size: 12px; font-weight: 600; color: #555; margin-bottom: 4px; }

/* ===== Comp Cards ===== */
.comp-card {
    background: #fff; border-radius: 8px; padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08); border: 1px solid #e5e7eb;
    transition: border-color 0.15s;
}
.comp-card:hover { border-color: #F5A623; }
.comp-rank { display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%; font-size: 12px; font-weight: 700; }
.comp-rank-top { background: #F5A623; color: #fff; }
.comp-rank-other { background: #e5e7eb; color: #555; }

/* ===== Export Dropdown ===== */
.export-dropdown {
    position: absolute; right: 0; top: 100%; margin-top: 4px;
    background: #fff; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border: 1px solid #e5e7eb; min-width: 140px; z-index: 300; overflow: hidden;
}
.export-dropdown a {
    display: block; padding: 8px 16px; font-size: 13px; color: #333;
    text-decoration: none; transition: background 0.1s;
}
.export-dropdown a:hover { background: #FFF3DC; }

/* ===== Toggle Tabs ===== */
.type-toggle { display: inline-flex; background: #f4f5f7; border-radius: 6px; padding: 2px; }
.type-toggle-btn {
    padding: 6px 16px; border-radius: 4px; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all 0.15s; border: none; background: transparent; color: #666;
}
.type-toggle-btn.active { background: #fff; color: #333; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* ===== Chart Tabs ===== */
.chart-tab {
    padding: 8px 16px; font-size: 13px; font-weight: 500; cursor: pointer;
    border-bottom: 2px solid transparent; color: #666; transition: all 0.15s;
    background: none; border-top: none; border-left: none; border-right: none;
}
.chart-tab:hover { color: #333; }
.chart-tab.active { color: #F5A623; border-bottom-color: #F5A623; }

/* ===== Upload Segment Tabs ===== */
.upload-segment-tabs {
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 0;
    border-bottom: 1px solid #e5e7eb;
    padding-top: 6px;
}
.upload-segment-tab-wrap {
    position: relative;
    flex: 1 1 96px;
    min-width: 78px;
    max-width: 132px;
}
.upload-segment-tab {
    width: 100%;
    min-height: 76px;
    padding: 9px 28px 10px 12px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    text-align: center;
    white-space: normal;
    line-height: 1.25;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.upload-segment-tab:hover { color: #333; background: #fafafa; }
.upload-segment-tab.active { color: #F5A623; border-bottom-color: #F5A623; }
.upload-segment-tab.voided { color: #9ca3af; background: #f9fafb; }
.upload-segment-menu-trigger {
    position: absolute;
    top: 8px;
    right: 6px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: #8a8f98;
    cursor: pointer;
}
.upload-segment-menu-trigger:hover { background: #f3f4f6; color: #333; }
.upload-segment-menu-trigger svg {
    width: 4px;
    height: 16px;
    fill: currentColor;
    display: block;
}
.upload-segment-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 6px;
    z-index: 20;
    min-width: 120px;
    padding: 4px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

/* ===== Badge Tags ===== */
.badge-mapped { background: #d1fae5; color: #065f46; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-unmapped { background: #fef3c7; color: #92400e; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-required { background: #fee2e2; color: #991b1b; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }

/* ===== Progress Bar ===== */
.progress-bar { height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: #F5A623; border-radius: 3px; transition: width 0.3s; }

/* ===== Utility ===== */
.text-amber { color: #F5A623; }
.bg-amber { background: #F5A623; }
.bg-amber-pale { background: #FFF3DC; }
