/* ============================================================
   Exyo — Estilo global
   Motion + glassmorphism + identidade teal preservada
   ============================================================ */

/* --- 1. FONTES E RESET --- */
@font-face {
    font-family: 'uniNeue';
    src: url('../fonts/Fontfabric - UniNeueBook.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'uniNeue';
    src: url('../fonts/Fontfabric - UniNeueBold.otf') format('opentype');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

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

html { scroll-behavior: smooth; }


/* --- 2. SISTEMA DE TEMAS E VARIÁVEIS --- */
:root {
    --primary-color: #71C5C9;
    --primary-dark:  #004C4C;
    --primary-soft:  #A6DDDF;
    --primary-glow:  rgba(113, 197, 201, 0.45);

    --bs-primary: var(--primary-color);
    --bs-primary-rgb: 113, 197, 201;

    --transition-fast: 180ms cubic-bezier(.4, 0, .2, 1);
    --transition-base: 320ms cubic-bezier(.4, 0, .2, 1);
    --transition-slow: 600ms cubic-bezier(.4, 0, .2, 1);
    --ease-spring:    cubic-bezier(.34, 1.56, .64, 1);

    --shadow-sm: 0 1px 2px rgba(0,0,0,.06), 0 1px 1px rgba(0,0,0,.04);
    --shadow-md: 0 6px 18px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
    --shadow-lg: 0 18px 40px rgba(0,0,0,.18), 0 4px 12px rgba(0,0,0,.06);
    --shadow-glow: 0 0 0 1px var(--primary-glow), 0 12px 30px var(--primary-glow);
}

/* TEMA DARK (unico) */
:root {
    --bs-body-bg: #0e1414;
    --bs-body-color: #FFFFFF;
    --bs-secondary-bg: #161e1f;
    --bs-tertiary-bg: #131a1b;
    --bs-border-color: rgba(113, 197, 201, 0.18);
    --bs-tertiary-color: #B0BFBF;

    --glass-bg:    rgba(22, 30, 31, 0.6);
    --glass-bg-strong: rgba(22, 30, 31, 0.82);
    --glass-border: rgba(113, 197, 201, 0.22);
    --body-overlay-bg: rgba(14, 20, 20, 0.78);
    --aurora-1: rgba(113, 197, 201, 0.18);
    --aurora-2: rgba(0, 76, 76, 0.30);
}


/* --- 3. BODY + BACKDROP ANIMADO --- */
body {
    font-family: 'uniNeue', 'Inter', system-ui, sans-serif;
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 0;
    overflow-x: hidden;
}

body {
    background-image: url("../chat/fundo.png");
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
}

/* Aurora animada no fundo (gradiente que se move suavemente) */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 15% 20%, var(--aurora-1) 0%, transparent 45%),
        radial-gradient(circle at 85% 80%, var(--aurora-2) 0%, transparent 45%),
        var(--body-overlay-bg);
    pointer-events: none;
    z-index: -1;
    transition: background .4s ease;
    animation: aurora-drift 22s ease-in-out infinite alternate;
}

@keyframes aurora-drift {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    50%  { transform: translate3d(-1.5%, 1.5%, 0) scale(1.05); }
    100% { transform: translate3d(1.5%, -1%, 0) scale(1); }
}


/* --- 4. LAYOUT PRINCIPAL --- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    height: 60px;
    background-color: var(--glass-bg-strong);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border-bottom: 1px solid var(--bs-border-color);
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 1030;
    transition: background-color var(--transition-base), border-color var(--transition-base);
}

.page-wrapper { display: flex; flex-grow: 1; }

/* --- Sidebar (apenas texto; toggle no header) --- */
:root {
    --sidebar-w: 220px;
}
[data-sidebar="hidden"]  .sidebar-custom { transform: translateX(-100%); }
[data-sidebar="hidden"]  .main-content   { padding-left: 0; }
[data-sidebar="visible"] .main-content   { padding-left: var(--sidebar-w); }

.sidebar-custom {
    position: fixed;
    left: 0;
    top: 60px;
    height: calc(100vh - 60px);
    width: var(--sidebar-w);
    background-color: var(--glass-bg-strong);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border-right: 1px solid var(--bs-border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 18px 12px;
    z-index: 1025;
    overflow: hidden;
    transition: transform var(--transition-base);
}

.main-content {
    flex-grow: 1;
    transition: padding-left var(--transition-base);
    display: flex;
    flex-direction: column;
}

.footer-custom {
    background-color: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--bs-border-color);
    padding: 1.5rem 0;
    margin-top: auto;
}


/* --- 5. COMPONENTES --- */

/* Header */
.header-content-left,
.header-content-right { display: flex; align-items: center; gap: 16px; }

.logo-image {
    height: 35px; width: auto;
    transition: transform var(--transition-base), filter var(--transition-base);
    filter: drop-shadow(0 0 6px transparent);
}
.logo-image:hover {
    transform: scale(1.06) rotate(-2deg);
    filter: drop-shadow(0 0 10px var(--primary-glow));
}

/* Botão de toggle do sidebar no header (sem ícone — três barras CSS-only) */
.header-icon-btn {
    background: none;
    border: 1px solid transparent;
    color: var(--bs-body-color);
    width: 40px; height: 40px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
}
.header-icon-btn:hover {
    color: var(--primary-color);
    background-color: rgba(113,197,201,.08);
    border-color: var(--bs-border-color);
}
.header-icon-bars {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 18px;
}
.header-icon-bars span {
    display: block;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform var(--transition-fast), opacity var(--transition-fast), width var(--transition-fast);
}
.header-icon-bars span:nth-child(1) { width: 100%; }
.header-icon-bars span:nth-child(2) { width: 70%; }
.header-icon-bars span:nth-child(3) { width: 100%; }
[data-sidebar="visible"] .header-icon-bars span:nth-child(2) { width: 100%; }

.header-user {
    color: var(--bs-tertiary-color);
    font-size: .9rem;
    font-weight: 500;
}

/* Inline SVG icons (Lucide-style) — substituem Font Awesome */
.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
}
.icon-2x { font-size: 2em; }
.icon-lg { font-size: 1.4em; }

/* Sidebar (texto puro) */
.sidebar-nav    { display: flex; flex-direction: column; gap: 2px; }
.sidebar-bottom { display: flex; flex-direction: column; gap: 2px; padding-top: 12px; border-top: 1px solid var(--bs-border-color); }

.sidebar-link {
    display: flex;
    align-items: center;
    height: 42px;
    padding: 0 14px;
    border-radius: 8px;
    color: var(--bs-tertiary-color);
    text-decoration: none;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    font-size: .92rem;
    font-weight: 500;
    letter-spacing: .005em;
    transition: color var(--transition-fast), background-color var(--transition-fast), padding-left var(--transition-fast);
}
.sidebar-link:hover {
    color: var(--bs-body-color);
    background-color: rgba(113, 197, 201, 0.08);
    padding-left: 18px;
}
.sidebar-link.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(113, 197, 201, .18) 0%, rgba(0, 76, 76, .22) 100%);
}
.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 20px;
    border-radius: 2px;
    background: var(--primary-color);
    box-shadow: 0 0 8px var(--primary-color);
}
.sidebar-link-muted { opacity: .75; }
.sidebar-link-muted:hover { opacity: 1; }


/* Cards */
.card-custom {
    background-color: var(--glass-bg-strong);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    border: 1px solid var(--bs-border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
    position: relative;
    overflow: hidden;
}
.card-custom::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
    opacity: 0;
    transition: opacity var(--transition-base);
}
.card-custom:hover::before { opacity: 1; }

.card-custom .card-header {
    background-color: var(--bs-secondary-bg);
    border-bottom: 1px solid var(--bs-border-color);
    color: var(--bs-primary);
    font-weight: 600;
}


/* Botões */
.btn {
    transition: all var(--transition-base);
}

.btn-primary-custom {
    background: linear-gradient(135deg, var(--primary-color) 0%, #5fb3b7 100%);
    color: var(--primary-dark);
    border: none;
    padding: 0.65rem 1.6rem;
    font-weight: 700;
    border-radius: 10px;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    z-index: 1;
}
.btn-primary-custom::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(135deg, #5fb3b7 0%, var(--primary-color) 100%);
    opacity: 0;
    transition: opacity var(--transition-base);
    z-index: -1;
}
.btn-primary-custom::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 0; height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
    transition: width .55s ease, height .55s ease, opacity .55s ease;
    opacity: 0;
    z-index: -1;
}
.btn-primary-custom:hover {
    color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 10px 24px var(--primary-glow);
}
.btn-primary-custom:hover::before { opacity: 1; }
.btn-primary-custom:active { transform: translateY(0); }
.btn-primary-custom:active::after {
    width: 280px; height: 280px; opacity: 1;
    transition: 0s;
}

/* Hover lift genérico para botões outline */
.btn-outline-secondary,
.btn-outline-danger,
.btn-outline-primary {
    transition: all var(--transition-base);
}
.btn-outline-secondary:hover,
.btn-outline-danger:hover,
.btn-outline-primary:hover {
    transform: translateY(-1px);
}


/* Forms */
.form-control-custom,
.form-select.form-control-custom {
    background-color: var(--bs-secondary-bg);
    border: 1px solid var(--bs-border-color);
    color: var(--bs-body-color);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    transition: all var(--transition-base);
}
.form-control-custom:focus,
.form-select.form-control-custom:focus {
    background-color: var(--bs-secondary-bg);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--primary-glow);
    color: var(--bs-body-color);
}


/* Tabelas */
.table-custom { background-color: transparent; --bs-table-bg: transparent; }
.table-custom th {
    border-bottom: 2px solid var(--bs-border-color);
    color: var(--bs-primary);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
}
.table-custom td { border-top: 1px solid var(--bs-border-color); }
.table-custom tbody tr {
    transition: background-color var(--transition-fast), transform var(--transition-fast);
}
.table-custom tbody tr:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.06);
}


/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary-color), var(--primary-dark));
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #5fb3b7, var(--primary-dark));
    background-clip: padding-box;
}


/* --- 6. PÁGINA DE CHAT --- */
.chat-page .main-content { padding: 0 !important; height: calc(100vh - 60px); }
.chat-page .footer-custom { display: none; }
.chat-container { display: flex; flex-direction: column; height: 100%; width: 100%; max-width: 900px; margin: 0 auto; }
.chat-header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--bs-border-color); background-color: var(--glass-bg-strong); }
.message-text-ai { background-color: var(--bs-secondary-bg); color: var(--bs-body-color); border-top-left-radius: 0.25rem; }
.message-text-user { background-color: var(--bs-primary); color: var(--primary-dark); font-weight: 500; border-top-right-radius: 0.25rem; }
.chat-input-container { padding: 1rem 1.5rem; background-color: var(--glass-bg-strong); border-top: 1px solid var(--bs-border-color); }
#message-input { background-color: var(--bs-secondary-bg); border: 1px solid var(--bs-border-color); color: var(--bs-body-color); }
#message-input:focus { border-color: var(--bs-primary); box-shadow: 0 0 0 3px var(--primary-glow); }
#send-button { background-color: var(--bs-primary); color: var(--primary-dark); }
.chat-messages { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }
.message-row { display: flex; animation: fadeInUp .45s var(--ease-spring); }
.message-content { display: flex; flex-direction: column; max-width: 80%; }
.message-content.align-items-end { align-items: flex-end; }
.message-author { font-size: .8rem; color: var(--bs-primary); opacity: .9; margin-bottom: .25rem; padding: 0 .5rem; }
.message-text { padding: .8rem 1.2rem; border-radius: 1rem; font-size: .95rem; line-height: 1.6; word-wrap: break-word; }


/* --- 7. SELEÇÃO DE PACIENTES --- */
.patient-card {
    background-color: var(--glass-bg);
    backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    border: 1px solid var(--bs-border-color);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}
.patient-card::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: conic-gradient(from var(--angle, 0deg),
        transparent 0deg, var(--primary-color) 90deg, transparent 180deg);
    opacity: 0;
    z-index: -1;
    transition: opacity var(--transition-base);
    animation: rotate-gradient 4s linear infinite;
}
.patient-card:hover {
    background-color: var(--bs-secondary-bg);
    border-color: var(--primary-color);
    transform: translateY(-8px) scale(1.015);
    box-shadow: 0 20px 40px rgba(0,0,0,.18), 0 0 30px var(--primary-glow);
}
.patient-name { color: var(--bs-body-color); transition: color var(--transition-base); }
.patient-card:hover .patient-name { color: var(--primary-color); }

.patients-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.75rem; }

.patient-avatar {
    width: 120px; height: 120px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 1.25rem;
    border: 3px solid var(--bs-border-color);
    transition: all var(--transition-base);
    position: relative;
}
.patient-card:hover .patient-avatar {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 6px rgba(var(--bs-primary-rgb), 0.15), 0 8px 20px var(--primary-glow);
    transform: scale(1.04);
}

@property --angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}
@keyframes rotate-gradient {
    to { --angle: 360deg; }
}


/* --- 8. ANIMAÇÕES UTILITÁRIAS --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes scaleUp {
    from { transform: scale(.92); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 var(--primary-glow); }
    50%      { box-shadow: 0 0 0 12px transparent; }
}
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-fade-in-up { animation: fadeInUp .6s ease-out forwards; opacity: 0; }
.animate-fade-in    { animation: fadeIn .8s ease-out forwards; opacity: 0; }
.animate-scale-up   { animation: scaleUp .6s var(--ease-spring) forwards; opacity: 0; }
.animate-float      { animation: float 3s ease-in-out infinite; }

/* Stagger pelos data attrs */
[data-stagger] { animation: fadeInUp .55s var(--ease-spring) backwards; }
[data-stagger="1"]  { animation-delay: .05s; }
[data-stagger="2"]  { animation-delay: .10s; }
[data-stagger="3"]  { animation-delay: .15s; }
[data-stagger="4"]  { animation-delay: .20s; }
[data-stagger="5"]  { animation-delay: .25s; }
[data-stagger="6"]  { animation-delay: .30s; }
[data-stagger="7"]  { animation-delay: .35s; }
[data-stagger="8"]  { animation-delay: .40s; }


/* Reveal on scroll (controlado por IntersectionObserver no JS) */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity .7s ease, transform .7s var(--ease-spring);
    will-change: opacity, transform;
}
.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}


/* Sidebar overlay (mobile, quando visible) */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
}
@media (max-width: 991.98px) {
    [data-sidebar="visible"] .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }
}


/* --- 9. RESPONSIVIDADE --- */
@media (max-width: 991.98px) {
    /* Em mobile o sidebar é sempre drawer; main ocupa 100% */
    .main-content { padding-left: 0 !important; }
    .sidebar-custom {
        z-index: 1040;
        box-shadow: 8px 0 24px rgba(0,0,0,.35);
        transform: translateX(-100%);
    }
    [data-sidebar="visible"] .sidebar-custom { transform: translateX(0); }

    .table-responsive-cards table,
    .table-responsive-cards thead,
    .table-responsive-cards tbody,
    .table-responsive-cards th,
    .table-responsive-cards td,
    .table-responsive-cards tr { display: block; }

    .table-responsive-cards thead tr {
        position: absolute; top: -9999px; left: -9999px;
    }
    .table-responsive-cards tr {
        border: 1px solid var(--bs-border-color);
        border-radius: 12px;
        margin-bottom: 1rem;
        background-color: var(--glass-bg);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    .table-responsive-cards td {
        border: none;
        border-bottom: 1px solid var(--bs-border-color);
        position: relative;
        padding-left: 50%;
        text-align: right;
    }
    .table-responsive-cards tr:last-child td:last-child { border-bottom: 0; }
    .table-responsive-cards td:before {
        position: absolute; top: 50%; left: 1rem;
        width: 45%; padding-right: 10px;
        white-space: nowrap; text-align: left; font-weight: bold;
        transform: translateY(-50%);
        color: var(--bs-primary);
    }
    .table-responsive-cards td:nth-of-type(1):before { content: "Caso Clínico"; }
    .table-responsive-cards td:nth-of-type(2):before { content: "Data"; }
    .table-responsive-cards td:nth-of-type(3):before { content: "Nota"; }
    .table-responsive-cards td:nth-of-type(4):before { content: "Feedback"; }

    .fila-table td:nth-of-type(1):before { content: "Aluno"; }
    .fila-table td:nth-of-type(2):before { content: "Caso Clínico"; }
    .fila-table td:nth-of-type(3):before { content: "Data"; }
    .fila-table td:nth-of-type(4):before { content: "Sessão Nº"; }
    .fila-table td:nth-of-type(5):before { content: "Ação"; }
}

@media (max-width: 575.98px) {
    .header { padding: 0 16px; }
    .chat-messages { padding: 1rem; }
    .message-content { max-width: 90%; }
    .patients-grid { grid-template-columns: 1fr 1fr; gap: 1rem; }
    .patient-card { padding: 1rem; }
    .patient-avatar { width: 80px; height: 80px; }
    .container, .container-fluid { padding-right: 1rem; padding-left: 1rem; }
}


/* --- 9.5. TRANSIÇÕES ENTRE PÁGINAS --- */
/* Browsers modernos (Chrome/Edge 126+): transição cross-document automática.
   Browsers sem suporte ignoram o @view-transition silenciosamente. */
@view-transition { navigation: auto; }

::view-transition-old(root) {
    animation: pt-fade-out .22s cubic-bezier(.4, 0, .2, 1) both;
}
::view-transition-new(root) {
    animation: pt-fade-in .38s cubic-bezier(.2, .7, .3, 1) both;
}

/* Mantém header e sidebar sem transição (parecem persistir). */
.header         { view-transition-name: shell-header; }
.sidebar-custom { view-transition-name: shell-sidebar; }
::view-transition-old(shell-header),
::view-transition-new(shell-header),
::view-transition-old(shell-sidebar),
::view-transition-new(shell-sidebar) {
    animation: none;
    mix-blend-mode: normal;
}

@keyframes pt-fade-out {
    to { opacity: 0; transform: translateY(-6px); }
}
@keyframes pt-fade-in {
    from { opacity: 0; transform: translateY(10px); }
}

/* Fallback p/ Safari, Firefox e Chrome <126: JS adiciona .pt-fallback no body */
body.pt-fallback { animation: pt-fade-in .4s cubic-bezier(.2, .7, .3, 1) both; }
body.pt-fallback.pt-leaving {
    animation: pt-fade-out .2s cubic-bezier(.4, 0, .2, 1) forwards;
    pointer-events: none;
}


/* --- 10. ACESSIBILIDADE --- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
    body::before { animation: none; }
}
