/* ========== CSS Variables ========== */
:root {
    --bg: #ffffff;
    --nav-bg: rgba(255, 255, 255, 0.85);
    --bg-card: #f8fafc;
    --bg-input: #f1f5f9;
    --bg-hover: #e2e8f0;
    --border: #e2e8f0;
    --border-focus: #6366f1;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: rgba(99, 102, 241, 0.08);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.08);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.08);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.08);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', 'Consolas', monospace;
}

[data-theme="dark"] {
    --bg: #0f1117;
    --nav-bg: rgba(15, 17, 23, 0.85);
    --bg-card: #1a1f2e;
    --bg-input: #242938;
    --bg-hover: #2d3348;
    --border: #2d3348;
    --border-focus: #818cf8;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #818cf8;
    --accent-hover: #6366f1;
    --accent-light: rgba(129, 140, 248, 0.1);
    --success-bg: rgba(16, 185, 129, 0.12);
    --error-bg: rgba(239, 68, 68, 0.12);
    --warning-bg: rgba(245, 158, 11, 0.12);
    --shadow: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.3);
}

/* ========== Reset ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background 0.3s, color 0.3s;
}

/* ========== Navbar ========== */
.navbar {
    position: sticky; top: 0; z-index: 100;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background 0.3s, border-color 0.3s;
}
.nav-inner {
    max-width: 1200px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; height: 60px;
}
.nav-logo {
    display: flex; align-items: center; gap: 8px;
    text-decoration: none; color: var(--text);
    font-weight: 700; font-size: 18px;
}
.logo-icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: white;
}
.nav-links { display: flex; gap: 4px; }
.nav-link {
    padding: 8px 14px; border-radius: var(--radius-sm);
    text-decoration: none; color: var(--text-secondary);
    font-size: 14px; font-weight: 500;
    transition: all 0.2s;
}
.nav-link:hover { color: var(--text); background: var(--bg-hover); }
.nav-link.active { color: var(--accent); background: var(--accent-light); }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.theme-toggle {
    width: 38px; height: 38px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-card);
    cursor: pointer; font-size: 16px; display: flex;
    align-items: center; justify-content: center;
    transition: all 0.2s;
}
.theme-toggle:hover { border-color: var(--accent); background: var(--accent-light); }
.mobile-menu-btn {
    display: none; width: 38px; height: 38px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-card);
    cursor: pointer; font-size: 18px; color: var(--text);
}

/* ========== Main Content ========== */
.main-content {
    flex: 1; max-width: 1200px; width: 100%;
    margin: 0 auto; padding: 32px 24px;
}

/* ========== Home Page ========== */
.hero { text-align: center; margin-bottom: 48px; }
.hero h1 {
    font-size: 40px; font-weight: 800;
    letter-spacing: -0.03em; margin-bottom: 12px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6, #ec4899);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero p { font-size: 16px; color: var(--text-secondary); max-width: 500px; margin: 0 auto; }

.tools-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}
.tool-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 28px;
    cursor: pointer; text-decoration: none; color: var(--text);
    transition: all 0.3s; box-shadow: var(--shadow);
}
.tool-card:hover {
    transform: translateY(-4px); box-shadow: var(--shadow-lg);
    border-color: var(--accent);
}
.tool-card-icon {
    width: 52px; height: 52px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; margin-bottom: 16px;
}
.tool-card h3 { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.tool-card p { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* ========== Tool Page Layout ========== */
.tool-page { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.tool-header { margin-bottom: 24px; }
.tool-header h1 { font-size: 28px; font-weight: 800; margin-bottom: 6px; }
.tool-header p { color: var(--text-secondary); font-size: 14px; }

/* Tabs */
.tab-bar {
    display: flex; gap: 4px; margin-bottom: 24px;
    background: var(--bg-input); padding: 4px; border-radius: var(--radius-sm);
    width: fit-content;
}
.tab-btn {
    padding: 8px 20px; border: none; border-radius: 6px;
    background: transparent; color: var(--text-secondary);
    font-family: var(--font); font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: var(--bg-card); color: var(--accent); box-shadow: var(--shadow); }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.2s ease; }

/* ========== Form Elements ========== */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
    box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-title {
    font-size: 15px; font-weight: 700; margin-bottom: 16px;
    display: flex; align-items: center; gap: 8px;
}

.form-row { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 120px; }
.form-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

input[type="text"], input[type="number"], select, textarea {
    padding: 10px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-input);
    color: var(--text); font-family: var(--font); font-size: 14px;
    outline: none; transition: all 0.2s; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
textarea { resize: vertical; font-family: var(--mono); font-size: 12px; line-height: 1.6; min-height: 120px; }
select { cursor: pointer; }

.btn {
    padding: 10px 20px; border: none; border-radius: var(--radius-sm);
    font-family: var(--font); font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-secondary { background: var(--bg-input); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-success { background: var(--success); color: white; }
.btn-sm { padding: 6px 14px; font-size: 12px; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ========== Output ========== */
.output-box {
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 16px;
    font-family: var(--mono); font-size: 12px; line-height: 1.7;
    white-space: pre-wrap; word-break: break-all;
    max-height: 400px; overflow-y: auto; color: var(--text);
    min-height: 60px;
}

/* Stats bar */
.stats-bar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-chip {
    padding: 8px 16px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px;
}
.stat-chip.total { background: var(--bg-input); color: var(--text); }
.stat-chip.success { background: var(--success-bg); color: var(--success); }
.stat-chip.error { background: var(--error-bg); color: var(--error); }
.stat-chip.warning { background: var(--warning-bg); color: var(--warning); }

/* Result table */
.result-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.result-table th {
    text-align: left; padding: 10px 12px; font-weight: 600; font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}
.result-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.result-table tr:hover td { background: var(--accent-light); }

/* Badges */
.badge {
    padding: 3px 10px; border-radius: 20px; font-size: 11px;
    font-weight: 600; display: inline-block;
}
.badge-credit { background: var(--accent-light); color: var(--accent); }
.badge-debit { background: var(--success-bg); color: var(--success); }
.badge-prepaid { background: var(--warning-bg); color: var(--warning); }
.badge-valid { background: var(--success-bg); color: var(--success); }
.badge-invalid { background: var(--error-bg); color: var(--error); }
.src-badge { padding: 1px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; vertical-align: middle; margin-left: 6px; display: inline-block; }
.src-badge.local { background: var(--accent-light); color: var(--accent); }
.src-badge.stripe { background: rgba(99,91,255,0.1); color: #635bff; }

/* Copy feedback */
.copy-toast {
    position: fixed; bottom: 24px; right: 24px; padding: 12px 20px;
    background: var(--success); color: white; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600; z-index: 1000;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 1.5s forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(20px); } }

/* ========== Promo Banner ========== */
.promo-banner {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 40%, #0f3460 70%, #533483 100%);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: relative;
    overflow: hidden;
}
.promo-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(99,102,241,0.15) 0%, transparent 60%);
    animation: promoPulse 4s ease-in-out infinite;
}
@keyframes promoPulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 1; }
}
.promo-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: relative;
    z-index: 1;
}
.promo-text {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.promo-badge {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    animation: badgeGlow 2s ease-in-out infinite;
}
@keyframes badgeGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(245,158,11,0.4); }
    50% { box-shadow: 0 0 20px rgba(245,158,11,0.8); }
}
.promo-desc {
    color: rgba(255,255,255,0.85);
    font-size: 13px;
    font-weight: 500;
}
.promo-btns {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.promo-btn {
    padding: 7px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s;
}
.promo-btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
}
.promo-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(99,102,241,0.5);
}
.promo-btn-tg {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}
.promo-btn-tg:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

/* ========== Footer ========== */
.footer {
    border-top: 1px solid var(--border); padding: 20px 24px;
    text-align: center; transition: border-color 0.3s;
}
.footer-inner { max-width: 1200px; margin: 0 auto; }
.footer p { font-size: 13px; color: var(--text-muted); }

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .nav-links { display: none; position: absolute; top: 60px; left: 0; right: 0;
        background: var(--bg); border-bottom: 1px solid var(--border);
        flex-direction: column; padding: 8px; }
    .nav-links.open { display: flex; }
    .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }
    .hero h1 { font-size: 28px; }
    .tools-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    .tab-bar { width: 100%; overflow-x: auto; }
    .promo-inner { flex-direction: column; text-align: center; padding: 10px 16px; }
    .promo-text { justify-content: center; }
    .promo-btns { justify-content: center; }
    .promo-desc { font-size: 11px; }
}
