:root {
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --secondary: #ec4899;
    --accent: #06b6d4;
    --bg-app: #0f172a;
    --bg-sidebar: rgba(15, 23, 42, 0.9);
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --magic: linear-gradient(135deg, #8b5cf6, #ec4899);
}

* {
    margin: 0; padding: 0; box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}

.app-container {
    display: flex;
    height: 100vh; width: 100vw;
    position: relative;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 420px;
    background: var(--bg-sidebar);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 100;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed { width: 0; overflow: hidden; border-right: none; }

.toggle-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.toggle-btn:hover {
    background: var(--magic);
    border-color: transparent;
    transform: rotate(-180deg) scale(1.1);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h1 {
    font-size: 1.5rem; font-weight: 800;
    background: var(--magic); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.search-panel { 
    padding: 20px; 
    border-bottom: 1px solid var(--border);
    position: relative;
}

.input-group { margin-bottom: 16px; }
.input-group label {
    display: block; font-size: 0.7rem; font-weight: 800; color: var(--text-muted);
    text-transform: uppercase; margin-bottom: 6px; letter-spacing: 0.8px;
}

input[type="text"], select {
    width: 100%; padding: 12px; border: 1px solid var(--border);
    border-radius: 12px; background: #1e293b; color: white;
    font-size: 0.95rem; outline: none; transition: all 0.3s;
    appearance: none; /* Remove browser default arrow */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

select option {
    background-color: #0f172a;
    color: white;
    padding: 8px 12px;
}

/* Status dropdown colors */
.status-dropdown option[value="uncontacted"] { color: #cbd5e1; border-left: 4px solid #cbd5e1; }
.status-dropdown option[value="contacted"] { color: #eab308; border-left: 4px solid #eab308; }
.status-dropdown option[value="interested"] { color: #22c55e; border-left: 4px solid #22c55e; }
.status-dropdown option[value="not_interested"] { color: #ef4444; border-left: 4px solid #ef4444; }
.status-dropdown option[value="client"] { color: #06b6d4; border-left: 4px solid #06b6d4; }

/* Dynamic select border based on current value */
.status-dropdown.status-uncontacted { border-color: #cbd5e1; color: #cbd5e1; }
.status-dropdown.status-contacted { border-color: #eab308; color: #eab308; }
.status-dropdown.status-interested { border-color: #22c55e; color: #22c55e; }
.status-dropdown.status-not_interested { border-color: #ef4444; color: #ef4444; }
.status-dropdown.status-client { border-color: #06b6d4; color: #06b6d4; }

/* Sidebar status filter colors */
#statusFilterSelect option[value="uncontacted"] { color: #cbd5e1; }
#statusFilterSelect option[value="contacted"] { color: #eab308; }
#statusFilterSelect option[value="interested"] { color: #22c55e; }
#statusFilterSelect option[value="not_interested"] { color: #ef4444; }
#statusFilterSelect option[value="client"] { color: #06b6d4; }

input:focus, select:focus { border-color: var(--primary); background: rgba(255,255,255,0.06); }

.row-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.filter-group {
    display: flex; gap: 15px; margin: 15px 0;
}

.checkbox-container {
    display: flex; align-items: center; gap: 8px; font-size: 0.75rem; color: var(--text-muted); cursor: pointer;
}

.btn {
    padding: 14px; border: none; border-radius: 12px; font-weight: 700;
    cursor: pointer; transition: all 0.3s; display: flex; align-items: center;
    justify-content: center; gap: 10px; width: 100%;
}

.btn-primary { background: var(--primary); color: white; }
.btn-magic { background: var(--magic); color: white; }
.btn:hover { transform: translateY(-2px); filter: brightness(1.1); box-shadow: 0 10px 20px rgba(0,0,0,0.2); }

/* --- RESULTS --- */
.results-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.results-header { padding: 15px 24px; border-bottom: 1px solid var(--border); }
.results-header h2 { font-size: 0.9rem; color: var(--text-muted); text-transform: uppercase; }

.results-list { flex: 1; overflow-y: auto; padding: 20px; }

.place-card {
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: 16px; padding: 16px; margin-bottom: 12px;
    cursor: pointer; transition: all 0.3s;
}

.place-card:hover { border-color: var(--primary); transform: translateX(5px); background: rgba(30, 41, 59, 0.9); }

.card-header-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.card-category { background: var(--primary); padding: 2px 8px; border-radius: 6px; font-size: 0.6rem; font-weight: 800; }
.card-status { font-size: 0.6rem; font-weight: 800; text-transform: uppercase; padding: 2px 8px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.1); }

.place-card h3 { font-size: 1rem; margin-bottom: 4px; color: white; }
.place-card p { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 10px; }

.card-intel { display: flex; gap: 12px; border-top: 1px solid var(--border); padding-top: 10px; margin-top: 5px; }
.intel-item { display: flex; align-items: center; gap: 5px; font-size: 0.7rem; color: var(--text-muted); font-weight: 600; }
.intel-item.active { color: var(--accent); }
.intel-item.active i { filter: drop-shadow(0 0 5px var(--accent)); }

/* Status specific card colors */
.card-status.uncontacted { background: rgba(203, 213, 225, 0.1); color: #cbd5e1; }
.card-status.contacted { background: rgba(234, 179, 8, 0.1); color: #eab308; }
.card-status.interested { background: rgba(34, 197, 94, 0.1); color: #22c55e; }
.card-status.not_interested { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.card-status.client { background: rgba(6, 182, 212, 0.1); color: #06b6d4; }

/* --- MAP --- */
.main-content { flex: 1; position: relative; }
#map { width: 100%; height: 100%; }
.dark-tiles { filter: brightness(2.2) contrast(0.85); }

/* --- MARKERS --- */
.custom-pin {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}

.pin-dot {
    width: 14px; height: 14px; border-radius: 50%; border: 2px solid white;
    box-shadow: 0 0 10px rgba(255,255,255,0.6);
    transition: all 0.3s ease;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}

.pin-dot.active {
    width: 22px; height: 22px; 
    background: white !important;
    border: 3px solid var(--primary);
    box-shadow: 0 0 20px rgba(var(--primary-rgb, 168,85,247), 0.8), 0 0 40px rgba(var(--primary-rgb, 168,85,247), 0.4);
    animation: pinPulse 1.5s infinite alternate ease-in-out;
    z-index: 999999 !important;
}

@keyframes pinPulse {
    0% { box-shadow: 0 0 10px rgba(168,85,247,0.6), 0 0 0 0px rgba(168,85,247,0.3); }
    100% { box-shadow: 0 0 20px rgba(168,85,247,0.8), 0 0 0 8px rgba(168,85,247,0); }
}

.status-uncontacted .pin-dot { background: #cbd5e1 !important; }
.status-contacted .pin-dot { background: #eab308 !important; }
.status-interested .pin-dot { background: #22c55e !important; }
.status-not_interested .pin-dot { background: #ef4444 !important; }
.status-client .pin-dot { background: #06b6d4 !important; }

/* --- ANALYSIS OVERLAY --- */
.analysis-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(10, 15, 28, 0.85); backdrop-filter: blur(12px);
    z-index: 10000; display: none; align-items: center; justify-content: center;
    padding: 20px;
}

.analysis-card {
    background: var(--card-bg); border: 1px solid var(--border);
    width: 100%; max-width: 600px; border-radius: 24px;
    padding: 30px; position: relative; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.close-overlay {
    position: absolute; top: 20px; right: 20px;
    background: rgba(255,255,255,0.05); border: none; color: white;
    width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
    transition: all 0.3s;
}

.close-overlay:hover { background: rgba(255,255,255,0.15); transform: rotate(90deg); }

.analysis-header { margin-bottom: 25px; }
.lead-pill { 
    display: inline-block; padding: 4px 12px; background: var(--magic); 
    border-radius: 20px; font-size: 0.65rem; font-weight: 900; margin-bottom: 10px;
}
.analysis-header h2 { font-size: 1.8rem; letter-spacing: -0.5px; }

.insight-section { margin-bottom: 25px; }
.insight-section h3 { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.insight-text { background: rgba(255,255,255,0.03); border-radius: 16px; padding: 15px; font-size: 0.9rem; line-height: 1.6; border-left: 3px solid var(--accent); }

.prompt-section h3 { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 12px; }
.prompt-container { background: #0f172a; border: 1px solid var(--border); border-radius: 16px; padding: 20px; position: relative; }
pre { 
    white-space: pre-wrap; word-wrap: break-word; color: #a5b4fc; 
    font-size: 0.85rem; font-family: 'JetBrains Mono', 'Courier New', monospace;
    margin-bottom: 15px; max-height: 200px; overflow-y: auto;
}

.btn-sm { padding: 8px 16px; font-size: 0.75rem; border-radius: 10px; width: auto; }

/* Mobile Fullscreen */
@media (max-width: 768px) {
    .analysis-overlay { padding: 0; }
    .analysis-card { 
        height: 100%; max-height: 100vh; border-radius: 0; 
        display: flex; flex-direction: column; padding: 40px 24px;
    }
    .analysis-header h2 { font-size: 1.5rem; }
}

/* User Location */
.user-location-marker {
    background: #3b82f6; width: 20px; height: 20px; border-radius: 50%;
    border: 3px solid white; box-shadow: 0 0 20px #3b82f6; position: relative;
}

.user-location-marker::after {
    content: ''; position: absolute; top: -10px; left: -10px; right: -10px; bottom: -10px;
    border: 2px solid #3b82f6; border-radius: 50%; animation: userPulse 2s infinite;
}

@keyframes userPulse {
    0% { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(2.5); opacity: 0; }
}

/* --- DETAILS PANEL --- */
#toggleSidebarInMap {
    position: absolute; top: 20px; left: 20px; z-index: 1001;
    background: var(--magic); color: white; width: 52px; height: 52px;
    border-radius: 16px; display: none; align-items: center; justify-content: center;
    border: 2px solid rgba(255,255,255,0.2); cursor: pointer; 
    box-shadow: 0 10px 30px rgba(139, 92, 246, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#toggleSidebarInMap:hover { transform: scale(1.1) rotate(5deg); }
#toggleSidebarInMap:active { transform: scale(0.9); }
#toggleSidebarInMap i { font-size: 1.1rem; }

.place-details-panel {
    position: absolute; top: 24px; right: 24px; width: 400px;
    background: rgba(15, 23, 42, 0.95); backdrop-filter: blur(20px);
    border: 1px solid var(--border); border-radius: 24px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5); z-index: 1000;
    overflow: hidden;
}

.details-header {
    padding: 20px; background: rgba(255,255,255,0.03); border-bottom: 1px solid var(--border);
    position: relative; display: flex; flex-direction: column; align-items: center;
}

#closeDetails {
    position: absolute; top: 15px; right: 15px; background: rgba(255,255,255,0.1);
    border: none; color: white; width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
}

.drag-handle { width: 40px; height: 4px; background: rgba(255,255,255,0.2); border-radius: 10px; margin-bottom: 10px; }
.category-badge { background: var(--primary); padding: 4px 12px; border-radius: 20px; font-size: 0.7rem; font-weight: 800; margin-top: 8px; }

.details-body { padding: 24px; max-height: 70vh; overflow-y: auto; }

.info-grid { display: grid; gap: 20px; }
.info-item label { display: block; font-size: 0.65rem; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.info-item p { font-size: 0.95rem; line-height: 1.5; }

.social-section, .status-section { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border); }
.social-section label, .status-section label { display: block; font-size: 0.65rem; font-weight: 800; color: var(--text-muted); margin-bottom: 12px; }

.social-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.social-link {
    background: rgba(255,255,255,0.05); padding: 12px; border-radius: 12px;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    text-decoration: none; color: white; font-size: 0.6rem; font-weight: 800;
    border: 1px solid var(--border); transition: all 0.3s;
}
.social-link i { font-size: 1.4rem; }
.social-link:hover { background: var(--primary); transform: translateY(-3px); }

.status-dropdown { margin-top: 5px; }

/* --- LOADING --- */
.loading-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.8); display: flex; flex-direction: column;
    align-items: center; justify-content: center; z-index: 100;
    backdrop-filter: blur(4px); border-radius: 12px; gap: 15px;
}
.spinner {
    width: 30px; height: 30px; border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary); border-radius: 50%; animation: spin 1s infinite linear;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* --- MOBILE --- */
@media (max-width: 768px) {
    .sidebar { width: 100% !important; position: fixed; height: 100%; top: 0; left: 0; z-index: 2000; }
    .sidebar.collapsed { transform: translateX(-100%); width: 100% !important; }
    
    .place-details-panel {
        width: 100% !important; top: auto !important; bottom: 0 !important; right: 0 !important;
        border-radius: 32px 32px 0 0; max-height: 85dvh;
    }
}
