/* style.css - Senior UI/UX Design System (Notion x Airbnb x Linear) */

:root {
    /* Light Mode Tokens (Default) */
    --bg-page: #fbfbfb;
    --bg-surface: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.75);
    --border-color: #e5e5e5;
    --border-subtle: #f0f0f0;
    
    --text-primary: #171717;
    --text-secondary: #737373;
    --text-tertiary: #a3a3a3;
    
    --accent-primary: #000000;
    --accent-primary-hover: #262626;
    --accent-brand: #0066ff;
    --accent-brand-light: #e6f0ff;
    
    --shadow-subtle: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
    --shadow-dock: 0 10px 30px -5px rgba(0, 0, 0, 0.08);
    
    --radius-full: 9999px;
    --radius-xl: 16px;
    --radius-lg: 12px;
    --radius-md: 8px;
}

.dark {
    /* Dark Mode Tokens (Linear style) */
    --bg-page: #0b0c0e;
    --bg-surface: #141518;
    --bg-glass: rgba(20, 21, 24, 0.75);
    --border-color: #26282d;
    --border-subtle: #1c1e22;
    
    --text-primary: #f5f5f5;
    --text-secondary: #a1a1aa;
    --text-tertiary: #52525b;
    
    --accent-primary: #ffffff;
    --accent-primary-hover: #e5e5e5;
    --accent-brand: #3b82f6;
    --accent-brand-light: rgba(59, 130, 246, 0.15);
    
    --shadow-subtle: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
    --shadow-dock: 0 10px 30px -5px rgba(0, 0, 0, 0.6);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Hide Balkangraph Default Built-in Edit Form */
.bft-edit-form, form[data-bft-edit-form] {
    display: none !important;
}

/* SVG Node Card Light Mode Styling */
.bft-node-bg {
    fill: #ffffff;
    stroke: #e2e8f0;
    transition: fill 0.3s ease, stroke 0.3s ease;
}

.bft-node-name {
    fill: #1e293b;
    font-size: 15px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    transition: fill 0.3s ease;
}

.bft-node-patronymic {
    fill: #64748b;
    font-size: 13px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    transition: fill 0.3s ease;
}

.bft-node-line {
    stroke: #e2e8f0;
    transition: stroke 0.3s ease;
}

.bft-node-pill {
    fill: #f1f5f9;
    transition: fill 0.3s ease;
}

.bft-node-pill-text {
    fill: #334155;
    font-size: 12.5px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    transition: fill 0.3s ease;
}

/* SVG Node Card Dark Mode Styling (Linear / Notion Dark) */
.dark .bft-node-bg {
    fill: #141518;
    stroke: #26282d;
}

.dark .bft-node-name {
    fill: #f5f5f5;
}

.dark .bft-node-patronymic {
    fill: #a1a1aa;
}

.dark .bft-node-line {
    stroke: #26282d;
}

.dark .bft-node-pill {
    fill: #1c1e22;
}

.dark .bft-node-pill-text {
    fill: #cbd5e1;
}

/* Telegram Chat Style Memory Bubbles */
.chat-bubble {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 14px 16px;
    position: relative;
    box-shadow: var(--shadow-subtle);
    max-width: 100%;
    align-self: stretch;
}

.chat-bubble-header {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 0.82rem;
    color: var(--accent-brand);
    font-weight: 700;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 6px;
}

.chat-bubble-source {
    color: var(--accent-brand);
    font-size: 0.85rem;
    font-weight: 700;
}

.chat-bubble-uploader {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.chat-bubble-body {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.5;
    margin-top: 6px;
}

.chat-bubble-time {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    text-align: right;
    margin-top: 6px;
}

.btn-download-media {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    margin-top: 8px;
    transition: all 0.2s ease;
}

.btn-download-media:hover {
    background: var(--accent-brand);
    color: #ffffff;
    border-color: var(--accent-brand);
}

/* Floating Dock Navbar */
.navbar-dock-wrapper {
    position: fixed;
    top: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    z-index: 500;
    padding: 0 20px;
}

.navbar-dock {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 950px;
    height: 54px;
    padding: 0 12px 0 20px;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-dock);
    transition: all 0.3s ease;
}

.nav-brand {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-brand span {
    color: var(--accent-brand);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    background: var(--border-subtle);
    color: var(--text-primary);
}

.btn-dock-cta {
    background: var(--accent-primary);
    color: var(--bg-page);
    padding: 8px 18px;
    border-radius: var(--radius-full);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-dock-cta:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

/* Floating Controls (Zoom & Center & Export Widget) */
.floating-controls {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 450;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 8px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-dock);
}

.control-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: var(--accent-brand);
    color: #ffffff;
    border-color: var(--accent-brand);
    transform: scale(1.08);
}

/* Header Search Box */
.search-box {
    position: relative;
}

.search-input {
    padding: 7px 14px 7px 34px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    width: 150px;
    transition: all 0.3s ease;
}

.search-input:focus {
    width: 190px;
    background: var(--bg-surface);
    border-color: var(--accent-brand);
    box-shadow: 0 0 0 3px var(--accent-brand-light);
}

.search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--text-tertiary);
    pointer-events: none;
}

/* Modal Overlay & Card (Senior UI/UX Notion/Linear style) */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow-y: auto;
    padding: 20px;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    margin: 40px auto;
    padding: 28px;
    width: 100%;
    max-width: 460px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-dock);
    position: relative;
    color: var(--text-primary);
}

.modal-content h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 20px;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: var(--text-tertiary);
    font-size: 24px;
    font-weight: 600;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

.close:hover {
    color: var(--text-primary);
}

.input-group {
    margin-bottom: 16px;
}

/* Hero Section */
.hero-container {
    padding: 140px 20px 80px;
    max-width: 1080px;
    margin: 0 auto;
    text-align: center;
}

.hero-pill-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    background: var(--accent-brand-light);
    color: var(--accent-brand);
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 24px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.hero-title span {
    background: linear-gradient(135deg, #0066ff 0%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 640px;
    margin: 0 auto 36px;
    font-weight: 400;
    line-height: 1.6;
}

/* Clean Notion/Linear Access Card */
.access-card-container {
    max-width: 440px;
    margin: 0 auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-subtle);
    text-align: left;
}

.input-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: block;
}

.input-field-clean {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: all 0.2s ease;
}

.input-field-clean:focus {
    border-color: var(--accent-brand);
    box-shadow: 0 0 0 3px var(--accent-brand-light);
}

.btn-hero-primary {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-lg);
    background: var(--accent-primary);
    color: var(--bg-page);
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    margin-top: 16px;
    transition: all 0.2s ease;
}

.btn-hero-primary:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

/* Feature Grid Section */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    max-width: 1080px;
    margin: 60px auto 100px;
    padding: 0 20px;
}

.feature-card-clean {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 28px;
    transition: all 0.25 ease;
}

.feature-card-clean:hover {
    border-color: var(--text-tertiary);
    transform: translateY(-2px);
}

.feature-icon-box {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    background: var(--accent-brand-light);
    color: var(--accent-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 18px;
}

.feature-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.feature-desc {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Canvas & Dot Grid Pattern (Subtle, elegant Linear/Notion style dot grid) */
#tree-container {
    flex: 1;
    width: 100%;
    height: 100vh;
    background-color: #f8fafc !important;
    background-image: radial-gradient(rgba(100, 116, 139, 0.28) 1.5px, transparent 1.5px) !important;
    background-size: 24px 24px !important;
    transition: background-color 0.3s ease;
}

.dark #tree-container {
    background-color: #000000 !important;
    background-image: radial-gradient(rgb(255 255 255 / 7%) 1.5px, transparent 1.5px) !important;
    background-size: 24px 24px !important;
}

/* Force ALL BalkanGraph theme classes (.bft-light, .bft-dark, etc) to be 100% transparent */
.bft-light,
.bft-dark,
.bft-container,
div[class*="bft-"],
#tree-container svg.bft,
#tree-container [data-bft],
#tree-container > div {
    background: transparent !important;
    background-color: transparent !important;
}

/* Hide BalkanGraph's inner solid background rects so dot grid is 100% visible */
#tree-container svg.bft > rect,
#tree-container svg.bft rect[width="100%"],
#tree-container svg.bft rect.bft-bg,
#tree-container svg.bft g.bft-bg {
    fill: transparent !important;
    display: none !important;
}

/* Keep node card backgrounds solid */
#tree-container rect.bft-node-bg {
    display: block !important;
    fill: var(--bg-surface, #ffffff) !important;
}

/* Canvas background panning cursors (Outside cards) */
#tree-container svg.bft,
#tree-container .bft-container,
#tree-container [data-bft] {
    cursor: grab !important;
}

#tree-container svg.bft:active,
#tree-container .bft-container:active,
#tree-container [data-bft]:active {
    cursor: grabbing !important;
}

/* Person Card pointer cursor (Hovering over cards) */
#tree-container g[data-n-id],
#tree-container .bft-node,
#tree-container rect.bft-node-bg,
#tree-container g[data-n-id] * {
    cursor: pointer !important;
}

/* Side Inspector Drawer (family-tree-builder style - Wider 440px) */
.inspector-sidebar {
    position: fixed;
    top: 90px;
    left: 20px;
    bottom: 30px;
    width: 440px;
    max-width: calc(100vw - 40px);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-dock);
    z-index: 400;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.inspector-sidebar.collapsed {
    transform: translateX(-500px);
    opacity: 0;
    pointer-events: none;
}

.inspector-tab-bar {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-page);
}

.inspector-tab {
    flex: 1;
    padding: 12px 8px;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.inspector-tab.active {
    color: var(--accent-brand);
    border-bottom-color: var(--accent-brand);
    background: var(--bg-surface);
}

.inspector-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.sidebar-table-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.88rem;
}

.sidebar-table-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.sidebar-table-val {
    color: var(--text-primary);
    font-weight: 600;
    text-align: right;
}

.action-btn-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
}

.btn-side-action {
    width: 100%;
    padding: 11px 14px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-side-action:hover {
    background: var(--accent-brand-light);
    color: var(--accent-brand);
    border-color: var(--accent-brand);
}

.btn-side-main {
    background: var(--accent-brand);
    color: #ffffff;
    border: none;
}

.btn-side-main:hover {
    opacity: 0.9;
    color: #ffffff;
    transform: translateY(-1px);
}

.btn-side-danger {
    color: #ef4444;
}

.btn-side-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

.sidebar-toggle-btn {
    position: fixed;
    bottom: 30px;
    left: 20px;
    z-index: 450;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-dock);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover {
    transform: scale(1.08);
}

/* Footer */
.footer-clean {
    border-top: 1px solid var(--border-color);
    padding: 40px 20px;
    text-align: center;
    font-size: 0.88rem;
    color: var(--text-tertiary);
}

/* Comprehensive Mobile & Touchscreen Responsiveness */
@media (max-width: 768px) {
    .navbar-dock-wrapper {
        top: 10px;
        padding: 0 10px;
    }
    
    .navbar-dock {
        height: auto;
        padding: 8px 14px;
        flex-wrap: wrap;
        gap: 8px;
        border-radius: 20px;
    }
    
    .family-info {
        order: 3;
        width: 100%;
        justify-content: center;
        border-top: 1px solid var(--border-subtle);
        padding-top: 6px;
    }
    
    .search-input {
        width: 110px;
    }
    
    .search-input:focus {
        width: 140px;
    }
    
    .inspector-sidebar {
        top: 85px;
        left: 10px;
        bottom: 15px;
        width: calc(100vw - 20px);
        max-width: 100%;
        z-index: 600;
    }
    
    .floating-controls {
        bottom: 20px;
        right: 15px;
        padding: 6px;
    }
    
    .sidebar-toggle-btn {
        bottom: 20px;
        left: 15px;
    }
    
    .modal-content {
        margin: 15px auto;
        padding: 20px 16px;
        max-width: 100%;
    }
    
    .hero-title {
        font-size: 2.4rem;
    }
    .hero-subtitle {
        font-size: 1rem;
    }
}
