/* ===========================================================
   AtriFinanceiro — Design System
   Tokens compartilhados por todas as páginas do sistema
   =========================================================== */

:root {
    --bg: #0b0f17;
    --bg-elevated: #0d121c;
    --surface: #161b26;
    --surface-hover: #1c2330;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);

    --text: #eef1f8;
    --text-dim: #9aa3b8;
    --text-faint: #5c6478;

    /* "violet" mantido como nome do token (usado em todas as páginas) mas
       repintado pra azul/teal pra bater com o novo visual estilo app */
    --violet: #2563eb;
    --violet-light: #60a5fa;
    --teal: #14b8a6;
    --teal-light: #2dd4bf;
    --emerald: #10b981;
    --emerald-light: #34d399;
    --red: #ef4444;
    --amber: #f59e0b;
    --blue: #3b82f6;
    --purple: #9333ea;

    --gradient-brand: linear-gradient(135deg, var(--violet) 0%, var(--teal) 100%);

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;

    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 25px 60px rgba(0, 0, 0, 0.45);

    --glass-bg: linear-gradient(180deg, rgba(26, 32, 44, 0.75) 0%, rgba(17, 24, 39, 0.85) 100%);
    --glass-border: rgba(255, 255, 255, 0.07);

    color-scheme: dark;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
}

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

/* ---------- Buttons ---------- */
.btn {
    border: none;
    padding: 13px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--gradient-brand);
    color: #fff;
}

.btn-primary:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface-hover);
    color: var(--text);
}

/* ---------- Form controls ---------- */
.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 8px;
}

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

.input-wrap i.leading {
    position: absolute;
    left: 15px;
    color: var(--text-faint);
    font-size: 15px;
    transition: color 0.2s ease;
}

.input-wrap input {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 13px 15px 13px 42px;
    color: var(--text);
    font-size: 14.5px;
    font-family: inherit;
    transition: all 0.2s ease;
}

.input-wrap input::placeholder {
    color: var(--text-faint);
}

.input-wrap input:focus {
    outline: none;
    border-color: var(--violet);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.input-wrap input:focus ~ i.leading {
    color: var(--violet-light);
}

.input-wrap .toggle-visibility {
    position: absolute;
    right: 14px;
    background: none;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
}

.input-wrap .toggle-visibility:hover {
    color: var(--text-dim);
}

/* ---------- Alerts ---------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    font-weight: 500;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--emerald-light);
}

/* ---------- Topbar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 14px 28px;
    background: rgba(16, 20, 31, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 16px;
    text-decoration: none;
    color: var(--text);
    white-space: nowrap;
}

.topbar-badge {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--gradient-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
}

.topbar-title {
    flex: 1;
}

.topbar-title h1 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
}

.topbar-title span {
    font-size: 11px;
    color: var(--text-dim);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13.5px;
    color: var(--text-dim);
    white-space: nowrap;
}

.topbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--purple), var(--violet));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}

.topbar-user a {
    color: var(--text-faint);
    text-decoration: none;
    font-size: 16px;
    transition: color 0.2s ease;
}

.topbar-user a:hover {
    color: var(--red);
}

/* ---------- Bottom nav (app shell) ---------- */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    background: rgba(13, 18, 28, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}

.bottom-nav-inner {
    max-width: 520px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.bottom-nav a,
.bottom-nav .fab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-faint);
    font-size: 10px;
    font-weight: 600;
    padding: 4px 10px;
    transition: color 0.2s ease, transform 0.15s ease;
}

.bottom-nav a:active,
.bottom-nav .fab:active {
    transform: scale(0.92);
}

.bottom-nav a i {
    font-size: 18px;
}

.bottom-nav a.active {
    color: var(--violet-light);
}

.bottom-nav .fab {
    margin-top: -26px;
}

.bottom-nav .fab-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--gradient-brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.45);
    border: 3px solid var(--bg);
}

/* ---------- Page layout ---------- */
.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 28px 60px;
}

body:has(.bottom-nav) .page {
    padding-bottom: 96px;
}

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

.page-header h1 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

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

/* ---------- Card ---------- */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 22px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 16px;
}


/* ---------- Table ---------- */
.table-wrap {
    background: var(--glass-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    overflow-x: auto;
    position: relative;
    box-shadow: var(--shadow);
}

.table-wrap::-webkit-scrollbar {
    height: 8px;
}

.table-wrap::-webkit-scrollbar-track {
    background: transparent;
}

.table-wrap::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 10px;
}

.table-wrap::-webkit-scrollbar-thumb:hover {
    background: var(--text-faint);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    padding: 15px 20px;
    font-size: 11px;
    color: var(--text-faint);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: var(--bg-elevated);
}

tbody td {
    padding: 16px 20px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    max-width: 320px;
}

tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.015);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover td {
    background: var(--surface-hover);
}

th.text-right,
td.text-right {
    text-align: right;
}

td.nowrap {
    white-space: nowrap;
}

.valor-cell {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.row-actions {
    display: flex;
    gap: 6px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-dim);
    text-decoration: none;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

.icon-btn.danger:hover {
    color: var(--red);
    border-color: rgba(239, 68, 68, 0.4);
}

.icon-btn.success:hover {
    color: var(--emerald-light);
    border-color: rgba(16, 185, 129, 0.4);
}

/* ---------- Badges ---------- */
.badge {
    padding: 5px 11px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--emerald-light);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--amber);
}

/* ---------- Form row ---------- */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
    align-items: end;
}

.form-row .field {
    margin-bottom: 0;
}

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

.empty-state i {
    font-size: 40px;
    opacity: 0.3;
    margin-bottom: 14px;
    display: block;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .topbar-user span {
        display: none;
    }

    .page {
        padding: 22px 16px 60px;
    }

    body:has(.bottom-nav) .page {
        padding-bottom: 92px;
    }
}

/* ---------- Tile grid (Lembretes / Agenda) ---------- */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.tile {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.tile.concluido {
    opacity: 0.45;
}

.tile-photo {
    flex: 1;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-elevated);
}

.tile-photo i {
    font-size: 28px;
    color: var(--text-faint);
}

.tile-info {
    padding: 10px 12px;
    background: rgba(10, 14, 23, 0.75);
    backdrop-filter: blur(6px);
}

.tile-info h4 {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tile-info span {
    font-size: 11px;
    color: var(--text-dim);
}

.tile-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tile:hover .tile-actions {
    opacity: 1;
}

.tile-actions form {
    display: inline;
}

.tile-actions .icon-btn {
    width: 28px;
    height: 28px;
    font-size: 12px;
    background: rgba(10, 14, 23, 0.85);
}

.tile-check {
    position: absolute;
    top: 8px;
    left: 8px;
}

.tile-check button {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: rgba(10, 14, 23, 0.75);
    color: var(--text-dim);
    font-size: 12px;
}

.tile.concluido .tile-check button {
    background: var(--emerald);
    color: #fff;
}

.file-input {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 12px 15px;
    color: var(--text-dim);
    font-size: 13.5px;
}

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

/* ---------- Chat ---------- */
.chat-shell {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 560px;
    margin: 0 auto;
    background: var(--bg);
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    flex-shrink: 0;
}

.chat-back {
    color: var(--text-dim);
    font-size: 18px;
    text-decoration: none;
    padding: 4px;
}

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

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 15px;
}

.chat-header-info h1 {
    font-size: 15px;
    font-weight: 700;
}

.chat-header-info small {
    font-size: 11px;
    color: var(--emerald-light);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.msg-user {
    align-self: flex-end;
    background: var(--gradient-brand);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.msg-bot {
    align-self: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.msg-user img {
    max-width: 100%;
    border-radius: 10px;
    margin-top: 6px;
    display: block;
}

.msg-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.msg-actions button {
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.msg-actions .sim { background: var(--emerald); color: #fff; }
.msg-actions .nao { background: var(--red); color: #fff; }
.msg-actions .editar { background: var(--bg-elevated); color: var(--text-dim); border: 1px solid var(--border); }

.msg-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.msg-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-faint);
    animation: typing-bounce 1.2s infinite;
}

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

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

.chat-editing-hint {
    padding: 8px 16px;
    font-size: 12.5px;
    color: var(--violet-light);
    background: rgba(37, 99, 235, 0.1);
    border-top: 1px solid var(--border);
    display: none;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-editing-hint.show { display: flex; }

.chat-editing-hint button {
    background: none;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    font-size: 13px;
}

.chat-inputbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
    flex-shrink: 0;
}

.chat-inputbar.recording {
    background: rgba(239, 68, 68, 0.08);
}

.chat-inputbar input[type="text"] {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 11px 16px;
    color: var(--text);
    font-size: 14.5px;
    font-family: inherit;
}

.chat-inputbar input[type="text"]:focus {
    outline: none;
    border-color: var(--violet);
}

.chat-inputbar button {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: var(--surface);
    color: var(--text-dim);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-inputbar button.btn-send {
    background: var(--gradient-brand);
    color: #fff;
}

.chat-inputbar button.btn-mic.recording {
    background: var(--red);
    color: #fff;
    animation: mic-pulse 1.2s infinite;
}

@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}
