/* ════════════════════════════════════════════
   AutoIQ Chat — Design idêntico ao Claude.ai
   ════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Söhne:wght@400;500;600&family=Söhne+Mono&display=swap');

/* ── Reset & wrap ── */
.autoiq-wrap * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.autoiq-wrap {
    --bg:           #ffffff;
    --bg-surface:   #f5f5f0;
    --bg-input:     #ffffff;
    --border:       rgba(0,0,0,0.12);
    --border-light: rgba(0,0,0,0.08);
    --text:         #1a1a1a;
    --text-muted:   #6b7280;
    --text-hint:    #9ca3af;
    --accent:       #d97706;
    --accent-light: #fef3c7;
    --success:      #059669;
    --success-bg:   #ecfdf5;
    --danger:       #dc2626;
    --danger-bg:    #fef2f2;
    --warn:         #d97706;
    --warn-bg:      #fffbeb;
    --info:         #2563eb;
    --code-bg:      #f3f4f6;
    --radius:       12px;
    --radius-sm:    8px;
    --radius-xs:    4px;
    --font:         'Söhne', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:    'Söhne Mono', 'SF Mono', 'Fira Code', monospace;

    font-family:    var(--font);
    background:     var(--bg);
    border-radius:  var(--radius);
    overflow:       hidden;
    min-height:     100vh;
    max-width:      100%;
    margin:         0;
    display:        flex;
    flex-direction: column;
    color:          var(--text);
}

/* ── Screens ── */
.autoiq-screen { flex: 1; display: flex; flex-direction: column; }

/* ────────────────────────────────────────────
   LOADING
────────────────────────────────────────────── */
.autoiq-screen-loading {
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.autoiq-spinner-ring {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: autoiq-spin 0.8s linear infinite;
}

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

/* ────────────────────────────────────────────
   LOGIN — estilo Claude
────────────────────────────────────────────── */
.autoiq-screen-login {
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: var(--bg-surface);
}

.autoiq-login-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 380px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.06);
    animation: autoiq-fadeup 0.3s ease both;
}

@keyframes autoiq-fadeup {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.autoiq-login-header {
    padding: 32px 28px 24px;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
}

.autoiq-logo-mark {
    width: 44px;
    height: 44px;
    margin: 0 auto 14px;
    color: var(--accent);
}

.autoiq-logo-mark svg { width: 100%; height: 100%; }

.autoiq-login-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.3px;
}

.autoiq-login-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.autoiq-login-body {
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.autoiq-field-group { display: flex; flex-direction: column; gap: 5px; }

.autoiq-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.autoiq-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    padding: 10px 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.autoiq-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(217,119,6,0.1);
}

.autoiq-input::placeholder { color: var(--text-hint); }

.autoiq-input-wrap { position: relative; }
.autoiq-input-wrap .autoiq-input { padding-right: 42px; }

.autoiq-toggle-pw {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}

.autoiq-toggle-pw:hover { color: var(--text); }
.autoiq-toggle-pw svg { width: 16px; height: 16px; }

.autoiq-alert-error {
    background: var(--danger-bg);
    border: 1px solid rgba(220,38,38,0.2);
    color: var(--danger);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-size: 13px;
}

.autoiq-btn-login {
    background: var(--text);
    color: #fff;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px;
    cursor: pointer;
    width: 100%;
    transition: opacity 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
}

.autoiq-btn-login:hover { opacity: 0.85; }
.autoiq-btn-login:disabled { opacity: 0.4; cursor: not-allowed; }

.autoiq-btn-spinner svg {
    width: 15px;
    height: 15px;
    animation: autoiq-spin 0.8s linear infinite;
}

.autoiq-login-footer {
    text-align: center;
    padding: 14px 28px 18px;
    font-size: 12px;
    color: var(--text-hint);
    border-top: 1px solid var(--border-light);
}

/* ────────────────────────────────────────────
   CHAT SCREEN
────────────────────────────────────────────── */
.autoiq-screen-chat {
    min-height: 100vh;
    background: var(--bg);
    display: flex;
    flex-direction: column;
}

/* ── Header ── */
.autoiq-chat-header {
    background: var(--bg);
    border-bottom: 1px solid var(--border-light);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.autoiq-chat-header-left { display: flex; align-items: center; gap: 10px; }

.autoiq-chat-avatar {
    width: 32px;
    height: 32px;
    background: #f0ede8;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--accent);
}

.autoiq-chat-avatar svg { width: 18px; height: 18px; }

.autoiq-chat-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.autoiq-chat-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.autoiq-status-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
}

.autoiq-chat-header-right { display: flex; align-items: center; gap: 10px; }

.autoiq-usage-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    cursor: default;
}

.autoiq-usage-label { font-size: 10px; color: var(--text-hint); text-transform: uppercase; letter-spacing: 0.5px; }
.autoiq-usage-count { font-size: 12px; font-weight: 600; color: var(--text-muted); font-family: var(--font-mono); }

.autoiq-usage-bar-bg {
    width: 52px;
    height: 2px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.autoiq-usage-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.4s ease, background 0.3s;
    width: 0%;
}

.autoiq-btn-icon {
    width: 32px;
    height: 32px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.autoiq-btn-icon:hover { color: var(--danger); border-color: rgba(220,38,38,0.3); background: var(--danger-bg); }
.autoiq-btn-icon svg { width: 15px; height: 15px; }

/* ── Messages ── */
.autoiq-messages {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0 16px;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}

.autoiq-messages::-webkit-scrollbar { width: 4px; }
.autoiq-messages::-webkit-scrollbar-track { background: transparent; }
.autoiq-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Message row — igual ao Claude ── */
.autoiq-msg {
    padding: 12px 0;
    display: flex;
    gap: 16px;
    animation: autoiq-fadeup 0.2s ease both;
    max-width: 760px;
    margin: 0 auto;
    width: 100%;
    padding-left: 24px;
    padding-right: 24px;
}

.autoiq-msg-user {
    justify-content: flex-end;
}

.autoiq-msg-bot { }

.autoiq-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f0ede8;
    color: var(--accent);
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 3px;
    border: 1px solid var(--border-light);
}

.autoiq-msg-user .autoiq-msg-avatar { display: none; }

.autoiq-msg-bubble {
    max-width: 100%;
    width: 100%;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
}

.autoiq-msg-user .autoiq-msg-bubble {
    max-width: 75%;
    width: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 18px 18px 4px 18px;
    padding: 10px 16px;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 15px;
    line-height: 1.6;
}

/* ── Markdown ── */
.autoiq-msg-bubble h2 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin: 12px 0 3px;
    padding: 0;
}

.autoiq-msg-bubble h2:first-child { margin-top: 2px; }

.autoiq-msg-bubble h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin: 10px 0 2px;
}

.autoiq-msg-bubble h4 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin: 12px 0 4px;
}

.autoiq-msg-bubble p {
    margin: 4px 0;
    line-height: 1.6;
}

.autoiq-msg-bubble li {
    margin: 2px 0 2px 18px;
    list-style: disc;
    line-height: 1.5;
    font-size: 14px;
}

.autoiq-msg-bubble hr {
    display: none;
}

.autoiq-msg-bubble strong { font-weight: 600; color: var(--text); }
.autoiq-msg-bubble em { color: var(--text-muted); font-style: italic; }

.autoiq-msg-bubble code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--code-bg);
    color: var(--text);
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-light);
}

/* Verify badge */
.autoiq-verify {
    display: inline-block;
    background: var(--warn-bg);
    border: 1px solid rgba(217,119,6,0.2);
    color: var(--warn);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

/* ── Tables — idêntico ao Claude ── */
.autoiq-table-wrap {
    overflow-x: auto;
    margin: 6px 0 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.autoiq-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.autoiq-table th {
    background: var(--bg-surface);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12px;
    letter-spacing: 0.3px;
    padding: 7px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.autoiq-table td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
    font-size: 14px;
    vertical-align: top;
    line-height: 1.5;
}

.autoiq-table td:first-child { color: var(--text-muted); font-size: 13px; }
.autoiq-table tr:last-child td { border-bottom: none; }
.autoiq-table tr:hover td { background: var(--bg-surface); }

/* Code col */
.autoiq-table td code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-light);
    color: var(--text);
}

/* Status badges */
.autoiq-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

.autoiq-badge-ok      { background: var(--success-bg); color: var(--success); }
.autoiq-badge-danger  { background: var(--danger-bg);  color: var(--danger);  }
.autoiq-badge-warn    { background: var(--warn-bg);    color: var(--warn);    }
.autoiq-badge-info    { background: #eff6ff;            color: var(--info);    }

/* Alert block — discreto igual ao Claude */
.autoiq-alert-block {
    border-left: 2px solid rgba(217,119,6,0.4);
    padding: 2px 0 2px 12px;
    margin: 4px 0;
}

.autoiq-alert-block-title {
    display: none;
}

/* ── Typing ── */
.autoiq-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 8px 0 !important;
}

.autoiq-typing span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--text-hint);
    border-radius: 50%;
    animation: autoiq-bounce 1.2s ease infinite;
}

.autoiq-typing span:nth-child(2) { animation-delay: 0.15s; }
.autoiq-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes autoiq-bounce {
    0%,60%,100% { transform: translateY(0); opacity:0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Cursor streaming ── */
.autoiq-cursor {
    display: inline-flex !important;
    align-items: center !important;
    gap: 3px !important;
    margin-left: 4px !important;
    vertical-align: middle !important;
}

.autoiq-cursor span {
    display: inline-block !important;
    width: 6px !important;
    height: 6px !important;
    background: var(--accent) !important;
    border-radius: 50% !important;
    animation: autoiq-bounce 1.2s ease-in-out infinite !important;
}

.autoiq-cursor span:nth-child(2) { animation-delay: 0.2s !important; }
.autoiq-cursor span:nth-child(3) { animation-delay: 0.4s !important; }

/* ── Input area ── */
.autoiq-input-area {
    padding: 12px 24px 16px;
    background: var(--bg);
    border-top: 1px solid var(--border-light);
    flex-shrink: 0;
}

.autoiq-input-inner {
    max-width: 760px;
    margin: 0 auto;
}

.autoiq-textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    padding: 12px 16px;
    resize: none;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    display: block;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.autoiq-textarea:focus {
    border-color: rgba(0,0,0,0.25);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}

.autoiq-textarea::placeholder { color: var(--text-hint); }

.autoiq-input-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    gap: 8px;
}

.autoiq-input-hint { font-size: 11px; color: var(--text-hint); }

.autoiq-btn-send {
    background: var(--text);
    color: #fff;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    padding: 9px 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
    transition: opacity 0.15s;
}

.autoiq-btn-send:hover { opacity: 0.85; }
.autoiq-btn-send:active { transform: scale(0.99); }
.autoiq-btn-send:disabled { opacity: 0.35; cursor: not-allowed; }
.autoiq-btn-send svg { width: 14px; height: 14px; }

/* ── Supplier selector ── */
.autoiq-supplier-wrap { position: relative; }

.autoiq-supplier-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    padding: 7px 12px;
    cursor: pointer;
    font-family: var(--font);
    font-size: 13px;
    transition: border-color 0.15s, background 0.15s;
}

.autoiq-supplier-btn:hover {
    border-color: rgba(0,0,0,0.2);
    background: var(--bg-surface);
}

.autoiq-supplier-label {
    color: var(--text);
    font-weight: 500;
    font-size: 13px;
}

.autoiq-supplier-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 260px;
    padding: 8px;
    z-index: 999;
    box-shadow: 0 4px 24px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.08);
}

.autoiq-supplier-search {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    padding: 8px 10px;
    box-sizing: border-box;
    outline: none;
    margin-bottom: 4px;
}

.autoiq-supplier-search:focus { border-color: rgba(0,0,0,0.25); }

.autoiq-supplier-list { max-height: 220px; overflow-y: auto; }

.autoiq-supplier-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    transition: background 0.1s;
}

.autoiq-supplier-item:hover { background: var(--bg-surface); }
.autoiq-supplier-item.active { color: var(--accent); font-weight: 500; }
.autoiq-supplier-check { color: var(--accent); font-size: 13px; }

/* ── Responsive ── */
@media (max-width: 600px) {
    .autoiq-msg { padding: 16px; gap: 10px; }
    .autoiq-msg-bubble { font-size: 14px; }
    .autoiq-input-hint { display: none; }
    .autoiq-chat-header { padding: 10px 14px; }
}

/* Section labels — pequenos e discretos igual ao Claude */
.autoiq-msg-bubble h3 {
    font-size: 13px !important;
    font-weight: 500 !important;
    color: var(--text-muted) !important;
    margin: 10px 0 4px !important;
}
