/* ===================================================================
   GENEALOGY PREMIUM DESIGN SYSTEM
   =================================================================== */

:root {
    /* Color Palette - Premium Royal Gold & Deep Crimson */
    --primary-main: #b38b4d;
    --primary-dark: #8c6d3d;
    --primary-light: #d4ae78;
    
    --accent-red: #8b0000;
    --accent-gold: #ffd700;
    
    --bg-deep: #0f1218;
    --bg-dark: #1a1f26;
    --bg-card: rgba(30, 39, 51, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.05);
    
    --text-main: #e0e6ed;
    --text-muted: #94a3b8;
    --text-gold: #caa052;
    
    --border-color: rgba(202, 160, 82, 0.2);
    --border-bright: rgba(202, 160, 82, 0.4);
    
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    
    --sidebar-width: 260px;
    --sidebar-collapsed: 80px;
    --header-height: 70px;
    --mobile-nav-height: 70px;
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Mode Overrides */
:root.light-mode {
    --bg-deep: #f0f2f5;
    --bg-dark: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-glass: rgba(0, 0, 0, 0.05);
    
    --text-main: #1a1f26;
    --text-muted: #64748b;
    --text-gold: #a37c3d;
    
    --border-color: rgba(0, 0, 0, 0.08);
    --border-bright: rgba(179, 139, 77, 0.3);
    
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-deep);
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(179, 139, 77, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(139, 0, 0, 0.05) 0%, transparent 40%);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color var(--transition-base), color var(--transition-base);
}

:root.light-mode body {
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(179, 139, 77, 0.03) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(139, 0, 0, 0.02) 0%, transparent 40%);
}

h1, h2, h3, h4, h5 {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    color: var(--text-gold);
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition-fast);
}

ul {
    list-style: none;
}

/* --- Layout Structure --- */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-dark);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-base);
    z-index: 1000;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

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

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

.logo-icon {
    font-size: 28px;
    color: var(--text-gold);
    flex-shrink: 0;
}

.logo-text {
    font-family: 'Playfair Display', serif;
    font-weight: 800;
    font-size: 20px;
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition-base);
}

.sidebar.collapsed .logo-text {
    opacity: 0;
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
}

/* Nav Links */
.nav-links {
    padding: 20px 0;
    flex-grow: 1;
}

.nav-links li {
    padding: 4px 15px;
}

.nav-links a {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-radius: 20px; /* Bo tròn menu */
    color: var(--text-muted);
    gap: 15px;
    white-space: nowrap;
}

.nav-links a i {
    font-size: 24px;
    flex-shrink: 0;
}

.nav-links .link-name {
    font-size: 15px;
    font-weight: 500;
    opacity: 1;
    transition: opacity var(--transition-base);
}

.sidebar.collapsed .link-name {
    opacity: 0;
}

.nav-links li.active a,
.nav-links a:hover {
    background: rgba(202, 160, 82, 0.1);
    color: var(--text-gold);
}

.bottom-links {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    background: var(--bg-deep);
}

.top-header {
    height: var(--header-height);
    background: rgba(15, 18, 24, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 900;
    border-bottom: 1px solid var(--border-color);
}

.header-greeting h1 {
    font-size: 1.5rem;
    margin: 0;
}

#current-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid var(--text-gold);
}

/* Theme Toggle Button */
.theme-toggle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    color: var(--text-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 22px;
    transition: var(--transition-base);
}

.theme-toggle:hover {
    background: var(--primary-main);
    color: #fff;
    transform: rotate(15deg);
}

.header-profile {
    display: flex;
    align-items: center;
    gap: 15px;
}

.content-body {
    padding: 30px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Glass Card System */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 30px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 30px;
}

/* Hero Banner */
.hero-banner {
    display: flex;
    align-items: center;
    min-height: 280px;
    background: linear-gradient(135deg, rgba(30, 39, 51, 0.9), rgba(15, 18, 24, 0.9)), 
                url('https://images.unsplash.com/photo-1518709268805-4e9042af9f23?q=80&w=2000&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
    transition: background var(--transition-base);
}

:root.light-mode .hero-banner {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(240, 242, 245, 0.9)), 
                url('https://images.unsplash.com/photo-1518709268805-4e9042af9f23?q=80&w=2000&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
}

.hero-content h2 {
    font-size: 2.8rem;
    line-height: 1.2;
    margin-bottom: 20px;
}

.highlight-text {
    color: var(--text-gold);
    position: relative;
}

.hero-content p {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 600px;
    margin-bottom: 30px;
}

.primary-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background-color: var(--primary-main);
    color: #fff;
    padding: 14px 28px;
    border-radius: 14px;
    font-weight: 700;
    transition: var(--transition-base);
}

.primary-btn:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(179, 139, 77, 0.3);
}

/* Modules Grid */
.dashboard-section-title {
    margin-bottom: 20px;
    font-size: 1.4rem;
}

.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.module-card {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 25px;
    transition: var(--transition-base);
}

.module-card:hover {
    transform: translateY(-5px);
    border-color: var(--border-bright);
    background: rgba(202, 160, 82, 0.05);
}

.icon-wrapper {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    margin-bottom: 20px;
}

.bg-orange { background: rgba(255, 152, 0, 0.15); color: #ff9800; }
.bg-green { background: rgba(76, 175, 80, 0.15); color: #4caf50; }
.bg-blue { background: rgba(33, 150, 243, 0.15); color: #2196f3; }
.bg-purple { background: rgba(156, 39, 176, 0.15); color: #9c27b0; }

.module-card h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.module-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Events Section */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.view-all {
    font-size: 0.9rem;
    color: var(--text-gold);
    display: flex;
    align-items: center;
    gap: 5px;
}

.event-item {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 18px;
    padding: 15px 20px;
    gap: 20px;
}

.event-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--primary-main);
    color: #fff;
    min-width: 65px;
    height: 65px;
    border-radius: 15px;
}

.event-date .day { font-size: 1.2rem; font-weight: 800; line-height: 1; }
.event-date .month { font-size: 0.6rem; font-weight: 600; text-transform: uppercase; }

.event-details flex-grow: 1;

.event-details h4 { font-size: 1.1rem; margin-bottom: 4px; }
.event-details p { font-size: 0.85rem; color: var(--text-muted); }

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-icon:hover { color: var(--text-gold); }

/* --- Mobile Navigation --- */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    background: rgba(15, 18, 24, 0.9);
    backdrop-filter: blur(15px);
    border-top: 1px solid var(--border-color);
    z-index: 1100;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.65rem;
    gap: 4px;
    transition: var(--transition-fast);
    flex: 1;
}

.nav-item i { font-size: 24px; }
.nav-item.active { color: var(--text-gold); }

/* Central Button */
.center-btn-wrapper {
    position: relative;
    top: -20px;
    z-index: 1200;
}

.center-btn {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary-main), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(179, 139, 77, 0.4);
    border: 4px solid var(--bg-deep);
    transition: var(--transition-base);
}

.center-btn i { color: #fff; font-size: 28px; }

/* Mobile Popup */
.mobile-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1500;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.mobile-popup-overlay.active { display: flex; opacity: 1; align-items: flex-end; }

.mobile-popup-content {
    width: 100%;
    background: var(--bg-dark);
    border-radius: 30px 30px 0 0;
    padding: 30px;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-popup-overlay.active .mobile-popup-content { transform: translateY(0); }

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.close-popup {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
}

.popup-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.popup-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}

.popup-item .icon-wrapper {
    margin-bottom: 0;
}

.popup-item span { font-size: 0.8rem; font-weight: 500; }

/* Responsive adjustments */
@media (max-width: 1024px) {
    .sidebar { display: none; }
    .mobile-nav { display: flex; }
    .main-content { height: calc(100vh - var(--mobile-nav-height)); }
    .top-header { padding: 0 20px; }
    .content-body { padding: 20px; }
    .hero-content h2 { font-size: 2rem; }
}

@media (min-width: 1025px) {
    .mobile-nav { display: none !important; }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.content-body > section {
    animation: fadeIn 0.8s ease forwards;
}

/* Canvas Specifics */
.canvas-page .main-content {
    background: var(--bg-deep);
    overflow: hidden;
    position: relative; /* Essential for absolute positioning of toolbars */
}

.canvas-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    cursor: grab;
    overflow: hidden;
}

.canvas-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: row;
    gap: 8px;
    z-index: 10;
}

.control-btn {
    background: rgba(15, 25, 35, 0.85); /* Tối hơn, đục hơn */
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%; /* Nút điều khiển tròn hẳn */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition-base), opacity 0.3s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5); /* Đổ bóng mạnh hơn */
    opacity: 1; /* Loại bỏ làm mờ để luôn dễ nhìn */
}

.control-btn:hover {
    background: rgba(30, 39, 51, 0.95);
    color: var(--text-gold);
    border-color: rgba(202, 160, 82, 0.4);
    opacity: 1;
}

.sidebar-tools {
    margin-top: auto;
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.sidebar-tool-btn {
    display: flex;
    align-items: center;
    gap: 15px; 
    padding: 12px 15px; 
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 20px; /* Bo tròn nút công cụ đồng bộ nav-links */
    transition: var(--transition-base);
    width: 100%;
}
.sidebar-tool-btn i {
    font-size: 24px;
    flex-shrink: 0;
}
.sidebar-tool-btn .tool-name {
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition-base);
}
.sidebar.collapsed .sidebar-tool-btn .tool-name {
    opacity: 0;
}
.sidebar-tool-btn:hover {
    background: rgba(202, 160, 82, 0.1);
    color: var(--text-bright);
}
.sidebar-tool-btn.highlight {
    color: #4caf50; 
}
.sidebar-tool-btn.highlight:hover {
    background: rgba(76, 175, 80, 0.1);
}

/* Settings Panel */
.settings-panel {
    position: absolute;
    top: 70px;
    right: 20px;
    width: 260px;
    background: rgba(30, 39, 51, 0.95);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    z-index: 1000;
    display: none;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    color: var(--text-bright);
}
.settings-panel.active {
    display: flex;
    animation: qi-slide-up 0.2s ease-out;
}
.sp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sp-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}
.sp-header button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition-base);
}
.sp-header button:hover {
    color: var(--text-gold);
}
.sp-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.sp-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sp-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.sp-control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0,0,0,0.3);
    border-radius: 20px; /* Bo tròn mạnh cho hàng điều khiển */
    padding: 4px;
}
.sp-control-row button {
    background: transparent;
    border: none;
    color: var(--text-bright);
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}
.sp-control-row button:hover {
    background: rgba(255,255,255,0.1);
}
.sp-control-row span {
    font-size: 0.9rem;
    font-weight: 500;
}
.sp-group input[type="color"] {
    width: 100%;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px; /* Bo tròn ô màu */
    cursor: pointer;
    background: rgba(0,0,0,0.2);
    padding: 2px;
}
.sp-group input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}
}

.sp-divider {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-gold);
    letter-spacing: 1px;
    margin: 20px 0 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(202, 160, 82, 0.2);
}

.sp-select {
    width: 100%;
    height: 36px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px; /* Bo tròn ô chọn */
    color: var(--text-bright);
    padding: 0 10px;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
}
.sp-select option {
    background: var(--bg-dark);
    color: var(--text-bright);
}

/* Background Patterns */
.canvas-wrapper {
    background-color: var(--bg-deep);
}

.bg-pattern-none {
    background-image: none !important;
}

.bg-pattern-modern {
    background-image: radial-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px) !important;
    background-size: 20px 20px !important;
}

.bg-pattern-grid {
    background-image: 
      linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px) !important;
    background-size: 40px 40px !important;
}

.bg-pattern-antique {
    background-image: repeating-linear-gradient(45deg, rgba(202, 160, 82, 0.06) 0, rgba(202, 160, 82, 0.06) 2px, transparent 2px, transparent 8px) !important;
}

/* Hoa văn Giao thoa Đồng tiền Truyền Thống */
.bg-pattern-coins {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23caa052' stroke-width='2' stroke-opacity='0.1'%3E%3Ccircle cx='60' cy='60' r='20'/%3E%3Ccircle cx='60' cy='60' r='40'/%3E%3Ccircle cx='60' cy='60' r='60'/%3E%3Ccircle cx='0' cy='0' r='20'/%3E%3Ccircle cx='0' cy='0' r='40'/%3E%3Ccircle cx='0' cy='0' r='60'/%3E%3Ccircle cx='120' cy='0' r='20'/%3E%3Ccircle cx='120' cy='0' r='40'/%3E%3Ccircle cx='120' cy='0' r='60'/%3E%3Ccircle cx='0' cy='120' r='20'/%3E%3Ccircle cx='0' cy='120' r='40'/%3E%3Ccircle cx='0' cy='120' r='60'/%3E%3Ccircle cx='120' cy='120' r='20'/%3E%3Ccircle cx='120' cy='120' r='40'/%3E%3Ccircle cx='120' cy='120' r='60'/%3E%3C/g%3E%3C/svg%3E") !important;
}

/* Hoa văn Kiến trúc Á Đông vòng cung (Mây nước / Seigaiha) */
.bg-pattern-waves {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='20' viewBox='0 0 40 20'%3E%3Cg fill='none' stroke='%23caa052' stroke-width='1.5' stroke-opacity='0.1'%3E%3Cpath d='M0 20 c10-15, 30-15, 40 0'/%3E%3Cpath d='M-20 20 c10-15, 30-15, 40 0'/%3E%3Cpath d='M20 20 c10-15, 30-15, 40 0'/%3E%3Cpath d='M0 10 c10-15, 30-15, 40 0'/%3E%3Cpath d='M-20 10 c10-15, 30-15, 40 0'/%3E%3Cpath d='M20 10 c10-15, 30-15, 40 0'/%3E%3C/g%3E%3C/svg%3E") !important;
}

/* Hoa văn Khung Cửa Lưới (Grid Trung Hoa) */
.bg-pattern-lattice {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cg fill='none' stroke='%23caa052' stroke-width='1.5' stroke-opacity='0.1'%3E%3Cpath d='M0 20h40 M20 0v40 M0 0l40 40 M40 0L0 40'/%3E%3C/g%3E%3C/svg%3E") !important;
}

/* Hoa văn Tổ ong (Lục giác) */
.bg-pattern-honeycomb {
    background-image: url("data:image/svg+xml,%3Csvg width='28' height='49' viewBox='0 0 28 49' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23caa052' stroke-width='1.5' stroke-opacity='0.08'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM14 0l14 8v16L14 32l-14-8V8l14-8z'/%3E%3C/g%3E%3C/svg%3E") !important;
}

/* Hoa văn Kim cương (Họa tiết hình thoi) */
.bg-pattern-diamond {
    background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23caa052' stroke-width='1' stroke-opacity='0.1'%3E%3Cpath d='M20 0 L40 20 L20 40 L0 20 Z'/%3E%3C/g%3E%3C/svg%3E") !important;
}

/* Hoa văn Gạch xếp (Kiến trúc cổ) */
.bg-pattern-brick {
    background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23caa052' stroke-width='1' stroke-opacity='0.12'%3E%3Cpath d='M0 20h40 M20 20v20 M0 0v20'/%3E%3C/g%3E%3C/svg%3E") !important;
}

/* Hoa văn Đồng tâm (Mặt trời / La bàn) */
.bg-pattern-radar {
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23caa052' stroke-width='1' stroke-opacity='0.08'%3E%3Ccircle cx='30' cy='30' r='10'/%3E%3Ccircle cx='30' cy='30' r='20'/%3E%3Ccircle cx='30' cy='30' r='30'/%3E%3C/g%3E%3C/svg%3E") !important;
}

.quick-info-panel {
    position: absolute;
    left: 20px;
    bottom: 20px;
    width: 300px; /* Increased slightly for 3 buttons row */
    display: none;
    z-index: 1000;
    pointer-events: none;
}

.quick-info-panel.active {
    display: block;
    pointer-events: auto;
    animation: qi-slide-up 0.3s ease-out;
}

@keyframes qi-slide-up {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.qi-card {
    background: var(--bg-card);
    backdrop-filter: blur(30px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 12px; /* Even smaller padding */
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

.qi-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px; /* Less margin */
}

.qi-avatar {
    width: 42px; /* Smaller avatar */
    height: 42px;
    border-radius: 50%;
    border: 1.5px solid var(--text-gold);
}

.qi-name h3 {
    margin: 0;
    font-size: 1rem; /* Smaller font */
    color: var(--text-gold);
    line-height: 1.1;
}

.qi-name p {
    margin: 0;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.qi-details {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 6px 0;
    margin-bottom: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.qi-item span {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.qi-item strong {
    font-size: 0.85rem;
    color: var(--text-bright);
}

/* Quick Info Actions */
.qi-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 8px;
}

.action-btn {
    display: flex;
    flex-direction: row; 
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 4px;
    border-radius: 12px; /* Bo tròn nút thao tác */
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-muted);
    font-size: 0.75rem; 
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-base);
    white-space: nowrap;
}

.action-btn i {
    font-size: 1rem;
    color: var(--text-muted);
    transition: var(--transition-base);
}

.action-btn.add:hover { background: rgba(76, 175, 80, 0.1); border-color: rgba(76, 175, 80, 0.3); color: #4caf50; }
.action-btn.add:hover i { color: #4caf50; }

.action-btn.edit:hover { background: rgba(33, 150, 243, 0.1); border-color: rgba(33, 150, 243, 0.3); color: #2196f3; }
.action-btn.edit:hover i { color: #2196f3; }

.action-btn.delete:hover { background: rgba(244, 67, 54, 0.1); border-color: rgba(244, 67, 54, 0.3); color: #f44336; }
.action-btn.delete:hover i { color: #f44336; }

/* Modal Editor */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid rgba(202, 160, 82, 0.2);
    border-radius: 24px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    animation: modalSlide 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

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

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-family: var(--font-fancy);
    font-size: 1.5rem;
    color: var(--text-gold);
}

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--transition-base);
}
.close-modal:hover { color: var(--text-gold); }

.modal-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group { flex: 1; }

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.form-group input, .form-group textarea {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px; /* Bo tròn ô nhập liệu */
    padding: 12px;
    color: var(--text-bright);
    font-size: 0.9rem;
    transition: var(--transition-base);
}

.form-group input:focus, .form-group textarea:focus {
    border-color: var(--text-gold);
    background: rgba(0,0,0,0.3);
    outline: none;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Synchronized Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 25px; /* Nút hình thuốc (Pill shape) */
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-base);
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-main), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 15px rgba(179, 139, 77, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(179, 139, 77, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-main);
}

/* Premium Upload Area */
.upload-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border: 2px dashed rgba(202, 160, 82, 0.3);
    border-radius: 20px;
    transition: var(--transition-base);
    cursor: pointer;
}

.upload-group:hover {
    border-color: var(--text-gold);
    background: rgba(202, 160, 82, 0.05);
}

.upload-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid var(--text-gold);
    object-fit: cover;
    box-shadow: var(--shadow-md);
    background: var(--bg-dark);
}

.upload-info {
    text-align: center;
}

.upload-info i {
    font-size: 24px;
    color: var(--text-gold);
    margin-bottom: 5px;
    display: block;
}

.upload-info span {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Canvas Search Box v2 (Expandable) */
.search-box-v2 {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
}

.search-inner {
    display: flex;
    align-items: center;
    background: rgba(15, 25, 35, 0.85); /* Tối hơn, đục hơn */
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 30px; /* Thanh tìm kiếm dạng viên thuốc tròn hẳn */
    padding: 6px;
    width: 38px;
    height: 38px;
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28), background 0.3s, border-color 0.3s, opacity 0.3s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5); /* Đổ bóng mạnh hơn */
    opacity: 1; /* Loại bỏ làm mờ */
}

.search-inner:hover,
.search-inner:focus-within {
    width: 250px;
    background: rgba(0, 0, 0, 1);
    border-color: rgba(202, 160, 82, 0.5);
    opacity: 1;
}

.search-inner i {
    font-size: 1.2rem;
    color: #fff;
    min-width: 24px;
    text-align: center;
    cursor: pointer;
    transition: color 0.3s;
}

.search-inner:hover i,
.search-inner:focus-within i {
    color: var(--text-gold);
}

.search-inner input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.9rem;
    padding-left: 10px;
    width: 100%;
    outline: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    transform: translateX(10px);
    white-space: nowrap;
}

.search-inner:hover input,
.search-inner:focus-within input {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.clear-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.clear-btn:hover {
    color: #f44336;
}

/* Tree Manager Modal Specifics */
.tree-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
}

.tree-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 15px 20px;
    border-radius: 16px;
    transition: var(--transition-base);
    cursor: pointer;
}

:root.light-mode .tree-item {
    background: rgba(0, 0, 0, 0.03);
}

.tree-item:hover {
    border-color: var(--text-gold);
    background: rgba(202, 160, 82, 0.1);
    transform: translateX(5px);
}

.tree-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tree-name {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-main);
}

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

.tree-item-actions {
    display: flex;
    gap: 8px;
}

.tree-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: var(--transition-base);
}

.tree-btn.open { background: var(--primary-main); color: #fff; }
.tree-btn.delete { background: rgba(239, 68, 68, 0.1); color: #ef4444; }

.tree-btn:hover { transform: scale(1.1); }
.tree-btn.delete:hover { background: #ef4444; color: #fff; }

.add-tree-btn {
    margin-top: 20px;
    width: 100%;
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    padding: 12px;
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition-base);
}

.add-tree-btn:hover {
    border-color: var(--text-gold);
    color: var(--text-gold);
    background: rgba(202, 160, 82, 0.05);
}
}