/* ============================================================
   Helper Tool Web App — Dark Premium Theme
   Domain: tool.chichvl.net
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg: #0a0e14;
    --bg2: #131920;
    --bg3: #1a2332;
    --bg4: #222d3d;
    --bg-input: #0d1117;
    --fg: #c9d1d9;
    --fg-dim: #6b7f8e;
    --fg-bright: #f0f4f8;
    --accent: #00b4d8;
    --accent2: #0096b7;
    --green: #2ec4b6;
    --red: #e63946;
    --orange: #fb8500;
    --purple: #a78bfa;
    --pink: #ff6b9d;
    --border: #21303f;
    --border2: #2a3a4a;
    --shadow: rgba(0,0,0,0.4);
    --radius: 10px;
    --radius-sm: 6px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--fg);
    min-height: 100vh;
    line-height: 1.5;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Layout ── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: 240px;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand .logo {
    font-size: 24px;
}

.sidebar-brand h1 {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.3px;
}

.sidebar-brand small {
    font-size: 10px;
    color: var(--fg-dim);
    display: block;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--fg-dim);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    gap: 10px;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--bg3);
    color: var(--fg);
}

.nav-item.active {
    background: var(--bg3);
    color: var(--accent);
    border-left-color: var(--accent);
}

.nav-item .icon { font-size: 16px; width: 22px; text-align: center; }

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--fg-dim);
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 2s infinite;
}
.status-dot.online { background: var(--green); }
.status-dot.offline { background: var(--red); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Main Content ── */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 24px;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--fg-bright);
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-header p {
    color: var(--fg-dim);
    font-size: 13px;
    margin-top: 4px;
}

/* ── Cards ── */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border2);
    box-shadow: 0 4px 20px var(--shadow);
}

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

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--fg-bright);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Stat Cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.stat-card.accent::before { background: var(--accent); }
.stat-card.green::before { background: var(--green); }
.stat-card.orange::before { background: var(--orange); }
.stat-card.purple::before { background: var(--purple); }

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--shadow);
}

.stat-value {
    font-size: 32px;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 4px;
}

.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.orange .stat-value { color: var(--orange); }
.stat-card.purple .stat-value { color: var(--purple); }

.stat-label {
    font-size: 12px;
    color: var(--fg-dim);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Form Elements ── */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--fg-dim);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

textarea, input[type="text"], input[type="password"], input[type="number"], select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--fg);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    transition: var(--transition);
    outline: none;
}

textarea:focus, input[type="text"]:focus, input[type="password"]:focus,
input[type="number"]:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,180,216,0.15);
}

textarea { resize: vertical; min-height: 80px; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px var(--shadow); }
.btn:active { transform: translateY(0); }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent2); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #25a89c; }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: #c5303c; }
.btn-orange { background: var(--orange); color: #fff; }
.btn-orange:hover { background: #da7300; }
.btn-ghost {
    background: var(--bg3);
    color: var(--fg);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg4); border-color: var(--border2); }

.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }

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

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    background: var(--bg3);
    color: var(--fg-dim);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}

tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

tbody tr:hover { background: var(--bg3); }
tbody tr:last-child td { border-bottom: none; }

.tag-new { color: var(--green); font-weight: 600; }
.tag-dup { color: var(--orange); font-weight: 600; }
.tag-err { color: var(--red); font-weight: 600; }
.tag-skip { color: var(--fg-dim); }

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
}
.badge-green { background: rgba(46,196,182,0.15); color: var(--green); }
.badge-red { background: rgba(230,57,70,0.15); color: var(--red); }
.badge-orange { background: rgba(251,133,0,0.15); color: var(--orange); }
.badge-accent { background: rgba(0,180,216,0.15); color: var(--accent); }

/* ── Progress ── */
.progress-bar {
    height: 4px;
    background: var(--bg3);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--green));
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ── Log Box ── */
.log-box {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
    color: var(--fg-dim);
}

.log-entry { margin-bottom: 2px; }
.log-entry .time { color: var(--fg-dim); margin-right: 6px; }
.log-entry.ok .msg { color: var(--green); }
.log-entry.err .msg { color: var(--red); }
.log-entry.warn .msg { color: var(--orange); }
.log-entry.info .msg { color: var(--accent); }

/* ── Settings Grid ── */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 16px;
}

.settings-section {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.settings-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Instance List ── */
.instance-list {
    list-style: none;
}

.instance-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 13px;
}

.instance-item .url { color: var(--accent); font-weight: 500; }

/* ── Loading ── */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10,14,20,0.7);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Toast ── */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    z-index: 9999;
    animation: slideIn 0.3s ease;
    box-shadow: 0 8px 30px var(--shadow);
}

.toast.ok { background: var(--green); color: #fff; }
.toast.err { background: var(--red); color: #fff; }
.toast.warn { background: var(--orange); color: #fff; }

@keyframes slideIn {
    from { transform: translateX(100px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── Login Page ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a0e14 0%, #131920 50%, #1a2332 100%);
}

.login-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px var(--shadow);
}

.login-card h1 {
    font-size: 24px;
    font-weight: 800;
    color: var(--accent);
    text-align: center;
    margin-bottom: 6px;
}

.login-card .subtitle {
    text-align: center;
    color: var(--fg-dim);
    font-size: 13px;
    margin-bottom: 28px;
}

.login-card .btn { width: 100%; justify-content: center; margin-top: 8px; }

.error-msg {
    color: var(--red);
    font-size: 12px;
    text-align: center;
    margin-top: 12px;
    padding: 8px;
    background: rgba(230,57,70,0.1);
    border-radius: var(--radius-sm);
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--fg-dim);
}

.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 14px; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar .nav-text, .sidebar-brand h1, .sidebar-brand small,
    .sidebar-footer span { display: none; }
    .sidebar-brand { justify-content: center; padding: 16px; }
    .main-content { margin-left: 60px; padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .settings-grid { grid-template-columns: 1fr; }
}
