@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.8);
    --bg-card-hover: rgba(31, 41, 55, 0.9);
    --bg-input: rgba(17, 24, 39, 0.6);
    --border-color: rgba(99, 102, 241, 0.2);
    --border-active: rgba(99, 102, 241, 0.6);
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
    --accent-glow: 0 0 20px rgba(99, 102, 241, 0.3);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ===== Background Particles ===== */
.bg-gradient {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.06) 0%, transparent 50%),
                radial-gradient(ellipse at 50% 80%, rgba(168,85,247,0.04) 0%, transparent 50%);
    z-index: 0; pointer-events: none;
}

/* ===== Header & Navigation ===== */
.header {
    position: sticky; top: 0; z-index: 100;
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.header-inner {
    max-width: 1280px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; height: 64px;
}

.logo {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; color: var(--text-primary);
    font-weight: 800; font-size: 1.2rem;
}

.logo-icon {
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    background: var(--accent-gradient);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; color: #fff; box-shadow: var(--accent-glow);
}

.nav-tabs {
    display: flex; gap: 4px; list-style: none;
    background: rgba(17, 24, 39, 0.6);
    padding: 4px; border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.nav-tab {
    padding: 8px 18px; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 0.85rem; font-weight: 500;
    color: var(--text-secondary); transition: var(--transition);
    white-space: nowrap; user-select: none;
    display: flex; align-items: center; gap: 6px;
}

.nav-tab:hover { color: var(--text-primary); background: rgba(99,102,241,0.1); }

.nav-tab.active {
    color: #fff; background: var(--accent-gradient);
    box-shadow: var(--accent-glow);
}

.nav-tab .tab-icon { font-size: 1rem; }

.lang-select {
    background: var(--bg-input); border: 1px solid var(--border-color);
    color: var(--text-primary); padding: 6px 10px; border-radius: var(--radius-sm);
    font-size: 0.8rem; cursor: pointer; font-family: inherit;
}
.lang-select option { background: var(--bg-secondary); }

/* ===== Main Content ===== */
.main-content {
    max-width: 1280px; margin: 0 auto;
    padding: 32px 24px; position: relative; z-index: 1;
}

.tool-section { display: none; animation: fadeUp 0.4s ease; }
.tool-section.active { display: block; }

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

/* ===== Tool Header ===== */
.tool-header { margin-bottom: 32px; text-align: center; }
.tool-header h1 {
    font-size: 2rem; font-weight: 800;
    background: var(--accent-gradient); -webkit-background-clip: text;
    -webkit-text-fill-color: transparent; background-clip: text;
    margin-bottom: 8px;
}
.tool-header p { color: var(--text-secondary); font-size: 0.95rem; max-width: 600px; margin: 0 auto; }

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}
.card:hover { border-color: var(--border-active); box-shadow: var(--shadow-lg), var(--accent-glow); }
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 20px; display: flex; align-items: center; gap: 8px; }

/* ===== Form Elements ===== */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

.form-input, .form-select, .form-textarea {
    width: 100%; padding: 12px 16px;
    background: var(--bg-input); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); color: var(--text-primary);
    font-size: 0.9rem; font-family: inherit; transition: var(--transition);
    outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 120px; line-height: 1.8; }
.form-select { cursor: pointer; }
.form-select option { background: var(--bg-secondary); }

.input-group { position: relative; }
.input-group .input-icon {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 1rem; pointer-events: none;
}
.input-group .form-input { padding-left: 42px; }

/* Autocomplete */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); max-height: 220px; overflow-y: auto;
    display: none; box-shadow: var(--shadow-lg);
}
.autocomplete-list.show { display: block; }
.autocomplete-item {
    padding: 10px 16px; cursor: pointer; font-size: 0.88rem;
    transition: background 0.15s; border-bottom: 1px solid rgba(255,255,255,0.03);
}
.autocomplete-item:hover, .autocomplete-item.highlighted { background: rgba(99,102,241,0.15); }
.autocomplete-item .item-code { color: var(--text-muted); font-size: 0.75rem; margin-left: 6px; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 28px; border: none; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 600; font-family: inherit;
    cursor: pointer; transition: var(--transition); user-select: none;
}
.btn-primary {
    background: var(--accent-gradient); color: #fff;
    box-shadow: var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 25px rgba(99,102,241,0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-sm { padding: 8px 16px; font-size: 0.82rem; }
.btn-outline {
    background: transparent; color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
}
.btn-outline:hover { background: rgba(99,102,241,0.1); }

.btn-loading::after {
    content: ''; width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff; border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Gauge / Score Display ===== */
.scores-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 20px; margin: 24px 0; }

.score-card {
    background: rgba(17, 24, 39, 0.5); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); padding: 20px; text-align: center;
    transition: var(--transition);
}
.score-card:hover { border-color: var(--border-active); transform: translateY(-2px); }

.gauge-wrap { position: relative; width: 120px; height: 120px; margin: 0 auto 12px; }
.gauge-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-bg { fill: none; stroke: rgba(255,255,255,0.05); stroke-width: 8; }
.gauge-fill { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.5s; }
.gauge-value {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    font-size: 1.8rem; font-weight: 800;
}
.gauge-label { font-size: 0.75rem; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; }

/* ===== Info Grid ===== */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 24px 0; }
.info-item {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 18px; background: rgba(17,24,39,0.4);
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
}
.info-icon { font-size: 1.4rem; width: 40px; text-align: center; }
.info-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.info-value { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); }

/* ===== Status Badges ===== */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
}
.badge-success { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-info { background: rgba(59,130,246,0.15); color: var(--info); }

/* ===== Results Table ===== */
.table-wrap { overflow-x: auto; margin: 20px 0; border-radius: var(--radius-md); border: 1px solid var(--border-color); }
.results-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.results-table thead { background: rgba(99,102,241,0.08); }
.results-table th {
    padding: 12px 16px; text-align: left; font-weight: 600; font-size: 0.78rem;
    text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color); white-space: nowrap;
}
.results-table td { padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.03); vertical-align: middle; }
.results-table tbody tr { transition: background 0.15s; }
.results-table tbody tr:hover { background: rgba(99,102,241,0.05); }
.results-table .rank-cell { font-weight: 700; font-size: 1.1rem; }
.rank-top3 { color: var(--success); }
.rank-top10 { color: var(--info); }
.rank-top20 { color: var(--warning); }
.rank-low { color: var(--danger); }
.rank-notfound { color: var(--text-muted); font-style: italic; }

.url-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.url-cell a { color: var(--accent-primary); text-decoration: none; }
.url-cell a:hover { text-decoration: underline; }

/* ===== Progress / Skeleton ===== */
.progress-bar { width: 100%; height: 4px; background: rgba(255,255,255,0.05); border-radius: 2px; overflow: hidden; margin: 16px 0; }
.progress-fill { height: 100%; background: var(--accent-gradient); border-radius: 2px; transition: width 0.3s; }

.skeleton { background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.loading-overlay {
    display: none; align-items: center; justify-content: center; flex-direction: column; gap: 16px;
    padding: 40px; text-align: center;
}
.loading-overlay.show { display: flex; }
.loading-spinner {
    width: 48px; height: 48px; border: 3px solid rgba(99,102,241,0.2);
    border-top-color: var(--accent-primary); border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loading-text { color: var(--text-secondary); font-size: 0.9rem; }

/* ===== Alert Messages ===== */
.alert { padding: 14px 18px; border-radius: var(--radius-sm); margin: 16px 0; font-size: 0.88rem; display: flex; align-items: flex-start; gap: 10px; }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); color: #6ee7b7; }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); color: #fcd34d; }
.alert-info { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.3); color: #93c5fd; }

/* ===== Check Items ===== */
.check-list { list-style: none; }
.check-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 0.88rem; border-bottom: 1px solid rgba(255,255,255,0.03); }
.check-icon { font-size: 1.1rem; width: 24px; text-align: center; }
.check-pass { color: var(--success); }
.check-fail { color: var(--danger); }
.check-warn { color: var(--warning); }

/* ===== Export Button ===== */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0; flex-wrap: wrap; }

/* ===== Footer ===== */
.footer {
    text-align: center; padding: 32px 24px; margin-top: 60px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted); font-size: 0.82rem;
}
.footer a { color: var(--accent-primary); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header-inner { padding: 0 16px; height: 56px; }
    .nav-tabs { display: none; position: absolute; top: 56px; left: 0; right: 0; flex-direction: column; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 0; padding: 8px; z-index: 99; }
    .nav-tabs.show { display: flex; }
    .mobile-toggle { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; background: none; border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 1.3rem; cursor: pointer; }
    .main-content { padding: 20px 16px; }
    .tool-header h1 { font-size: 1.5rem; }
    .scores-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .card { padding: 20px; }
    .info-grid { grid-template-columns: 1fr; }
    .results-table { font-size: 0.78rem; }
    .results-table th, .results-table td { padding: 8px 10px; }
    .logo span { display: none; }
}

@media (min-width: 769px) {
    .mobile-toggle { display: none; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,0.5); }
