/* ============================================================
   NUTRIMETRIC — DESIGN SYSTEM UNIFICADO
   Fonte: DM Sans (display) + JetBrains Mono (dados)
   Tema: Dark refinado com acentos esmeralda
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800;1,9..40,400&family=JetBrains+Mono:wght@400;500;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800;900&display=swap');

/* ── TOKENS ── */
:root {
    /* Superfícies */
    --surface-0: #070709;
    --surface-1: #0e0e12;
    --surface-2: #141418;
    --surface-3: #1c1c22;
    --surface-4: #242429;

    /* Bordas */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.14);

    /* Texto */
    --text-primary: #f2f2f4;
    --text-secondary: #bfbfc2;
    --text-tertiary: #c2c2cb;

    /* Marca */
    --green-500: #0fda96;
    --green-600: #059669;
    --green-700: #047857;
    --green-glow: rgba(15, 218, 150, 0.28);
    --green-subtle: rgba(15, 218, 150, 0.10);

    /* Semânticas */
    --blue-400: #7cb9ff;
    --blue-500: #4f96ff;
    --amber-400: #ffd04d;
    --amber-500: #f5a623;
    --red-400: #ff7b7b;
    --red-500: #f53b3b;
    --purple-400: #d09aff;
    --purple-500: #b467ff;

    /* Aliases legado */
    --bg-body: var(--surface-0);
    --bg-sidebar: var(--surface-1);
    --bg-card: var(--surface-2);
    --bg-card-2: var(--surface-3);
    --bg-input: var(--surface-1);
    --border-color: var(--border-default);
    --text-main: var(--text-primary);
    --text-muted: var(--text-secondary);
    --primary: var(--green-500);
    --primary-hover: var(--green-600);
    --primary-glow: var(--green-glow);
    --danger: var(--red-500);
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 8px 32px rgba(0, 0, 0, 0.35);
    --shadow-main: 0 24px 64px rgba(0, 0, 0, 0.75);
    --glass-bg: rgba(14, 14, 18, 0.88);
}

/* ── LIGHT MODE ── */
body.light-mode {
    --surface-0: #f4f4f8;
    --surface-1: #ffffff;
    --surface-2: #ffffff;
    --surface-3: #f8f8fc;
    --surface-4: #f0f0f5;

    --border-subtle: rgba(0, 0, 0, 0.04);
    --border-default: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.14);

    --text-primary: #0f0f14;
    --text-secondary: #353538;
    --text-tertiary: #454555;

    --green-500: #059669;
    --green-600: #047857;
    --green-glow: rgba(5, 150, 105, 0.12);
    --green-subtle: rgba(5, 150, 105, 0.06);

    --blue-400: #2563eb;
    --blue-500: #1d4ed8;
    --amber-400: #d97706;
    --amber-500: #b45309;
    --purple-400: #7c3aed;
    --purple-500: #6d28d9;
    --red-400: #dc2626;
    --red-500: #b91c1c;

    --bg-body: var(--surface-0);
    --bg-sidebar: var(--surface-1);
    --bg-card: var(--surface-2);
    --bg-card-2: var(--surface-3);
    --bg-input: var(--surface-4);
    --border-color: var(--border-default);
    --text-main: var(--text-primary);
    --text-muted: var(--text-secondary);
    --primary: var(--green-500);
    --primary-hover: var(--green-600);
    --primary-glow: var(--green-glow);
    --card-shadow: 0 2px 10px rgba(0, 0, 0, 0.10), 0 12px 40px rgba(0, 0, 0, 0.13);
    --shadow-main: 0 10px 40px rgba(0, 0, 0, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.92);
}

/* ── RESET ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    transition: background-color 0.3s, color 0.3s;
}

h4, h5 {
    color: var(--text-primary) !important;
    font-size: 24px;
}

h1, h2, h3, h4, h5, h6, .page-title, .nm-welcome-title, .brand-name, .nm-stat-value {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 800;
    letter-spacing: -0.02em;
}

a {
    text-decoration: none;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
}

/* ── SIDEBAR ── */
.sidebar {
    width: 244px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-mode .sidebar {
    box-shadow: 1px 0 0 var(--border-default);
}

.brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--green-500), var(--green-700));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 16px var(--green-glow);
}

.brand-logo img {
    width: 27px;
}

.brand-name {
    font-size: 23px;
    font-weight: 700;
    color: var(--text-primary) !important;
    letter-spacing: -0.03em;
}

.brand-name span {
    color: var(--green-500);
}

.nav-section {
    padding: 16px 12px 4px;
}

.nav-label {
    font-size: 11, 5px;
    font-weight: 600;
    color: var(--text-tertiary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0 10px;
    margin-bottom: 4px;
    display: block;
}

.sidebar nav {
    padding: 0 12px;
    flex: 1;
    overflow-y: visible;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    margin-bottom: 1px;
}

.sidebar nav a i {
    font-size: 15px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar nav a:hover {
    background: var(--surface-3);
    color: var(--text-primary);
    transform: translateX(3px);
}

.sidebar nav a.active {
    background: rgba(15, 218, 150, 0.13);
    color: var(--green-500);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--green-500);
}

body.light-mode .sidebar nav a.active {
    background: rgba(5, 150, 105, 0.08);
}

.sidebar nav a.active i {
    color: var(--green-500);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-subtle);
}

.sidebar-user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    margin-bottom: 6px;
    text-decoration: none;
    transition: background .2s;
    cursor: pointer;
}
.sidebar-user-card:hover {
    background: var(--surface-3);
}
.sidebar-user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--green-500), #064e3b);
    color: #fff;
    font-size: .85rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.sidebar-user-avatar img {
    width: 100%; height: 100%; object-fit: cover; object-position: top center;
}
.sidebar-user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}
.sidebar-user-name {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: .68rem;
    color: var(--green-500);
    font-weight: 500;
}

.logout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-tertiary);
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.15s;
}

.logout:hover {
    background: rgba(248, 113, 113, 0.08);
    color: var(--red-400);
}

/* ── MAIN CONTENT ── */
.main-content {
    margin-left: 244px;
    min-height: 100vh;
    background: var(--bg-body);
    transition: background 0.3s;
}

/* ── THEME TOGGLE ── */
.theme-btn {
    position: fixed;
    top: 16px;
    right: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface-3);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
}

.theme-btn:hover {
    border-color: var(--green-500);
    color: var(--green-500);
    transform: scale(1.05);
}

/* ── CARDS / PANELS ── */
.nm-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    box-shadow: var(--card-shadow);
}

body.light-mode .nm-card {
    border-color: var(--border-default);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.09), 0 10px 40px rgba(0, 0, 0, 0.12);
}

.nm-card-pad {
    padding: 22px;
}

/* ── SECTION HEADER ── */
.nm-section-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 18px;
}

.nm-section-head i {
    color: var(--green-500);
    font-size: 13px;
}

/* ── INPUTS ── */
.nm-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: 9px;
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 13.5px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.nm-input:focus {
    border-color: var(--green-500);
    box-shadow: 0 0 0 3px var(--green-glow);
}

.nm-input option {
    background: var(--surface-2);
}

body.light-mode .nm-input {
    background: var(--surface-4);
    border-color: var(--border-default);
    color: var(--text-primary);
}

body.light-mode .nm-input:focus {
    background: #fff;
}

.nm-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

/* ── BUTTONS ── */
.nm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 18px;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 600;
    font-family: 'Plus Jakarta Sans', sans-serif;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: none;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.nm-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.15);
    opacity: 0;
    transition: opacity 0.15s;
    border-radius: inherit;
}

.nm-btn:active {
    transform: scale(0.94) !important;
    transition-duration: 0.08s !important;
}

.nm-btn-primary {
    background: #00815d;
    color: #fff;
    box-shadow: 0 2px 10px rgba(6, 95, 70, 0.4);
}

.nm-btn-primary:hover {
    background: var(--green-600);
    color: #fff;
    box-shadow: 0 8px 28px rgba(4, 120, 87, 0.45), 0 2px 8px rgba(0, 0, 0, 0.25);
    transform: translateY(-3px) scale(1.03);
}

.nm-btn-primary:hover::after {
    opacity: 1;
}

/* Modo claro: verde vibrante */
body.light-mode .nm-btn-primary {
    background: var(--green-500);
    box-shadow: 0 2px 10px var(--green-glow);
}

body.light-mode .nm-btn-primary:hover {
    background: var(--green-600);
    box-shadow: 0 8px 28px var(--green-glow), 0 2px 8px rgba(0, 0, 0, 0.15);
}

.nm-btn-ghost {
    background: var(--surface-3);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
}

.nm-btn-ghost:hover {
    background: var(--surface-4);
    color: var(--text-primary);
    border-color: var(--green-500);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.nm-btn-danger {
    background: rgba(255, 123, 123, 0.12);
    color: var(--red-400);
    border: 1px solid rgba(255, 123, 123, 0.25);
}

.nm-btn-danger:hover {
    background: rgba(255, 123, 123, 0.24);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 18px rgba(248, 113, 113, 0.28);
    border-color: rgba(255, 123, 123, 0.45);
}

.nm-btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 7px;
}

.nm-btn-full {
    width: 100%;
}

/* ── BADGES / PILLS ── */
.nm-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.nm-badge-green {
    background: rgba(15, 218, 150, 0.15);
    color: var(--green-500);
    border: 1px solid rgba(15, 218, 150, 0.30);
}

.nm-badge-blue {
    background: rgba(124, 185, 255, 0.15);
    color: var(--blue-400);
    border: 1px solid rgba(124, 185, 255, 0.28);
}

.nm-badge-amber {
    background: rgba(255, 208, 77, 0.15);
    color: var(--amber-400);
    border: 1px solid rgba(255, 208, 77, 0.28);
}

.nm-badge-red {
    background: rgba(255, 123, 123, 0.15);
    color: var(--red-400);
    border: 1px solid rgba(255, 123, 123, 0.28);
}

.nm-badge-purple {
    background: rgba(208, 154, 255, 0.15);
    color: var(--purple-400);
    border: 1px solid rgba(208, 154, 255, 0.28);
}

.nm-badge-gray {
    background: var(--surface-3);
    color: var(--text-tertiary);
    border: 1px solid var(--border-default);
}

body.light-mode .nm-badge-green {
    background: rgba(5, 150, 105, 0.08);
    color: var(--green-500);
}

body.light-mode .nm-badge-blue {
    background: rgba(59, 130, 246, 0.08);
    color: var(--blue-500);
}

body.light-mode .nm-badge-amber {
    background: rgba(245, 158, 11, 0.08);
    color: var(--amber-500);
}

body.light-mode .nm-badge-red {
    background: rgba(239, 68, 68, 0.08);
    color: var(--red-500);
}

body.light-mode .nm-badge-purple {
    background: rgba(168, 85, 247, 0.08);
    color: var(--purple-500);
}

/* ── AVATAR ── */
.nm-avatar {
    border-radius: 50%;
    background: var(--green-subtle);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--green-500);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.nm-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.nm-avatar-sm {
    width: 36px;
    height: 36px;
    font-size: 14px;
}

.nm-avatar-md {
    width: 44px;
    height: 44px;
    font-size: 16px;
}

.nm-avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 20px;
}

.nm-avatar-xl {
    width: 80px;
    height: 80px;
    font-size: 28px;
}

/* ── STAT CARDS ── */
.nm-stat {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transition: all 0.2s;
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
}

.nm-stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--stat-color, var(--green-500));
    opacity: 0.8;
}

.nm-stat:hover {
    border-color: var(--stat-color, var(--green-500));
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--stat-color, var(--green-500));
}

body.light-mode .nm-stat {
    border-color: var(--border-default);
}

.nm-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--stat-color, var(--green-500)) 12%, transparent);
    color: var(--stat-color, var(--green-500));
}

.nm-stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 4px;
}

.nm-stat-value {
    font-size: 30px;
    font-weight: 900;
    color: var(--text-primary);
    line-height: 1;
    font-family: 'Plus Jakarta Sans', sans-serif;
    letter-spacing: -0.02em;
}

.nm-stat-sub {
    font-size: 14px;
    color: var(--text-tertiary);
    margin-top: 3px;
}

/* ── WELCOME BAR ── */
.nm-welcome {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 22px 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.nm-welcome::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, var(--green-glow) 0%, transparent 70%);
    pointer-events: none;
}

body.light-mode .nm-welcome {
    background: #fff;
    border-color: var(--border-default);
}

.nm-welcome-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.nm-welcome-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 3px;
}

/* ── TABLES / ROWS ── */
.nm-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
    gap: 12px;
}

.nm-row:last-child {
    border-bottom: none;
}

/* ── EMPTY STATE ── */
.nm-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.nm-empty-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--green-subtle);
    border: 1px solid rgba(16, 185, 129, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: rgba(16, 185, 129, 0.4);
    margin-bottom: 14px;
}

.nm-empty-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.nm-empty-sub {
    font-size: 13px;
    color: var(--text-tertiary);
}

/* ── ALERTS ── */
.nm-alert {
    padding: 12px 16px;
    border-radius: 9px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nm-alert-success {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--green-500);
}

.nm-alert-danger {
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.2);
    color: var(--red-400);
}

/* ── LOGIN SCREEN ── */
.body-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: var(--surface-0);
    background-image:
        radial-gradient(ellipse 60% 50% at 50% -10%, var(--green-glow), transparent);
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: 18px;
    padding: 40px;
    box-shadow: var(--shadow-main);
}

body.light-mode .login-card {
    background: #fff;
    border-color: var(--border-default);
}

.input-group-custom {
    background: var(--surface-0);
    border: 1px solid var(--border-default);
    border-radius: 9px;
    display: flex;
    align-items: center;
    padding: 12px 14px;
    transition: all 0.15s;
    gap: 10px;
}

.input-group-custom:focus-within {
    border-color: var(--green-500);
    box-shadow: 0 0 0 3px var(--green-glow);
}

.input-group-custom input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    width: 100%;
    outline: none;
    font-size: 14px;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.input-group-custom input::placeholder {
    color: var(--text-tertiary);
}

.input-group-custom i {
    color: var(--text-tertiary);
    font-size: 14px;
    flex-shrink: 0;
}

.btn-nutri-dark {
    background: #00815d;
    color: #fff;
    border: none;
    padding: 13px;
    border-radius: 9px;
    font-weight: 600;
    font-size: 14px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    transition: all 0.2s;
    width: 100%;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(6, 95, 70, 0.4);
}

.btn-nutri-dark:hover {
    background: var(--green-600);
    box-shadow: 0 6px 20px rgba(4, 120, 87, 0.45), 0 2px 8px rgba(0, 0, 0, 0.25);
    transform: translateY(-1px);
}

/* ── CHAT ── */
.chat-wrapper {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 112px);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface-1);
    flex-shrink: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.bubble-row {
    display: flex;
    align-items: flex-end;
}

.bubble-row.mine {
    justify-content: flex-end;
}

.bubble-row.theirs {
    justify-content: flex-start;
}

.bubble-col {
    display: flex;
    flex-direction: column;
    max-width: 58%;
}

.bubble-row.mine .bubble-col {
    align-items: flex-end;
}

.bubble-row.theirs .bubble-col {
    align-items: flex-start;
}

.bubble {
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
    display: inline-block;
}

.bubble.theirs {
    background: var(--surface-3);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.bubble.mine {
    background: #00815d;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.bubble-time {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 3px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    padding: 0 3px;
}

.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-1);
    flex-shrink: 0;
}

.chat-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: 11px;
    padding: 10px 14px;
    transition: border-color 0.15s;
}

.chat-input-row:focus-within {
    border-color: var(--green-500);
}

.chat-input-row textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13.5px;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.chat-input-row textarea::placeholder {
    color: var(--text-tertiary);
}

.btn-send {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--green-500);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.btn-send:hover {
    background: var(--green-600);
    transform: scale(1.1);
    box-shadow: 0 4px 14px var(--green-glow);
}

.btn-send:disabled {
    opacity: 0.35;
    cursor: default;
    transform: none;
}

/* ── MISC ── */
.base_img {
    width: 22px;
}

.font-mono {
    font-family: 'Plus Jakarta Sans', sans-serif;
}

/* ── RESPONSIVE ── */
/* Tablet: sidebar recolhida com só ícones */
@media (max-width: 992px) and (min-width: 577px) {
    .sidebar {
        width: 60px;
    }

    .brand-name,
    .sidebar .nav-label,
    .sidebar nav a span,
    .sidebar-footer .logout span,
    .sidebar-user-info {
        display: none;
    }
    .sidebar-user-card {
        justify-content: center;
        padding: 10px 0;
    }

    .brand {
        justify-content: center;
        padding: 18px 0;
    }

    .sidebar nav a {
        justify-content: center;
        padding: 11px;
    }

    .sidebar nav a i {
        width: auto;
        font-size: 17px;
    }

    .logout {
        justify-content: center;
    }

    .main-content {
        margin-left: 60px;
    }

    .nav-section {
        display: none;
    }
}

/* Desktop: bottom nav nunca aparece */
@media (min-width: 577px) {
    .bottom-nav {
        display: none !important;
    }

    .bottom-drawer {
        display: none !important;
    }

    .bottom-drawer-overlay {
        display: none !important;
    }
}

/* Mobile: sidebar some, bottom bar aparece */
@media (max-width: 576px) {
    .sidebar {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding-bottom: 72px;
    }

    .theme-btn {
        top: 10px;
        right: 12px;
    }

    .bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--bg-sidebar);
        border-top: 1px solid var(--border-default);
        z-index: 200;
        align-items: stretch;
        justify-content: space-around;
        padding: 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
    }
}

/* ── BOTTOM NAV ── */
.bottom-nav {
    display: none;
    /* visível só no mobile via media query */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border-default);
    z-index: 200;
    align-items: stretch;
    justify-content: space-around;
    padding: 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

body.light-mode .bottom-nav {
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.10);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-tertiary);
    font-size: 10px;
    font-weight: 600;
    font-family: 'Plus Jakarta Sans', sans-serif;
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    padding: 6px 4px;
    transition: color 0.2s;
    position: relative;
}

.bottom-nav-item i {
    font-size: 18px;
    line-height: 1;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bottom-nav-item span {
    font-size: 9.5px;
    letter-spacing: 0.01em;
}

.bottom-nav-item:hover,
.bottom-nav-item:hover i {
    color: var(--green-500);
}

.bottom-nav-item:hover i {
    transform: translateY(-3px) scale(1.15);
}

.bottom-nav-item.active {
    color: var(--green-500);
}

.bottom-nav-item.active i {
    transform: translateY(-3px) scale(1.1);
}

.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--green-500);
    border-radius: 0 0 3px 3px;
}

/* ── BOTTOM DRAWER ── */
.bottom-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 300;
    backdrop-filter: blur(2px);
}

.bottom-drawer-overlay.open {
    display: block;
}

.bottom-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface-2);
    border-top: 1px solid var(--border-default);
    border-radius: 18px 18px 0 0;
    z-index: 400;
    padding: 12px 16px 80px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-mode .bottom-drawer {
    background: #fff;
    border-color: var(--border-default);
}

.bottom-drawer.open {
    transform: translateY(0);
}

.bottom-drawer-handle {
    width: 36px;
    height: 4px;
    background: var(--border-strong);
    border-radius: 2px;
    margin: 0 auto 16px;
}

.drawer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 12px;
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
    margin-bottom: 2px;
}

.drawer-item i {
    font-size: 17px;
    width: 22px;
    text-align: center;
    color: var(--text-tertiary);
}

.drawer-item:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

.drawer-item.active {
    background: rgba(15, 218, 150, 0.10);
    color: var(--green-500);
}

.drawer-item.active i {
    color: var(--green-500);
}

.drawer-item.text-danger {
    color: var(--red-400) !important;
}

.drawer-item.text-danger i {
    color: var(--red-400) !important;
}

.drawer-item.text-danger:hover {
    background: rgba(255, 123, 123, 0.08);
}

@media (max-width: 576px) {
    .theme-btn {
        top: 10px;
        right: 12px;
    }

    /* Cards de estatística do dashboard com tamanho uniforme no celular */
    .nm-stat {
        height: 100%;
        min-height: 142px;
        padding: 16px;
        gap: 12px;
    }
    .nm-stat-value {
        font-size: 26px;
    }
    .nm-stat-label {
        font-size: 10.5px;
        letter-spacing: 0.03em;
    }

    /* Evita o zoom automático do iOS ao focar QUALQUER campo com fonte < 16px.
       !important porque vários inputs usam font-size inline (ex.: 12.5px). */
    input,
    select,
    textarea,
    .input-group-custom input,
    .nm-input,
    select.nm-input,
    textarea.nm-input {
        font-size: 16px !important;
    }
}

body.light-mode .nm-stat {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.09), 0 10px 32px rgba(0, 0, 0, 0.12);
}

/* ── CORREÇÃO DE PREENCHIMENTO AUTOMÁTICO (AUTOFILL) ── */

/* Para os inputs da tela de login/cadastro */
.input-group-custom input:-webkit-autofill,
.input-group-custom input:-webkit-autofill:hover,
.input-group-custom input:-webkit-autofill:focus,
.input-group-custom input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px var(--surface-0) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Para os inputs gerais do painel (caso usem autofill) */
.nm-input:-webkit-autofill,
.nm-input:-webkit-autofill:hover,
.nm-input:-webkit-autofill:focus,
.nm-input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Previne animações no carregamento da página */
.preload-theme,
.preload-theme * {
    -webkit-transition: none !important;
    transition: none !important;
}

/* ── SOMBRA LIGHT MODE — CARDS CUSTOMIZADOS ──────────────────
   Em fundo branco (#f4f4f8 → #fff) os cards sem sombra ficam
   invisíveis. Aplica a mesma sombra do .nm-card em light mode
   para todas as classes de card definidas nos templates.
   ─────────────────────────────────────────────────────────── */
body.light-mode .inativo-card,
body.light-mode .modelo-card,
body.light-mode .shopping-card,
body.light-mode .nutri-card,
body.light-mode .contato-card,
body.light-mode .refeicao-card,
body.light-mode .paciente-card,
body.light-mode .pac-card,
body.light-mode .create-card,
body.light-mode .hc-stat,
body.light-mode .hc-panel,
body.light-mode .hc-welcome,
body.light-mode .hero-card,
body.light-mode .info-chip,
body.light-mode .action-card {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.09), 0 10px 40px rgba(0, 0, 0, 0.12);
}

/* Sombra reforçada no hover para cards interativos */
body.light-mode .inativo-card:hover,
body.light-mode .modelo-card:hover,
body.light-mode .nutri-card:hover,
body.light-mode .contato-card:hover,
body.light-mode .pac-card:hover,
body.light-mode .hc-stat:hover,
body.light-mode .info-chip:hover {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.10);
}

/* quick-link: sombra leve pois fica dentro de nm-card */
body.light-mode .quick-link {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

/* ── AJUSTES MOBILE (consolidados) ── */
@media (max-width: 576px) {

    /* Menos espaço ao redor do conteúdo/cards */
    .main-content .container-fluid {
        padding: 14px 12px !important;
    }
    .nm-stat {
        min-height: 0;
        padding: 14px;
    }

    /* Campos nunca saem do card (ex.: data de nascimento) */
    .nm-card input,
    .nm-card select,
    .nm-card textarea {
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
    .row > * {
        min-width: 0;
    }

    /* Grid "adicionar alimento" (montar dieta / modelo): empilhado, sem sobreposição */
    .add-item-grid {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }
    .add-item-grid > input,
    .add-item-grid > select {
        width: 100% !important;
    }
    .add-item-grid .btn-add-item {
        width: 100% !important;
        height: 42px !important;
    }

    /* Linha de dieta: ações quebram para baixo em vez de vazar */
    .dieta-item {
        flex-wrap: wrap !important;
        row-gap: 10px;
    }
    .dieta-item > div:last-child {
        width: 100%;
        justify-content: flex-end;
    }

    /* Cabeçalho de "montar dieta": botões de ação em largura própria */
    .refeicao-head {
        flex-wrap: wrap;
        row-gap: 8px;
    }
}
