/* ============================================================
   SP-BASE.CSS — SHARED STYLES, TYPOGRAPHY, THEME VARIABLES
   ============================================================ */

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

/* ============================================================
   THEME COLOR VARIABLES (Dark Mode)
   ============================================================ */
:root {
    --bg: #0a0f1a;
    --surface: #111827;
    --surface-2: #1a2235;
    --border: #1e293b;
    --border-light: #2d3a4f;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --accent: #22d3ee;
    --accent-dim: rgba(34, 211, 238, 0.12);
    --accent-glow: rgba(34, 211, 238, 0.25);
    --warm: #f59e0b;
    --warm-dim: rgba(245, 158, 11, 0.12);
    --green: #10b981;
    --green-dim: rgba(16, 185, 129, 0.12);
    --red: #ef4444;
    --red-dim: rgba(239, 68, 68, 0.12);
    --purple: #8b5cf6;
    --purple-dim: rgba(139, 92, 246, 0.12);
    --pink: #ec4899;
    --pink-dim: rgba(236, 72, 153, 0.12);
    --blue: #3b82f6;
    --blue-dim: rgba(59, 130, 246, 0.12);
    --amber: #f59e0b;
    --amber-dim: rgba(245, 158, 11, 0.12);

    /* Aliases used by Berichte/export cards and JS-rendered HTML */
    --bg-card: #111827;
    --bg-secondary: #1a2235;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;

    color-scheme: dark;
}

/* ============================================================
   BASE TYPOGRAPHY & GLOBAL STYLES
   ============================================================ */

html {
    overflow-x: hidden;
    max-width: 100%;
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    max-width: 100%;
    width: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { font-family: 'Space Grotesk', sans-serif; }

/* ============================================================
   BACKGROUND & LAYOUT FOUNDATION
   ============================================================ */

.topo-bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(139, 92, 246, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(16, 185, 129, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================================
   FORM ELEMENTS & INPUTS
   ============================================================ */

.form-control,
.filter-select,
.filter-input {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.88rem;
    padding: 0.65rem 0.9rem;
    border-radius: 10px;
    font-family: 'DM Sans', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus,
.filter-select:focus,
.filter-input:focus {
    border-color: var(--purple);
}

.filter-input {
    min-width: 220px;
    font-size: 0.82rem;
    padding: 0.5rem 0.75rem;
}

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

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

select.form-control {
    cursor: pointer;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    background: var(--surface-2);
    border-radius: 4px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--purple);
    cursor: pointer;
    border: 2px solid var(--bg);
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.65rem 1.25rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--purple);
    color: #fff;
}

.btn-primary:hover {
    background: #7c3aed;
}

.btn-secondary {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--purple);
    color: var(--purple);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.78rem;
    border-radius: 8px;
}

.btn-success {
    background: var(--green);
    color: #fff;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--red);
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
}

/* ============================================================
   STATUS & URGENCY BADGES
   ============================================================ */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.73rem;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    font-weight: 500;
}

.status-pending { background: var(--warm-dim); color: var(--warm); }
.status-accepted { background: var(--accent-dim); color: var(--accent); }
.status-in_progress { background: var(--purple-dim); color: var(--purple); }
.status-completed { background: var(--green-dim); color: var(--green); }
.status-dropped_off { background: var(--red-dim); color: var(--red); }

.urgency-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

.urgency-low { background: var(--green-dim); color: var(--green); }
.urgency-medium { background: var(--accent-dim); color: var(--accent); }
.urgency-high { background: var(--warm-dim); color: var(--warm); }
.urgency-urgent {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ============================================================
   LOADING & EMPTY STATE
   ============================================================ */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--muted);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--purple);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 0.75rem;
}

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

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--muted);
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 999;
    padding: 0.75rem 1.25rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    animation: toastIn 0.3s ease-out;
    display: none;
}

.toast.show {
    display: block;
}

.toast.success {
    background: var(--green);
    color: #fff;
}

.toast.error {
    background: var(--red);
    color: #fff;
}

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

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes slideIn {
    from { transform: translateX(30px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   SCROLLBAR STYLING
   ============================================================ */

#referralTableBody::-webkit-scrollbar,
#wbHistoryBody::-webkit-scrollbar {
    width: 10px;
}

#referralTableBody::-webkit-scrollbar-track,
#wbHistoryBody::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.4);
    border-radius: 6px;
}

#referralTableBody::-webkit-scrollbar-thumb,
#wbHistoryBody::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
    border-radius: 6px;
    transition: background-color 0.2s;
}

#referralTableBody::-webkit-scrollbar-thumb:hover,
#wbHistoryBody::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.8);
}

#referralTableBody,
#wbHistoryBody {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.5) rgba(30, 41, 59, 0.4);
}

/* ============================================================
   THEME TOGGLE BUTTONS
   ============================================================ */

.theme-cycle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.3rem 0.65rem;
    cursor: pointer;
    color: var(--muted);
    font-size: 0.85rem;
    gap: 5px;
    transition: all 0.2s;
    font-family: inherit;
    line-height: 1;
}

.theme-cycle-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.theme-cycle-label {
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

/* ============================================================
   LANGUAGE SWITCHER
   ============================================================ */

.lang-toggle {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.lang-btn {
    background: none;
    border: none;
    padding: 0.3rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
    cursor: pointer;
    font-family: inherit;
    letter-spacing: 0.04em;
    transition: all 0.15s;
    line-height: 1;
}

.lang-btn + .lang-btn {
    border-left: 1px solid var(--border);
}

.lang-btn.lang-active {
    background: var(--purple-dim);
    color: var(--purple);
}

.lang-btn:hover:not(.lang-active) {
    color: var(--text);
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 1.5rem; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 0.8rem; }
.text-purple { color: var(--purple); }
.text-green { color: var(--green); }
.text-warm { color: var(--warm); }
.text-red { color: var(--red); }
.text-accent { color: var(--accent); }
.gap-1 { gap: 0.75rem; }
.flex { display: flex; }
.items-center { align-items: center; }

/* ============================================================
   ATTRIBUTE TAGS (Service Cards)
   ============================================================ */

.attr-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.65rem;
}

.attr-tag {
    font-size: 0.65rem;
    padding: 0.18rem 0.5rem;
    border-radius: 100px;
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.attr-tag-age {
    background: rgba(34,211,238,0.1);
    color: var(--accent);
    border: 1px solid rgba(34,211,238,0.25);
}

.attr-tag-gender {
    background: rgba(236,72,153,0.1);
    color: var(--pink);
    border: 1px solid rgba(236,72,153,0.25);
}

.attr-tag-access {
    background: rgba(16,185,129,0.1);
    color: var(--green);
    border: 1px solid rgba(16,185,129,0.25);
}

.attr-tag-focus {
    background: rgba(139,92,246,0.1);
    color: var(--purple);
    border: 1px solid rgba(139,92,246,0.25);
}

.attr-tag-cost {
    background: rgba(245,158,11,0.1);
    color: var(--warm);
    border: 1px solid rgba(245,158,11,0.25);
}

.attr-tag-indication {
    background: rgba(99,102,241,0.1);
    color: #818cf8;
    border: 1px solid rgba(99,102,241,0.25);
}

.attr-tag-contra {
    background: rgba(239,68,68,0.1);
    color: var(--red);
    border: 1px solid rgba(239,68,68,0.25);
}

/* ============================================================
   FILTER PILLS & INDICATORS
   ============================================================ */

.filter-select.active-filter {
    border-color: var(--purple);
    color: var(--text);
}

.filter-active-count {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: var(--purple);
    background: var(--purple-dim);
    border: 1px solid rgba(139,92,246,0.2);
    padding: 0.25rem 0.6rem;
    border-radius: 100px;
    cursor: pointer;
}

/* ============================================================
   ATTRIBUTE SECTION
   ============================================================ */

.attr-section {
    margin-top: 0.75rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--border);
}

.attr-section-label {
    font-size: 0.65rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.3rem;
    font-weight: 500;
}

/* ============================================================
   REPORTS & CHARTS
   ============================================================ */

.report-bars {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 140px;
}

.report-bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    height: 100%;
    justify-content: flex-end;
}

.report-bar {
    width: 100%;
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: all 0.3s;
}

.report-bar-label {
    font-size: 0.65rem;
    color: var(--muted);
    text-align: center;
}

.report-bar-value {
    font-size: 0.7rem;
    font-weight: 600;
}

/* ============================================================
   PROGRESS COMPARISON
   ============================================================ */

.progress-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.progress-item {
    background: var(--surface-2);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
}

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

.progress-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
}

.progress-change {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* ============================================================
   DEMO MODE STYLES
   ============================================================ */

/* Demo Banner - shown at top when ?demo=true */
.demo-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: linear-gradient(90deg, var(--purple) 0%, #a855f7 50%, var(--accent) 100%);
    color: #fff;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.3);
}

.demo-banner .demo-icon {
    width: 18px;
    height: 18px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
}

.demo-banner button.demo-close {
    position: absolute;
    right: 1rem;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.demo-banner button.demo-close:hover {
    background: rgba(255,255,255,0.25);
}

/* Adjust nav when banner is visible - push sticky navs down */
body.demo-mode .top-nav {
    top: 40px;
}
body.demo-mode .tab-nav {
    top: 96px;
}

/* Demo Walkthrough Overlay */
.demo-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
}

.demo-overlay.active {
    display: flex;
}

/* Demo Progress Indicator (top bar) */
.demo-progress {
    position: fixed;
    top: 44px;
    left: 0;
    right: 0;
    z-index: 1001;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 1rem;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.demo-progress.active {
    display: flex;
}

.demo-progress-dots {
    display: flex;
    gap: 0.5rem;
}

.demo-progress-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    transition: all 0.3s ease;
}

.demo-progress-dot.active {
    background: var(--purple);
    box-shadow: 0 0 8px var(--purple);
}

.demo-progress-dot.completed {
    background: var(--green);
}

.demo-progress-text {
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 500;
    min-width: 40px;
}

/* Walkthrough Tooltip Card */
.demo-tooltip {
    position: fixed;
    z-index: 1002;
    background: var(--surface);
    border: 1px solid var(--purple);
    border-radius: 12px;
    padding: 1.25rem;
    max-width: 320px;
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.25);
    display: none;
    animation: demoTooltipIn 0.3s ease;
}

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

.demo-tooltip.active {
    display: block;
}

.demo-tooltip-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.demo-tooltip-step {
    background: var(--purple);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.demo-tooltip-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.demo-tooltip-body {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.demo-tooltip-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.demo-tooltip-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.demo-tooltip-btn.skip {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}

.demo-tooltip-btn.skip:hover {
    background: var(--surface-2);
    color: var(--text);
}

.demo-tooltip-btn.next {
    background: var(--purple);
    color: #fff;
}

.demo-tooltip-btn.next:hover {
    background: #7c3aed;
    transform: translateY(-1px);
}

/* Demo start button on partners page */
.demo-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: 1rem;
    transition: color 0.2s ease;
}

.demo-link:hover {
    color: #06b6d4;
}

.demo-link::before {
    content: "▶";
    font-size: 0.7rem;
}
