:root {
    /* Colors */
    --bg-dark: #0f111a;
    --bg-card: rgba(26, 31, 46, 0.6);
    --bg-card-hover: rgba(45, 53, 77, 0.8);
    --primary: #00f0ff;
    --secondary: #ff0055;
    --accent: #8a2be2;
    --text-main: #ffffff;
    --text-muted: #a0aec0;
    
    /* Element Colors */
    --elem-phong: #10b981; /* Phong - Green */
    --elem-thuy: #3b82f6; /* Thủy - Blue */
    --elem-hoa: #ef4444; /* Hỏa - Red */
    --elem-dia: #f59e0b; /* Địa - Orange */
    --elem-none: #9ca3af; /* Không - Gray */

    /* Glassmorphism */
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-blur: blur(12px);

    /* Fonts */
    --font-heading: 'Be Vietnam Pro', sans-serif;
    --font-body: 'Be Vietnam Pro', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background overlay with a subtle gradient/image */
.bg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 15% 50%, rgba(138, 43, 226, 0.15), transparent 25%),
                radial-gradient(circle at 85% 30%, rgba(0, 240, 255, 0.15), transparent 25%);
    z-index: -1;
    pointer-events: none;
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1rem;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 3rem;
    padding: 0 1rem;
}

.logo-icon {
    color: var(--primary);
    width: 32px;
    height: 32px;
    filter: drop-shadow(0 0 8px var(--primary));
}

.logo h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 1px;
}

.logo span {
    color: var(--secondary);
    text-shadow: 0 0 10px rgba(255, 0, 85, 0.5);
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    transform: translateX(5px);
}

.nav-btn.active {
    font-weight: 700;
}

/* Nav specific colors */
.nav-color-1.active { border-left: 4px solid var(--elem-phong); background: linear-gradient(90deg, rgba(16, 185, 129, 0.15) 0%, transparent 100%); color: var(--elem-phong); }
.nav-color-2.active { border-left: 4px solid var(--elem-thuy); background: linear-gradient(90deg, rgba(59, 130, 246, 0.15) 0%, transparent 100%); color: var(--elem-thuy); }
.nav-color-3.active { border-left: 4px solid var(--elem-hoa); background: linear-gradient(90deg, rgba(239, 68, 68, 0.15) 0%, transparent 100%); color: var(--elem-hoa); }
.nav-color-4.active { border-left: 4px solid var(--elem-dia); background: linear-gradient(90deg, rgba(245, 158, 11, 0.15) 0%, transparent 100%); color: var(--elem-dia); }
.nav-color-5.active { border-left: 4px solid var(--accent); background: linear-gradient(90deg, rgba(138, 43, 226, 0.15) 0%, transparent 100%); color: var(--accent); }
.nav-color-6.active { border-left: 4px solid #eab308; background: linear-gradient(90deg, rgba(234, 179, 8, 0.15) 0%, transparent 100%); color: #eab308; }
.nav-color-7.active { border-left: 4px solid var(--primary); background: linear-gradient(90deg, rgba(0, 240, 255, 0.15) 0%, transparent 100%); color: var(--primary); }
.nav-color-8.active { border-left: 4px solid #ec4899; background: linear-gradient(90deg, rgba(236, 72, 153, 0.15) 0%, transparent 100%); color: #ec4899; }
.nav-color-9.active { border-left: 4px solid #f59e0b; background: linear-gradient(90deg, rgba(245, 158, 11, 0.15) 0%, transparent 100%); color: #f59e0b; }

/* Color blocks used instead of icons */
.logo-color-block {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    box-shadow: 0 0 10px var(--primary);
}

.spin-color-block {
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 4px;
    animation: spin 1s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    padding: 2rem 3rem;
    background: linear-gradient(180deg, rgba(15, 17, 26, 0.9) 0%, transparent 100%);
}

.search-container {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

.search-icon {
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

#global-search {
    width: 100%;
    padding: 1.2rem 1.5rem 1.2rem 4.5rem;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(0, 240, 255, 0.3);
    border-radius: 20px;
    color: #ffffff;
    font-family: var(--font-body);
    font-size: 1.1rem;
    outline: none;
    backdrop-filter: var(--glass-blur);
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.1), inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

#global-search::placeholder {
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
}

#global-search:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--primary);
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.3), inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

.fancy-input {
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(0, 240, 255, 0.3);
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: bold;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.fancy-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
    font-weight: normal;
}

.fancy-input:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.2), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.fancy-select {
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(0, 240, 255, 0.3);
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 500;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
    width: 100%;
    cursor: pointer;
    font-size: 0.95rem;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300f0ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 40px;
}

.fancy-select:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.2), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.fancy-select option {
    background: #1a1f2e;
    color: #fff;
}

/* Content Area */
.content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 0 3rem 3rem;
}

.hidden {
    display: none !important;
}

.loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 200px;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: var(--primary);
}

.spin {
    animation: spin 1s linear infinite;
}

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

/* Filters */
.filters-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    padding: 0.5rem;
    border-radius: 12px;
    border: var(--glass-border);
}

.filter-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 500;
    transition: all 0.2s ease;
}

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

.filter-btn.active {
    background: var(--primary);
    color: var(--bg-dark);
    font-weight: 600;
}

/* Grids & Cards */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem;
}

.card {
    background: var(--bg-card);
    border: var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    backdrop-filter: var(--glass-blur);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: break-word;
}

.card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.2);
}

.card.city-card {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.15) 0%, rgba(255, 0, 255, 0.05) 100%);
    border: 2px solid #c084fc;
    box-shadow: 0 0 12px rgba(192, 132, 252, 0.3), inset 0 0 15px rgba(192, 132, 252, 0.1);
}

.card.city-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(192, 132, 252, 0.5), inset 0 0 25px rgba(192, 132, 252, 0.2);
    border-color: #e879f9;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover::before {
    opacity: 1;
}

/* Typography in Cards */
.card h3 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    margin-bottom: 0.3rem;
    color: var(--text-main);
}

.card p {
    font-size: 0.9rem;
    margin-bottom: 0.15rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-label {
    color: var(--text-muted);
}

.card-value {
    font-weight: 600;
}

/* Elements Badges */
.elem-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.elem-1 { background: rgba(245, 158, 11, 0.2); color: var(--elem-dia); border: 1px solid var(--elem-dia); }
.elem-2 { background: rgba(59, 130, 246, 0.2); color: var(--elem-thuy); border: 1px solid var(--elem-thuy); }
.elem-3 { background: rgba(239, 68, 68, 0.2); color: var(--elem-hoa); border: 1px solid var(--elem-hoa); }
.elem-4 { background: rgba(16, 185, 129, 0.2); color: var(--elem-phong); border: 1px solid var(--elem-phong); }
.elem-0 { background: rgba(156, 163, 175, 0.2); color: var(--elem-none); border: 1px solid var(--elem-none); }



/* Optimal Grid visualizer */
.formation-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 1rem;
    background: rgba(0,0,0,0.3);
    padding: 1rem;
    border-radius: 12px;
    border: var(--glass-border);
}

.formation-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.formation-col-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.formation-cell {
    width: 100%;
    height: 50px;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    border: 1px dashed rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    text-align: center;
    color: var(--text-muted);
    padding: 4px;
}

.formation-cell.filled {
    background: rgba(0, 240, 255, 0.1);
    border: 1px solid var(--primary);
    color: var(--primary);
    font-weight: 600;
    box-shadow: inset 0 0 10px rgba(0, 240, 255, 0.2);
}

/* Sub-map tag badges */
.submap-tag {
    display: inline-block;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    margin: 3px;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.submap-tag:hover {
    background: rgba(0, 240, 255, 0.1);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
}

.submap-id {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    margin-left: 2px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        padding: 1rem;
        border-right: none;
        border-bottom: var(--glass-border);
    }
    
    .logo {
        margin-bottom: 1rem;
    }
    
    .nav-links {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }
    
    .nav-btn {
        white-space: nowrap;
        padding: 0.8rem;
    }
    
    .topbar {
        padding: 1rem;
    }
    
    .content-wrapper {
        padding: 0 1rem 1rem;
    }
}

/* Map Auto-Pathfinder Styles */
.navigation-tab-container {
    grid-column: 1 / -1;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.autocomplete-wrapper {
    position: relative;
    width: 100%;
}

.autocomplete-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #1a1f2e;
    border: 2px solid rgba(0, 240, 255, 0.3);
    border-top: none;
    border-radius: 0 0 12px 12px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

.autocomplete-suggestion {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-main);
    transition: background 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.autocomplete-suggestion:last-child {
    border-bottom: none;
}

.autocomplete-suggestion:hover {
    background: rgba(0, 240, 255, 0.1);
    color: var(--primary);
}

.warp-advice {
    background: rgba(138, 43, 226, 0.15);
    border: 1px solid var(--accent);
    padding: 1rem 1.25rem;
    border-radius: 12px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    box-shadow: 0 0 15px rgba(138, 43, 226, 0.1);
}

.warp-advice-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 0 5px var(--accent));
}

.route-timeline {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-top: 1rem;
    position: relative;
    padding-left: 1.5rem;
}

.route-timeline::before {
    content: '';
    position: absolute;
    top: 15px;
    bottom: 15px;
    left: 4px;
    width: 2px;
    background: dashed rgba(0, 240, 255, 0.3);
}

.route-step-node {
    position: relative;
    background: var(--bg-card);
    border: var(--glass-border);
    padding: 1rem 1.25rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: var(--glass-shadow);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    transition: transform 0.2s, box-shadow 0.2s;
}

.route-step-node:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px 0 rgba(0, 240, 255, 0.1);
    border-color: rgba(0, 240, 255, 0.3);
}

.route-step-node::before {
    content: '';
    position: absolute;
    left: -23px;
    top: 22px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
}

.route-step-node.start-node::before {
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}

.route-step-node.end-node::before {
    background: var(--secondary);
    box-shadow: 0 0 8px var(--secondary);
}

.route-step-node:last-child {
    margin-bottom: 0;
}

.route-step-title {
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.route-step-connector {
    position: absolute;
    bottom: -2.25rem;
    left: -20px;
    height: 2.25rem;
    display: flex;
    align-items: center;
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: bold;
    pointer-events: none;
}

/* Enhanced Monster Stats and Skills */
.stats-badge-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin: 8px 0;
    text-align: center;
}

.stat-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 4px;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
}

.stat-badge-lbl {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-bottom: 2px;
}

.stat-badge-val {
    font-weight: bold;
    color: var(--text-main);
}

.monster-skills-container {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.monster-skill-badge {
    display: inline-block;
    background: rgba(0, 240, 255, 0.05);
    border: 1px solid rgba(0, 240, 255, 0.15);
    color: var(--primary);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    margin: 2px;
}

/* Lucky Bag Drops Styling */
.lucky-bag-drops-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 180px;
    overflow-y: auto;
    padding-right: 4px;
    background: rgba(0, 0, 0, 0.15);
    padding: 8px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.lucky-bag-drop-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    padding: 4px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.02);
}

.lucky-bag-drop-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.drop-item-name {
    color: var(--text-main);
}

.drop-item-rate {
    font-weight: bold;
    color: #10b981;
}

.drop-item-rate.rare-drop {
    color: #ec4899;
    text-shadow: 0 0 5px rgba(236, 72, 153, 0.5);
}

/* Quest Timeline Layout */
.quest-timeline-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 10px;
    position: relative;
    padding-left: 1.2rem;
}

.quest-timeline-container::before {
    content: '';
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: 4px;
    width: 2px;
    background: dashed rgba(245, 158, 11, 0.3);
}

.quest-step-node {
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px 12px;
}

.quest-step-node::before {
    content: '';
    position: absolute;
    left: -21px;
    top: 14px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;
    box-shadow: 0 0 6px #f59e0b;
}

.quest-step-num {
    font-weight: bold;
    font-size: 0.85rem;
    color: #f59e0b;
    margin-bottom: 2px;
}

.quest-step-desc {
    font-size: 0.9rem;
    color: var(--text-main);
    line-height: 1.4;
}

.quest-step-condition-list {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.quest-step-condition-item {
    font-size: 0.8rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

