/* ── Infoway Market Data Widget v1.0.1 ──────────────────── */

/* ── Reset ───────────────────────────────────────────────── */
.infoway-widget *,
.infoway-widget *::before,
.infoway-widget *::after {
    box-sizing: border-box !important;
}

.infoway-widget input[type="text"],
.infoway-widget input[type="password"],
.infoway-widget input[type="text"]:focus,
.infoway-widget input[type="password"]:focus {
    -webkit-appearance: none !important;
    appearance: none !important;
    background: #fff !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    color: #1a1a2e !important;
    font-family: inherit !important;
    font-size: 13px !important;
    height: 36px !important;
    line-height: normal !important;
    margin: 0 !important;
    outline: none !important;
    padding: 8px 12px !important;
    width: 100% !important;
}

.infoway-widget select,
.infoway-widget select:focus {
    background: #fff !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    color: #1a1a2e !important;
    font-family: inherit !important;
    font-size: 13px !important;
    height: 36px !important;
    line-height: normal !important;
    margin: 0 !important;
    outline: none !important;
    padding: 8px 12px !important;
    width: 100% !important;
}

.infoway-widget img {
    border: none !important;
    max-width: none !important;
    vertical-align: middle !important;
}

.infoway-widget p { margin: 0 !important; }

.infoway-widget a,
.infoway-widget a:hover,
.infoway-widget a:visited { text-decoration: none !important; }

/* ── Widget base ─────────────────────────────────────────── */

.infoway-widget {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: #1a1a2e;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    max-width: 860px;
    margin: 0 auto 2rem;
    box-shadow: 0 2px 12px rgba(0,0,0,.07);
}

/* ── Header ──────────────────────────────────────────────── */

.ifw-header { padding: 18px 24px 0; }

.ifw-logo {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a2e;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ifw-logo-icon {
    background: #1a1a2e !important;
    color: #fff !important;
    border-radius: 4px !important;
    padding: 1px 5px !important;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -.5px;
}

.ifw-subtitle {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.5;
    margin: 4px 0 0 !important;
}

/* ── Tabs ────────────────────────────────────────────────── */

.ifw-tabs {
    display: flex;
    padding: 14px 24px 0;
    border-bottom: 1px solid #e5e7eb;
}

/* (0,2,0) — beats reset (0,1,1) */
.infoway-widget .ifw-tab-btn {
    background: none !important;
    border: none !important;
    border-bottom: 2px solid transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    color: #6b7280 !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 1 !important;
    margin-bottom: -1px !important;
    outline: none !important;
    padding: 8px 16px !important;
    text-transform: none !important;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
    width: auto !important;
}

.infoway-widget .ifw-tab-btn:hover {
    color: #1a1a2e !important;
    background: none !important;
}

.infoway-widget .ifw-tab-btn.active {
    border-bottom-color: #2563eb !important;
    color: #1a1a2e !important;
    font-weight: 600 !important;
}

/* ── Tab Panels ──────────────────────────────────────────── */

.ifw-tab-pane { display: none; padding: 20px 24px 24px; }
.ifw-tab-pane.active { display: block; }

/* ── Form Grid ───────────────────────────────────────────── */

.ifw-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 20px;
}

.ifw-span2 { grid-column: 1 / -1; }

.ifw-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ifw-label {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ifw-manage-link { color: #2563eb !important; font-size: 11px; font-weight: 400; }
.ifw-manage-link:hover { text-decoration: underline !important; }

/* ── Input focus ─────────────────────────────────────────── */

.infoway-widget input[type="text"].ifw-input:focus,
.infoway-widget input[type="password"].ifw-input:focus {
    border-color: #2563eb !important;
    box-shadow: 0 0 0 2px rgba(37,99,235,.15) !important;
}

.ifw-apikey-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.ifw-apikey-wrap input { padding-right: 38px !important; }

/* Eye button — (0,2,0) beats reset */
.infoway-widget .ifw-eye-btn,
.infoway-widget .ifw-eye-btn:hover,
.infoway-widget .ifw-eye-btn:focus {
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    color: #9ca3af !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    height: auto !important;
    padding: 0 !important;
    position: absolute !important;
    right: 10px !important;
    width: auto !important;
}
.infoway-widget .ifw-eye-btn:hover { color: #374151 !important; }

/* Datatype row */
.ifw-datatype-row { display: flex; gap: 8px; }
.ifw-datatype-row .ifw-select { flex: 1; }
.ifw-klinetype { display: none !important; }
.ifw-klinetype.visible { display: block !important; }

/* ── Action Buttons — (0,2,0) beats reset (0,1,1) ──────── */

.ifw-actions { display: flex; gap: 10px; margin-top: 18px; }

.infoway-widget .ifw-btn {
    align-items: center !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    display: inline-flex !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    gap: 6px;
    padding: 8px 20px !important;
    transition: background .15s, opacity .15s;
    width: auto !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

.infoway-widget .ifw-btn-primary {
    background: #2563eb !important;
    border: none !important;
    color: #fff !important;
}
.infoway-widget .ifw-btn-primary:hover {
    background: #1d4ed8 !important;
    color: #fff !important;
    border: none !important;
}
.infoway-widget .ifw-btn-primary.loading {
    cursor: wait !important;
    opacity: .7;
    pointer-events: none !important;
}

.infoway-widget .ifw-btn-secondary {
    background: #f3f4f6 !important;
    border: 1px solid #d1d5db !important;
    color: #374151 !important;
}
.infoway-widget .ifw-btn-secondary:hover {
    background: #e5e7eb !important;
    color: #374151 !important;
    border-color: #d1d5db !important;
}

.infoway-widget .ifw-ws-btn[data-state="connected"] {
    background: #dc2626 !important;
    color: #fff !important;
    border: none !important;
}
.infoway-widget .ifw-ws-btn[data-state="connected"]:hover {
    background: #b91c1c !important;
}

/* ── Symbol Picker ───────────────────────────────────────── */

.ifw-sym-wrap { position: relative; }

/* trigger is a div, not affected by button reset */
.ifw-sym-trigger {
    align-items: center;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: none;
    cursor: pointer;
    display: flex;
    gap: 8px;
    height: 36px;
    padding: 0 12px;
    transition: border-color .15s;
    user-select: none;
    width: 100%;
}
.ifw-sym-trigger:hover,
.ifw-sym-trigger:focus { border-color: #2563eb; outline: none; }
.ifw-sym-trigger.open {
    border-color: #2563eb;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    box-shadow: 0 0 0 2px rgba(37,99,235,.15);
}

.ifw-sym-icon    { flex-shrink: 0; height: 20px !important; object-fit: contain; width: 20px !important; }
.ifw-sym-label   { color: #1a1a2e; flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ifw-sym-chevron { align-items: center; color: #9ca3af; display: flex; flex-shrink: 0; transition: transform .15s; }
.ifw-sym-trigger.open .ifw-sym-chevron { transform: rotate(180deg); }

/* dropdown list — div, not affected by button reset */
.ifw-sym-list {
    background: #fff;
    border: 1px solid #2563eb;
    border-top: none;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    left: 0;
    overflow: hidden;
    position: absolute;
    right: 0;
    top: 35px;
    z-index: 9999;
}

/* sym options are divs — no button reset needed */
.ifw-sym-opt {
    align-items: center;
    background: transparent;
    border: none;
    color: #374151;
    cursor: pointer;
    display: flex;
    font-size: 13px;
    gap: 8px;
    padding: 8px 12px;
    transition: background .1s;
    width: 100%;
}
.ifw-sym-opt:hover  { background: #f0f5ff; }
.ifw-sym-opt.selected { background: #eff6ff; color: #1d4ed8; font-weight: 600; }

.ifw-sym-opt-icon { flex-shrink: 0; height: 20px !important; object-fit: contain; width: 20px !important; }

.ifw-sym-custom-opt { border-top: 1px solid #e5e7eb; color: #6b7280; font-style: italic; }
.ifw-sym-custom-opt:hover { background: #f9fafb; color: #374151; }

/* custom row */
.ifw-sym-custom-row { align-items: center; display: flex; gap: 6px; margin-top: 6px; }
.ifw-sym-custom-row .ifw-sym-input { flex: 1; }

/* back button is a <button> — (0,2,0) beats reset */
.infoway-widget .ifw-sym-back-btn,
.infoway-widget .ifw-sym-back-btn:hover,
.infoway-widget .ifw-sym-back-btn:focus {
    background: #f9fafb !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    color: #6b7280 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0;
    height: 36px !important;
    padding: 0 !important;
    transition: background .15s, border-color .15s, color .15s;
    width: 36px !important;
}
.infoway-widget .ifw-sym-back-btn:hover {
    background: #eff6ff !important;
    border-color: #2563eb !important;
    color: #2563eb !important;
}

/* ── Result Panel ────────────────────────────────────────── */

.ifw-result-wrap {
    background: #0f172a;
    border: 1px solid #374151;
    border-radius: 8px;
    margin-top: 18px;
    overflow: hidden;
}

.ifw-result-toolbar {
    background: #1e293b;
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
}

.ifw-autoscroll-label {
    align-items: center;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    font-size: 12px;
    gap: 6px;
    user-select: none;
}

.ifw-autoscroll { accent-color: #2563eb; cursor: pointer; }
.ifw-result-actions { display: flex; gap: 8px; }

/* result buttons are <button> — (0,2,0) beats reset */
.infoway-widget .ifw-btn-sm,
.infoway-widget .ifw-btn-sm:hover,
.infoway-widget .ifw-btn-sm:focus {
    background: #334155 !important;
    border: none !important;
    border-radius: 4px !important;
    box-shadow: none !important;
    color: #94a3b8 !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    font-size: 11px !important;
    padding: 4px 10px !important;
    transition: background .15s, color .15s;
    width: auto !important;
}
.infoway-widget .ifw-btn-sm:hover {
    background: #475569 !important;
    color: #e2e8f0 !important;
}

.ifw-output {
    background: #0f172a;
    color: #e2e8f0;
    font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", Consolas, monospace;
    font-size: 12px;
    line-height: 1.7;
    margin: 0;
    max-height: 360px;
    min-height: 180px;
    overflow-y: auto;
    padding: 14px 16px;
    white-space: pre-wrap;
    word-break: break-all;
    scrollbar-width: thin;
    scrollbar-color: #334155 #0f172a;
}

.ifw-output::-webkit-scrollbar       { width: 6px; height: 6px; }
.ifw-output::-webkit-scrollbar-track { background: #0f172a; }
.ifw-output::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
.ifw-output::-webkit-scrollbar-thumb:hover { background: #475569; }

.ifw-note { color: #64748b; font-style: italic; }
.ifw-err  { color: #f87171; }

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 600px) {
    .ifw-form-grid { grid-template-columns: 1fr; }
    .ifw-span2 { grid-column: 1; }
    .ifw-tabs { overflow-x: auto; }
    .infoway-widget .ifw-tab-btn { font-size: 12px !important; padding: 8px 12px !important; }
}
