:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --bg-gradient-start: #ee7752;
    --bg-gradient-end: #23a6d5;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --input-bg: rgba(255, 255, 255, 0.9);
    --input-border: rgba(209, 213, 219, 0.5);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background: linear-gradient(-45deg, #e0c3fc, #8ec5fc, #90f7ec, #fbc2eb);
    background-size: 600% 600%;
    animation: gradient 30s ease-in-out infinite;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--text-color);
}

@keyframes gradient {
    0% {
        background-position: 0% 0%;
    }

    50% {
        background-position: 100% 100%;
    }

    100% {
        background-position: 0% 0%;
    }
}

/* ========== Container Styles ========== */
.container {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    padding: 40px;
    width: 100%;
    max-width: 1000px;
    min-height: 800px;
    transition: transform 0.3s ease;
    margin: auto;
    position: relative;
}

.map-link {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: var(--primary-color);
    z-index: 10;
}

.map-link:hover {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    color: var(--primary-hover);
}

.map-link svg {
    width: 24px;
    height: 24px;
}

/* ========== Footer Styles ========== */
.footer {
    text-align: center;
    padding: 15px;
    margin-top: 0;
}

.footer a {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    text-decoration: none;
    transition: color 0.3s ease;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.footer a:hover {
    color: white;
}

/* ========== Typography ========== */
.title {
    text-align: center;
    color: var(--text-color);
    margin-bottom: 10px;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 40px;
    font-size: 16px;
    font-weight: 400;
}

/* ========== Form Styles ========== */
.form-group {
    margin-bottom: 24px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-color);
    font-weight: 600;
    font-size: 14px;
    margin-left: 4px;
}

.search-container {
    position: relative;
    width: 100%;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    padding-right: 48px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    font-size: 16px;
    color: var(--text-color);
    background: var(--input-bg);
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    line-height: 24px;
    height: 52px;
    box-sizing: border-box;
}

.form-group input:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.05);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
    background: white;
}

.form-group input:disabled {
    background-color: rgba(243, 244, 246, 0.8);
    cursor: not-allowed;
    opacity: 0.7;
}

/* ========== Dropdown Styles (Unified) ========== */
.dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;
    z-index: 9999;
    display: none;
    animation: slideDown 0.2s ease-out;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    padding: 12px;
}

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

.dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 8px 8px 0;
}

.dropdown::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.dropdown::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ========== Dropdown Item Styles (Unified) ========== */
.dropdown-item {
    padding: 10px 8px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 14px;
    color: var(--text-color);
    text-align: center;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
}

.dropdown-item:hover {
    background-color: #f3f4f6;
    color: var(--primary-color);
    border-color: rgba(79, 70, 229, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    font-weight: 500;
}

.dropdown-item.active {
    background-color: var(--primary-color);
    color: white;
}

.dropdown-item mark {
    background: #fef08a;
    padding: 0 2px;
    border-radius: 2px;
    color: inherit;
    font-weight: 600;
}

/* ========== Global Search Item (Extends dropdown-item) ========== */
.global-search-item {
    flex-direction: column;
    min-height: 40px;
}

.global-search-item:hover .region-name {
    color: var(--primary-color);
}

.global-search-item:hover .region-code {
    color: var(--primary-color);
    background: rgba(79, 70, 229, 0.1);
}

.global-search-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    flex: 1;
    min-width: 0;
    width: 100%;
}

.region-name {
    color: var(--text-color);
    font-size: 13px;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-all;
    max-width: 100%;
    text-align: center;
    line-height: 1.3;
}

.region-code {
    color: var(--text-muted);
    font-size: 11px;
    font-family: 'Courier New', monospace;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

.type-icon,
.global-search-path {
    display: none;
}

/* ========== Clear Icon ========== */
.clear-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 300;
    cursor: pointer;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    border-radius: 50%;
    transition: all 0.15s ease;
    z-index: 10;
    display: block !important;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.clear-icon:hover {
    background-color: #fee2e2;
    color: #ef4444;
    transform: translateY(-50%) scale(1.1);
}

.clear-icon:active {
    transform: translateY(-50%) scale(0.95);
}

.clear-icon:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ========== Result Styles ========== */
#result {
    margin-top: 40px;
}

.empty-message {
    text-align: center;
    color: var(--text-muted);
    padding: 30px;
    font-style: italic;
    background: rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-md);
    border: 1px dashed var(--glass-border);
}

.result-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f3f4f6;
}

.result-item {
    display: flex;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #f3f4f6;
}

.result-item:last-child {
    border-bottom: none;
}

.result-label {
    width: 100px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
}

.result-value {
    color: var(--text-color);
    font-weight: 600;
    flex: 1;
    cursor: pointer;
    transition: color 0.2s;
}

.result-value:hover {
    color: var(--text-color);
    /* 防止父级hover影响 */
}

.result-value>span:not(.result-code) {
    cursor: pointer;
    transition: color 0.2s;
}

.result-value>span:not(.result-code):hover {
    color: var(--primary-color);
}



.result-code {
    font-family: monospace;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    color: var(--text-muted);
    transition: all 0.2s;
}

.result-code:hover {
    color: var(--primary-color);
}

/* ========== Loading ========== */
.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
}

.loading::after {
    content: '';
    animation: dots 1.5s infinite;
}

@keyframes dots {

    0%,
    20% {
        content: '.';
    }

    40% {
        content: '..';
    }

    60%,
    100% {
        content: '...';
    }
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .container {
        padding: 24px;
        margin-bottom: 60px;
    }

    .title {
        font-size: 24px;
    }
}

@media (max-width: 480px) {

    .dropdown-item,
    .global-search-item {
        padding: 10px 12px !important;
    }

    .region-name {
        font-size: 13px;
    }

    .region-code {
        font-size: 11px;
    }
}

/* ========== Toast Styles ========== */
#toast-container {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    pointer-events: none;
}

.toast {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-error {
    background: rgba(220, 38, 38, 0.8);
}