/* =====================================================
   ToolKit — Design System
   Cloudflare-inspired Minimal/Clean Aesthetic
   ===================================================== */

/* ── Base Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    background: #f6f6f7;
    color: #16191e;
    margin: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Design Tokens ──────────────────────────────────── */
:root {
    --cf-orange:       #f38020;
    --cf-orange-dark:  #d66b18;
    --cf-orange-light: #fef3e8;
    --cf-dark:         #1d2a35;
    --cf-darker:       #12202d;

    --gray-50:  #f8f9fa;
    --gray-100: #f1f3f4;
    --gray-200: #e8eaed;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --green:  #10b981;
    --red:    #ef4444;
    --blue:   #3b82f6;
    --yellow: #f59e0b;

    --font-sans: 'Vavo', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

    --radius: 6px;
    --radius-lg: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.05);
}

/* ── Custom Scrollbar ───────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ── Toast Notifications ────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    background: var(--cf-dark);
    color: #fff;
    border-radius: var(--radius);
    font-size: .8125rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    transform: translateY(6px);
    opacity: 0;
    transition: all .2s cubic-bezier(.16,1,.3,1);
    min-width: 220px;
    max-width: 340px;
    pointer-events: auto;
    border-left: 3px solid transparent;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { border-left-color: var(--green); }
.toast-error   { border-left-color: var(--red); }
.toast-info    { border-left-color: var(--blue); }

.toast-icon { font-size: .875rem; flex-shrink: 0; }

/* ── Buttons ────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}
.btn:focus-visible { outline: 2px solid var(--cf-orange); outline-offset: 2px; }

.btn-primary {
    background: var(--cf-orange);
    color: #fff;
    border-color: var(--cf-orange);
}
.btn-primary:hover { background: var(--cf-orange-dark); border-color: var(--cf-orange-dark); }

.btn-secondary {
    background: #fff;
    color: var(--gray-700);
    border-color: var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
    border-color: transparent;
    padding: 6px 10px;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-900); }

.btn-danger {
    background: #fff;
    color: var(--red);
    border-color: #fecaca;
}
.btn-danger:hover { background: #fef2f2; }

.btn-sm { padding: 5px 10px; font-size: .8125rem; }
.btn-xs { padding: 3px 8px; font-size: .75rem; }

/* ── Form Elements ──────────────────────────────────── */
.form-textarea {
    width: 100%;
    font-family: var(--font-mono);
    font-size: .8125rem;
    line-height: 1.65;
    padding: 12px 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: #fafafa;
    color: var(--gray-900);
    resize: vertical;
    tab-size: 2;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
.form-textarea:focus {
    border-color: var(--cf-orange);
    box-shadow: 0 0 0 3px rgba(243,128,32,.12);
    background: #fff;
}
.form-textarea::placeholder { color: var(--gray-400); }

.form-select {
    padding: 7px 32px 7px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center;
    font-size: .875rem;
    color: var(--gray-800);
    cursor: pointer;
    appearance: none;
    outline: none;
    transition: border-color .15s;
    font-family: var(--font-sans);
}
.form-select:focus { border-color: var(--cf-orange); box-shadow: 0 0 0 3px rgba(243,128,32,.12); }

/* ── Panel / Card ───────────────────────────────────── */
.panel {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.panel-label {
    font-size: .6875rem;
    font-weight: 600;
    color: var(--gray-500);
    letter-spacing: .07em;
    text-transform: uppercase;
}

.panel-body { padding: 14px; }

/* ── Code / Output ──────────────────────────────────── */
.code-output {
    font-family: var(--font-mono);
    font-size: .8125rem;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-all;
    padding: 12px 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: #fafafa;
    min-height: 120px;
    color: var(--gray-800);
    overflow-x: auto;
}

/* ── JSON Syntax Colors ─────────────────────────────── */
.json-string  { color: #16a34a; }
.json-number  { color: #d97706; }
.json-boolean { color: #2563eb; }
.json-null    { color: #dc2626; }
.json-key     { color: #7c3aed; }

/* ── Diff View ──────────────────────────────────────── */
.diff-view {
    font-family: var(--font-mono);
    font-size: .8125rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    line-height: 1.5;
}
.diff-line {
    display: flex;
    min-height: 22px;
}
.diff-line-num {
    min-width: 44px;
    padding: 2px 8px;
    text-align: right;
    color: var(--gray-400);
    background: var(--gray-50);
    border-right: 1px solid var(--gray-200);
    user-select: none;
    font-size: .75rem;
    line-height: 1.8;
    flex-shrink: 0;
}
.diff-line-text { padding: 2px 12px; flex: 1; white-space: pre-wrap; word-break: break-all; }
.diff-add  { background: #f0fdf4; }
.diff-add  .diff-line-num { background: #dcfce7; color: #166534; }
.diff-add  .diff-line-text { color: #166534; }
.diff-remove { background: #fef2f2; }
.diff-remove .diff-line-num { background: #fee2e2; color: #991b1b; }
.diff-remove .diff-line-text { color: #991b1b; }
.diff-equal .diff-line-text { color: var(--gray-700); }

/* ── CSV Table ──────────────────────────────────────── */
.csv-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}
.csv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8125rem;
}
.csv-table th {
    background: var(--cf-dark);
    color: #fff;
    padding: 9px 14px;
    text-align: left;
    font-weight: 500;
    font-size: .75rem;
    letter-spacing: .04em;
    position: sticky;
    top: 0;
    white-space: nowrap;
}
.csv-table td {
    padding: 7px 14px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-800);
    font-family: var(--font-mono);
    font-size: .8125rem;
    vertical-align: top;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.csv-table tr:last-child td { border-bottom: none; }
.csv-table tr:hover td { background: var(--gray-50); }
.csv-table td.empty { color: var(--gray-400); font-style: italic; }

/* ── Hash Cards ─────────────────────────────────────── */
.hash-card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color .15s;
}
.hash-card:hover { border-color: var(--cf-orange); }
.hash-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-size: .6875rem;
    font-weight: 600;
    color: var(--gray-500);
    letter-spacing: .05em;
    text-transform: uppercase;
}
.hash-card-value {
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: .8125rem;
    color: var(--gray-800);
    word-break: break-all;
    line-height: 1.6;
    min-height: 42px;
    background: #fff;
}
.hash-card-value.empty { color: var(--gray-400); font-style: italic; }

/* ── Status Bar ─────────────────────────────────────── */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    font-size: .75rem;
}
.status-ok   { color: var(--green); font-weight: 500; }
.status-err  { color: var(--red);   font-weight: 500; }
.status-info { color: var(--gray-500); }

/* ── Breadcrumb ─────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .8125rem;
    color: var(--gray-500);
    margin-bottom: 20px;
}
.breadcrumb a { color: var(--gray-500); text-decoration: none; }
.breadcrumb a:hover { color: var(--cf-orange); }
.breadcrumb-sep { color: var(--gray-300); }
.breadcrumb-active { color: var(--gray-900); font-weight: 500; }

/* ── Tool Header ────────────────────────────────────── */
.tool-header { margin-bottom: 20px; }
.tool-header h1 { font-size: 1.375rem; font-weight: 700; color: var(--gray-900); margin: 0 0 4px; }
.tool-header p  { font-size: .9375rem; color: var(--gray-500); margin: 0; }

/* ── Toolbar ────────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}
.toolbar-sep {
    width: 1px;
    height: 20px;
    background: var(--gray-300);
    margin: 0 2px;
}

/* ── Toggle Switch ──────────────────────────────────── */
.toggle-group {
    display: inline-flex;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
}
.toggle-btn {
    padding: 6px 14px;
    font-size: .8125rem;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    border: none;
    background: transparent;
    transition: background .1s, color .1s;
}
.toggle-btn.active {
    background: var(--cf-orange);
    color: #fff;
}
.toggle-btn:hover:not(.active) { background: var(--gray-100); }

/* ── Animations ─────────────────────────────────────── */
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeSlideIn .15s ease-out; }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .6s linear infinite; }

/* ── Utility ────────────────────────────────────────── */
.font-mono { font-family: var(--font-mono); }
.truncate  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    .toolbar { gap: 4px; }
    .btn { padding: 6px 10px; font-size: .8125rem; }
}

/* Direct Link (CDN) button — emerald green to distinguish from orange Via Server */
#vd-direct-btn {
    background: #059669;  /* emerald-600 — communicates "fast / CDN / go" */
}
#vd-direct-btn:hover  { background: #047857; }
#vd-direct-btn:active { background: #065f46; }
#vd-direct-btn:disabled { background: #ccc; }