/* ===================================
   DESIGN SYSTEM — 終末地風格暗色主題
   =================================== */

:root {
    /* Base Variables (Constant) */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Light Theme (Default) */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-glass: rgba(255, 255, 255, 0.8);

    --accent-blue: #0284c7;
    --accent-blue-dim: rgba(2, 132, 199, 0.08);
    --accent-amber: #d97706;
    --accent-emerald: #059669;
    --accent-purple: #7c3aed;
    --accent-purple-dim: rgba(124, 58, 237, 0.05);
    --accent-emerald-dim: rgba(5, 150, 105, 0.05);
    --accent-red: #e11d48;
    --accent-pink: #db2777;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-accent: var(--accent-blue);

    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-btn: 0 10px 15px -3px rgba(2, 132, 199, 0.2);
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --bg-glass: rgba(15, 23, 42, 0.7);

    --accent-blue: #38bdf8;
    --accent-blue-dim: rgba(56, 189, 248, 0.1);
    --accent-amber: #fbbf24;
    --accent-emerald: #34d399;
    --accent-purple: #a78bfa;
    --accent-purple-dim: rgba(167, 139, 250, 0.05);
    --accent-emerald-dim: rgba(52, 211, 153, 0.05);
    --accent-red: #fb7185;
    --accent-pink: #ec4899;

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-accent: var(--accent-blue);

    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(56, 189, 248, 0.3);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.6);
    --shadow-btn: 0 10px 15px -3px rgba(56, 189, 248, 0.2);
}

/* ===================================
   RESET & BASE
   =================================== */

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

body {
    font-family: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition-normal), color var(--transition-normal), border-color var(--transition-normal);
}

/* ===================================
   ANIMATED BACKGROUND
   =================================== */

.bg-particles {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.bg-particles::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(ellipse at 20% 50%, var(--accent-blue-dim) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, var(--accent-purple-dim) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, var(--accent-emerald-dim) 0%, transparent 50%);
    animation: bgDrift 30s ease-in-out infinite alternate;
}

@keyframes bgDrift {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    100% {
        transform: translate(-2%, -1%) rotate(1deg);
    }
}

.particle {
    position: absolute;
    width: 1px;
    height: 1px;
    background: var(--accent-blue);
    border-radius: 50%;
    opacity: 0;
    animation: particleFloat 12s ease-in-out infinite;
}

@keyframes particleFloat {

    0%,
    100% {
        opacity: 0;
        transform: translateY(100vh) scale(0);
    }

    20% {
        opacity: 0.3;
    }

    80% {
        opacity: 0.3;
    }

    50% {
        transform: translateY(-10vh) scale(1.5);
    }
}

/* ===================================
   HEADER
   =================================== */

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
    background: var(--bg-glass);
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
}

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

.logo-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    color: var(--accent-blue);
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {

    0%,
    100% {
        filter: drop-shadow(0 0 4px var(--accent-blue-dim));
    }

    50% {
        filter: drop-shadow(0 0 12px var(--accent-blue));
    }
}

.header h1 {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.subtitle {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    color: var(--text-muted);
    letter-spacing: 0.4em;
    margin-top: 4px;
    opacity: 0.8;
}

.header-stats {
    display: flex;
    gap: 12px;
}

.stat-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    min-width: 90px;
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.stat-value {
    font-family: 'Orbitron', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-blue);
}

/* ===================================
   MAIN CONTAINER
   =================================== */

.main-container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

/* ===================================
   SECTIONS
   =================================== */

.section {
    margin-bottom: 32px;
}

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

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-icon {
    font-size: 1.2em;
}

/* ===================================
   BUTTONS
   =================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.1));
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn:hover::after {
    opacity: 1;
}

.btn-primary {
    background: var(--accent-primary);
    color: #0f172a;
    font-weight: 600;
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: var(--shadow-btn);
}

.btn-analyze {
    background: var(--text-primary);
    color: var(--bg-primary);
    font-size: 1rem;
    font-weight: 700;
    padding: 12px 32px;
    border-radius: var(--radius-md);
}

.btn-analyze:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    filter: brightness(0.95);
}

.btn-glow {
    /* Subtle pulsing intensity instead of full color wash */
    animation: btnSubtlePulse 3s ease-in-out infinite;
}

@keyframes btnSubtlePulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.9;
    }
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

.btn-icon {
    font-size: 1.2em;
    font-weight: 700;
}

/* ===================================
   THEME TOGGLE
   =================================== */

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-normal);
    margin-left: 12px;
}

.theme-toggle:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    transform: rotate(15deg);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

[data-theme="dark"] .sun-icon {
    display: block;
}

[data-theme="dark"] .moon-icon {
    display: none;
}

.sun-icon {
    display: none;
}

.moon-icon {
    display: block;
}

/* ===================================
   WEAPON CARDS
   =================================== */

.weapons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.weapon-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
}

.weapon-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
}

.weapon-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.weapon-name-input {
    flex: 1;
    background: var(--bg-card-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    color: var(--text-primary);
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    transition: all var(--transition-fast);
    outline: none;
    margin-right: 12px;
}

.weapon-name-input:focus {
    background: var(--bg-secondary);
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px var(--accent-blue-dim);
}

.weapon-name-input::placeholder {
    color: var(--text-muted);
}

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

.affix-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.affix-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.badge-base {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
}

.badge-extra {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
}

.badge-skill {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-purple);
}

.affix-select {
    width: 100%;
    background: var(--bg-card-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: all var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

.affix-select:focus {
    background: var(--bg-secondary);
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px var(--accent-blue-dim);
}

.affix-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ===================================
   EMPTY STATE
   =================================== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
    animation: emptyBounce 2s ease-in-out infinite;
}

@keyframes emptyBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.empty-state p {
    font-size: 0.95rem;
}

/* ===================================
   ANALYZE BAR
   =================================== */

.analyze-bar {
    text-align: center;
    padding: 20px 0 40px;
}

/* ===================================
   RESULT PANELS
   =================================== */

.results-section {
    animation: resultsFadeIn 0.6s ease backwards;
}

@keyframes resultsFadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
}

.result-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
}

.result-panel:hover {
    border-color: rgba(148, 163, 184, 0.2);
}

.result-panel h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.panel-content {
    line-height: 1.8;
}

/* Location tags */
.location-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    border-radius: 100px;
    font-size: 0.82rem;
    font-weight: 600;
    margin: 3px 4px;
    transition: transform var(--transition-fast);
}

.location-tag:hover {
    transform: scale(1.05);
}

.loc-hub {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.loc-originium {
    background: rgba(0, 194, 255, 0.12);
    color: #67e8f9;
    border: 1px solid rgba(0, 194, 255, 0.25);
}

.loc-ore {
    background: rgba(16, 185, 129, 0.12);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.loc-power {
    background: rgba(139, 92, 246, 0.12);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.25);
}

/* Affix items in results */
.affix-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    transition: background var(--transition-fast);
}

.affix-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.affix-item-name {
    font-weight: 500;
}

.affix-item-locations {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* Weapon result group */
.weapon-result-group {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.weapon-result-group:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.weapon-result-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-cyan);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.weapon-result-title::before {
    content: '⚔';
    font-size: 0.9em;
}

/* CP value table */
.cp-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 12px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.cp-table th,
.cp-table td {
    padding: 12px 16px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.cp-table th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.cp-table td {
    font-size: 0.9rem;
}

.cp-table tr:last-child td {
    border-bottom: none;
}

.cp-table .highlight {
    color: var(--accent-amber);
    font-weight: 700;
}

.cp-table .recommend {
    background: rgba(16, 185, 129, 0.08);
}

/* Route cards */
.route-step {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.route-step:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(148, 163, 184, 0.2);
}

.route-step-num {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    color: #fff;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    font-size: 0.9rem;
}

.route-step-content {
    flex: 1;
}

.route-step-location {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 4px;
}

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

.route-step-weapons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.weapon-chip {
    padding: 2px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(0, 194, 255, 0.1);
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 194, 255, 0.2);
}

/* Co-farm highlight */
.cofarm-group {
    padding: 16px;
    margin-bottom: 12px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), rgba(0, 194, 255, 0.05));
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.cofarm-title {
    font-weight: 700;
    color: var(--accent-emerald);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cofarm-weapons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.cofarm-affixes {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.no-cofarm {
    color: var(--text-muted);
    font-style: italic;
    padding: 20px;
    text-align: center;
}

/* ===================================
   FOOTER
   =================================== */

.footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 32px 24px;
    color: var(--text-muted);
    font-size: 0.78rem;
    border-top: 1px solid var(--border-color);
}

/* ===================================
   RESPONSIVE
   =================================== */

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 12px;
    }

    .header-stats {
        width: 100%;
        justify-content: center;
    }

    .section-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .weapons-grid {
        grid-template-columns: 1fr;
    }

    .weapon-card {
        padding: 18px;
    }

    .cp-table th,
    .cp-table td {
        padding: 8px 10px;
        font-size: 0.78rem;
    }

    .btn-analyze {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.2rem;
    }

    .main-container {
        padding: 20px 16px 48px;
    }
}

/* ===================================
   SCROLLBAR
   =================================== */

::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.25);
}

/* ===================================
   SELECTION
   =================================== */

::selection {
    background: rgba(0, 194, 255, 0.3);
    color: #fff;
}