/* ═══════════════════════════════════════════════════════════
   Tokko Search — Design System & Styles
   Premium dark theme with glassmorphism
   ═══════════════════════════════════════════════════════════ */

/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #07070e;
    --bg-secondary: #0d0d1a;
    --bg-card: rgba(16, 16, 32, 0.65);
    --bg-card-hover: rgba(22, 22, 44, 0.8);
    --bg-glass: rgba(20, 20, 40, 0.55);
    --border-subtle: rgba(99, 102, 241, 0.12);
    --border-glow: rgba(99, 102, 241, 0.3);
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-dark: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --purple: #8b5cf6;
    --green: #10b981;
    --green-bg: rgba(16, 185, 129, 0.1);
    --amber: #f59e0b;
    --red: #ef4444;
    --text-primary: #e8ecf4;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), 0 1px 4px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.08);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── Background effects ─────────────────────────────────── */
.bg-gradient {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(99, 102, 241, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 50%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 20% 80%, rgba(99, 102, 241, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.bg-grid {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background-image:
        linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
    z-index: 0;
}

/* ── Header ─────────────────────────────────────────────── */
#app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px) saturate(1.5);
    background: rgba(7, 7, 14, 0.75);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 24px;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px; height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    border-radius: var(--radius-sm);
    color: white;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.logo-group h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stats-bar {
    display: flex;
    gap: 8px;
}

.stat-chip {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid var(--border-subtle);
    padding: 4px 12px;
    border-radius: 100px;
    white-space: nowrap;
}

/* ── Main ───────────────────────────────────────────────── */
#app-main {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* ── Search Section ─────────────────────────────────────── */
.search-section {
    text-align: center;
    padding: 60px 0 32px;
    transition: padding var(--transition);
}

.search-section.compact {
    padding: 16px 0;
}

.search-title {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #fff, var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.search-section.compact .search-title,
.search-section.compact .search-subtitle {
    display: none;
}

.search-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 28px;
    font-weight: 400;
}

.search-box {
    position: relative;
    max-width: 680px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 0 20px;
    transition: all var(--transition);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-card), var(--shadow-glow);
}

.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: var(--shadow-card), 0 0 0 3px var(--accent-glow), 0 0 60px rgba(99, 102, 241, 0.1);
}

.search-icon {
    color: var(--text-muted);
    flex-shrink: 0;
    display: flex;
    transition: color var(--transition);
}

.search-box:focus-within .search-icon {
    color: var(--accent);
}

#search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1.05rem;
    font-weight: 400;
    padding: 18px 16px;
    width: 100%;
}

#search-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.search-clear {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    transition: all var(--transition);
}

.search-clear:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.06);
}

/* Spinner */
.spinner {
    width: 20px; height: 20px;
    border: 2.5px solid var(--border-subtle);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner.large {
    width: 36px; height: 36px;
    border-width: 3px;
}

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

.search-spinner {
    display: flex;
}

/* ── Results Section ────────────────────────────────────── */
.results-section {
    animation: fadeUp 0.3s ease;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 0 4px;
}

#results-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.property-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Property Card (list item) ──────────────────────────── */
.property-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    backdrop-filter: blur(8px);
}

.property-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-glow);
    transform: translateY(-1px);
    box-shadow: var(--shadow-card);
}

.property-card .prop-thumb {
    width: 72px; height: 54px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-secondary);
}

.property-card .prop-info {
    flex: 1;
    min-width: 0;
}

.property-card .prop-code {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 2px;
}

.property-card .prop-address {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.property-card .prop-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.property-card .prop-contacts-badge {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--accent-glow);
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-light);
}

.property-card .prop-contacts-badge.empty {
    background: rgba(100, 116, 139, 0.1);
    color: var(--text-muted);
}

.property-card .prop-contacts-badge svg {
    flex-shrink: 0;
}

/* ── Detail Panel ───────────────────────────────────────── */
.detail-panel {
    animation: fadeUp 0.3s ease;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-bottom: 20px;
    transition: all var(--transition);
}

.back-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-glow);
    background: var(--bg-card);
}

/* Property detail card */
.property-detail-card {
    display: flex;
    gap: 24px;
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: 28px;
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-card);
}

.prop-detail-img {
    width: 200px;
    height: 140px;
    border-radius: var(--radius-md);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-secondary);
}

.prop-detail-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.prop-detail-info .prop-code {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.prop-detail-info .prop-address {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.prop-detail-info .prop-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.prop-detail-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.prop-tag {
    font-size: 0.72rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 100px;
    background: rgba(99, 102, 241, 0.08);
    color: var(--accent-light);
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.prop-tag.price {
    background: var(--green-bg);
    color: var(--green);
    border-color: rgba(16, 185, 129, 0.2);
}

/* Contacts header */
.contacts-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 0 4px;
}

.contacts-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.contact-count-badge {
    background: var(--accent);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 100px;
    min-width: 28px;
    text-align: center;
}

.export-btn {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.export-btn:hover {
    color: var(--green);
    border-color: rgba(16, 185, 129, 0.3);
    background: var(--green-bg);
}

/* Contacts loading */
.contacts-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 48px 0;
    color: var(--text-secondary);
}

.loading-note {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Contacts grid */
.contacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 10px;
}

/* ── Contact Card ───────────────────────────────────────── */
.contact-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition);
}

.contact-card:hover {
    border-color: var(--border-glow);
    background: var(--bg-card-hover);
}

.contact-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.contact-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.contact-detail {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.contact-detail svg {
    flex-shrink: 0;
    color: var(--text-muted);
}

.contact-detail .value {
    cursor: pointer;
    transition: color var(--transition);
    word-break: break-all;
}

.contact-detail .value:hover {
    color: var(--accent-light);
}

.contact-event {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding-top: 6px;
    border-top: 1px solid var(--border-subtle);
    line-height: 1.4;
    font-style: italic;
}

.contact-status {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.contact-status.owner {
    background: rgba(245, 158, 11, 0.12);
    color: var(--amber);
}

.contact-status.active {
    background: var(--green-bg);
    color: var(--green);
}

.contact-status.closed {
    background: rgba(100, 116, 139, 0.12);
    color: var(--text-muted);
}

/* No contacts */
.no-contacts {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 48px 0;
    color: var(--text-muted);
    text-align: center;
}

/* ── Toast ──────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-primary);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-card);
    animation: slideIn 0.3s ease;
}

.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }

/* ── Utilities ──────────────────────────────────────────── */
.hidden { display: none !important; }

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

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

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .header-content { padding: 0 4px; }
    .stats-bar { display: none; }
    .search-title { font-size: 1.5rem; }
    .search-section { padding: 32px 0 20px; }
    .property-detail-card { flex-direction: column; }
    .prop-detail-img { width: 100%; height: 180px; }
    .contacts-grid { grid-template-columns: 1fr; }
    .property-card .prop-thumb { width: 56px; height: 42px; }
    #app-main { padding: 16px; }
}
