@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg: #090c14;
    --bg-2: #0d1220;
    --panel: rgba(23, 29, 46, 0.72);
    --panel-solid: #171d2e;
    --border: #262e42;
    --border-soft: rgba(255, 255, 255, 0.06);
    --text: #e9ecf4;
    --muted: #8a93a6;
    --up: #26d0ac;
    --down: #ff5c73;
    --neutral: #5b6478;
    --accent: #4f8dff;
    --accent-2: #8b6bff;
    --amber: #f0b90b;
    --radius: 14px;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--neutral); }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    position: relative;
    overflow-x: hidden;
}

/* Fundo com glow sutil e animado, puramente decorativo */
body::before {
    content: '';
    position: fixed;
    inset: -20%;
    z-index: -1;
    background:
        radial-gradient(600px circle at 15% 10%, rgba(79, 141, 255, 0.14), transparent 55%),
        radial-gradient(700px circle at 85% 25%, rgba(139, 107, 255, 0.12), transparent 55%),
        radial-gradient(600px circle at 50% 100%, rgba(38, 208, 172, 0.08), transparent 55%),
        var(--bg-2);
    background-color: var(--bg);
    animation: drift 22s ease-in-out infinite alternate;
}

@keyframes drift {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    100% { transform: translate3d(-2%, 1.5%, 0) scale(1.04); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulseDot {
    0%   { box-shadow: 0 0 0 0 rgba(38, 208, 172, 0.55); }
    70%  { box-shadow: 0 0 0 6px rgba(38, 208, 172, 0); }
    100% { box-shadow: 0 0 0 0 rgba(38, 208, 172, 0); }
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.topbar {
    padding: 20px 28px 14px;
    border-bottom: 1px solid var(--border-soft);
    backdrop-filter: blur(14px);
    background: linear-gradient(180deg, rgba(23, 29, 46, 0.55), transparent);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar h1 {
    margin: 0 0 4px;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, var(--text), var(--accent) 120%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle { margin: 0 0 12px; color: var(--muted); font-size: 13px; }

.topbar-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--muted);
    padding-top: 4px;
}

.topbar-user a {
    color: var(--accent);
    text-decoration: none;
    position: relative;
    transition: color 0.2s ease;
}

.topbar-user a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -3px;
    width: 0;
    height: 1.5px;
    background: var(--accent);
    transition: width 0.25s ease;
}

.topbar-user a:hover { color: #fff; }
.topbar-user a:hover::after { width: 100%; }

.layout { padding: 24px 28px 48px; animation: fadeInUp 0.35s ease both; }

/* Autenticação */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.auth-card {
    background: var(--panel);
    backdrop-filter: blur(18px);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 32px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow);
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--up));
    background-size: 200% 100%;
    animation: shimmer 4s linear infinite;
}

.auth-card h1 {
    margin: 0 0 4px;
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 18px;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

.auth-form input {
    background: rgba(9, 12, 20, 0.6);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 141, 255, 0.18);
}

.auth-form button {
    margin-top: 6px;
}

.auth-link {
    display: inline-block;
    margin-top: 18px;
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

.auth-link:hover { color: #fff; text-decoration: underline; }

.auth-error, .flash-error {
    background: rgba(255, 92, 115, 0.12);
    border: 1px solid var(--down);
    color: #ffb3bd;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-top: 12px;
    animation: fadeInUp 0.25s ease both;
}

.auth-success, .flash-success {
    background: rgba(38, 208, 172, 0.12);
    border: 1px solid var(--up);
    color: #9ff2e0;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-top: 12px;
    animation: fadeInUp 0.25s ease both;
}

.auth-warning {
    background: rgba(240, 185, 11, 0.1);
    border: 1px solid var(--amber);
    color: #f0d68a;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12px;
    margin-top: 12px;
    word-break: break-all;
}

.flash {
    padding: 11px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 18px;
    animation: fadeInUp 0.25s ease both;
}

/* Configurações */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
    align-items: start;
    margin-bottom: 18px;
}

.settings-panel {
    background: var(--panel);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 20px 22px;
    margin-bottom: 18px;
    max-width: 560px;
    box-shadow: var(--shadow);
    transition: border-color 0.2s ease;
    min-width: 0;
}

.settings-grid .settings-panel { margin-bottom: 0; max-width: none; }

.settings-panel-wide { max-width: none; }

.settings-panel:hover { border-color: rgba(79, 141, 255, 0.25); }

.settings-panel h3 { margin-top: 0; }

.table-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }

.users-table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    font-size: 13px;
}

.users-table th, .users-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
    white-space: nowrap;
}

.users-table th {
    color: var(--muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.users-table tbody tr { transition: background 0.15s ease; }
.users-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

.users-table .actions-cell { white-space: nowrap; }

.assets-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.assets-header h3 { margin: 0; }

.asset-filter {
    width: 100%;
    background: rgba(9, 12, 20, 0.6);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
    margin: 10px 0 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.asset-filter:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 141, 255, 0.18);
}

.assets-scroll { max-height: 420px; overflow-y: auto; }

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-form label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

.settings-form input[type="text"],
.settings-form input[type="email"],
.settings-form input[type="password"],
.settings-form input[type="number"],
.settings-form select {
    background: rgba(9, 12, 20, 0.6);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.settings-form input:focus, .settings-form select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 141, 255, 0.18);
}

.checkbox-label {
    flex-direction: row !important;
    align-items: center;
    gap: 9px !important;
    color: var(--text) !important;
    font-size: 13px !important;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.settings-form .hint { font-size: 11px; color: var(--muted); line-height: 1.6; }
.settings-form .hint code {
    background: rgba(255, 255, 255, 0.06);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
}

.settings-form button { align-self: flex-start; }

.inline-form { display: inline; margin-right: 10px; }

.link-button {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 12px;
    padding: 0;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.link-button:hover { color: #fff; }
.link-button-danger { color: var(--down); }
.link-button-danger:hover { color: #ff8a98; }

.controls {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.controls label {
    display: flex;
    flex-direction: column;
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
    gap: 5px;
}

select {
    background: var(--panel-solid);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

select:hover { border-color: rgba(79, 141, 255, 0.4); }
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 141, 255, 0.18); }

button {
    cursor: pointer;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: 1px solid transparent;
    color: #fff;
    font-weight: 600;
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 14px;
    font-family: inherit;
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
    box-shadow: 0 4px 14px rgba(79, 141, 255, 0.25);
}

button:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(79, 141, 255, 0.35); }
button:active { transform: translateY(0); }
button:disabled {
    opacity: 0.65;
    cursor: wait;
    transform: none;
    animation: pulseSoft 1.4s ease-in-out infinite;
}

@keyframes pulseSoft {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.25); }
}

.last-update { color: var(--muted); font-size: 12px; margin-left: auto; align-self: center; transition: color 0.2s ease; }

.auto-refresh-status {
    font-size: 11px;
    align-self: center;
    padding: 4px 10px 4px 8px;
    border-radius: 20px;
    background: rgba(91, 100, 120, 0.18);
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border-soft);
    transition: all 0.25s ease;
}

.auto-refresh-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--up);
    flex-shrink: 0;
    animation: pulseDot 2s ease-in-out infinite;
}

.auto-refresh-status.paused {
    background: rgba(240, 185, 11, 0.12);
    color: #f0d68a;
    border-color: rgba(240, 185, 11, 0.25);
}

.auto-refresh-status.paused::before {
    background: var(--amber);
    animation: none;
}

.grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    /* os dois painéis esticam para a mesma altura — evita espaço morto
       abaixo do gráfico quando a coluna de sinais/histórico é mais alta */
    align-items: stretch;
}

.chart-panel, .signal-panel {
    background: var(--panel);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    transition: border-color 0.25s ease;
    /* evita que o conteúdo (tabelas, textos longos) force o painel a crescer
       além da largura da coluna do grid */
    min-width: 0;
    overflow-wrap: break-word;
}

.chart-panel:hover, .signal-panel:hover { border-color: rgba(255, 255, 255, 0.1); }

.chart-panel { display: flex; flex-direction: column; }

#chart { width: 100%; flex: 1 1 auto; min-height: 420px; border-radius: 8px; overflow: hidden; }

.signal-card {
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 18px;
    border: 1px solid var(--border);
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    animation: fadeInUp 0.3s ease both;
}

.signal-type {
    font-size: 23px;
    font-weight: 800;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.signal-price { font-size: 15px; color: var(--muted); margin-top: 4px; }
.signal-meta { font-size: 13px; margin-top: 10px; color: var(--text); line-height: 1.5; }
.signal-notes { font-size: 12px; margin-top: 8px; color: var(--muted); line-height: 1.5; }

.signal-compra {
    background: linear-gradient(160deg, rgba(38, 208, 172, 0.14), rgba(38, 208, 172, 0.03));
    border-color: var(--up);
    box-shadow: 0 0 24px rgba(38, 208, 172, 0.12);
}
.signal-compra .signal-type { color: var(--up); }
.signal-compra .signal-type::before { content: '▲'; font-size: 16px; }

.signal-venda {
    background: linear-gradient(160deg, rgba(255, 92, 115, 0.14), rgba(255, 92, 115, 0.03));
    border-color: var(--down);
    box-shadow: 0 0 24px rgba(255, 92, 115, 0.12);
}
.signal-venda .signal-type { color: var(--down); }
.signal-venda .signal-type::before { content: '▼'; font-size: 16px; }

.signal-neutro {
    background: linear-gradient(160deg, rgba(91, 100, 120, 0.14), rgba(91, 100, 120, 0.03));
    border-color: var(--neutral);
}
.signal-neutro .signal-type { color: var(--muted); }
.signal-neutro .signal-type::before { content: '●'; font-size: 12px; }

h3 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 18px 0 10px; letter-spacing: 0.8px; font-weight: 700; }

.fib-context {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.02);
}

.fib-context-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 12px;
    border-bottom: 1px solid var(--border-soft);
}

.fib-context-row:last-child { border-bottom: none; }
.fib-context-row span { color: var(--muted); }
.fib-context-row strong { color: var(--text); font-weight: 600; text-align: right; }

.fib-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.fib-table td {
    padding: 6px 4px;
    border-bottom: 1px solid var(--border-soft);
    transition: background 0.15s ease;
    overflow-wrap: break-word;
}
.fib-table tr:hover td { background: rgba(255, 255, 255, 0.03); }
.fib-table td:last-child { text-align: right; font-family: 'JetBrains Mono', monospace; }

.badge {
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    display: inline-block;
}
.badge-compra { background: rgba(38, 208, 172, 0.16); color: var(--up); }
.badge-venda { background: rgba(255, 92, 115, 0.16); color: var(--down); }
.badge-neutro { background: rgba(91, 100, 120, 0.2); color: var(--muted); }

/* Análise por indicadores técnicos */
.indicators-section {
    background: var(--panel);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-top: 18px;
    box-shadow: var(--shadow);
}

.indicators-header {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.indicators-header h3 { margin: 0; flex: 1 1 220px; }

.indicators-overall {
    margin-bottom: 0;
    min-width: 260px;
    flex: 0 1 320px;
    padding: 12px 16px;
}

.indicators-overall .signal-type { font-size: 19px; }
.indicators-overall .signal-price { font-size: 13px; margin-top: 2px; }
.indicators-overall .signal-meta { font-size: 12px; margin-top: 6px; }

.indicators-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
}

.indicator-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.02);
    transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}

.indicator-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.15);
}

.indicator-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.indicator-label { font-size: 12px; color: var(--text); font-weight: 600; }
.indicator-value { font-family: 'JetBrains Mono', monospace; font-size: 16px; font-weight: 600; }
.indicator-detail { font-size: 11px; color: var(--muted); margin-top: 5px; line-height: 1.4; }

.indicator-alta { background: rgba(38, 208, 172, 0.08); border-color: rgba(38, 208, 172, 0.3); }
.indicator-baixa { background: rgba(255, 92, 115, 0.08); border-color: rgba(255, 92, 115, 0.3); }
.indicator-neutro { background: rgba(91, 100, 120, 0.06); }

@media (max-width: 640px) {
    .indicators-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

.disclaimer {
    margin-top: 28px;
    font-size: 11px;
    color: var(--muted);
    max-width: 800px;
    line-height: 1.6;
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
}

@media (max-width: 900px) {
    .grid { grid-template-columns: 1fr; }
    .topbar { padding: 16px 18px 10px; }
    .layout { padding: 18px 18px 36px; }
}
