/* ============================================
 * CSS BASE - Notas PWA
 * ============================================ */

/* CSS Variables - Theme Colors */
:root {
    --color-bg-global: #F5F5F7;
    --color-bg-container: #FFFFFF;
    --color-text-main: #1D1D1F;
    --color-text-muted: #6E6E73;
    --color-text-label: #86868B;
    --color-text-secondary: #64748b;
    --color-border: #DCE3ED;
    --color-neon-blue: #0071E3;
    --color-neon-green: #34C759;
    --color-neon-red: #FF3B30;
    --color-neon-purple: #AF52DE;
    --color-neon-orange: #FF9500;
}

/* Tema escuro: o CSS compilado do projeto original NAO redefine as variaveis
 * globais (--color-*) em [data-theme="dark"] — ele ajusta apenas componentes
 * especificos, e esses ajustes vivem em notes/editor.css (identico ao original).
 * Para manter a replica fiel ao compilado, as variaveis do tema claro tambem
 * valem no escuro. Ver docs/RELATORIO-PARIDADE.md. */

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Theme Transition */
html.theme-transition,
html.theme-transition * {
    transition: background-color 400ms ease, color 400ms ease, border-color 400ms ease !important;
}

/* Button Styles
 * As regras de .toolbar-btn vem do theme-origem.css (extraidas do CSS compilado
 * do projeto original). Nao redefinir aqui: width/height fixos causavam
 * divergencia de 2px e de border-radius em relacao ao original. */

/* Utility Classes */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-1 {
    flex: 1;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-end {
    justify-content: flex-end;
}

.gap-1 {
    gap: 4px;
}

.gap-2 {
    gap: 8px;
}

.gap-3 {
    gap: 12px;
}

.border-b {
    border-bottom: 1px solid var(--color-border);
}

.border-t {
    border-top: 1px solid var(--color-border);
}

.bg-bg-global {
    background-color: var(--color-bg-global);
}

.bg-bg-container {
    background-color: var(--color-bg-container);
}

.bg-neon-blue {
    background-color: var(--color-neon-blue);
}

.w-px {
    width: 1px;
}

.h-6 {
    height: 1.5rem;
}

.bg-border {
    background-color: var(--color-border);
}

.mx-1 {
    margin-left: 4px;
    margin-right: 4px;
}

.flex-wrap {
    flex-wrap: wrap;
}

.text-text-main {
    color: var(--color-text-main);
}

.text-text-muted {
    color: var(--color-text-muted);
}

.text-neon-blue {
    color: var(--color-neon-blue);
}

.text-sm {
    font-size: 14px;
}

.text-base {
    font-size: 16px;
}

.text-lg {
    font-size: 18px;
}

.font-semibold {
    font-weight: 600;
}

.tracking-tight {
    letter-spacing: -0.02em;
}

.min-h-screen {
    min-height: 100vh;
}

.overflow-x-hidden {
    overflow-x: hidden;
}

.overflow-auto {
    overflow: auto;
}

.select-none {
    user-select: none;
}

.select-text {
    user-select: text;
}

.relative {
    position: relative;
}

.absolute {
    position: absolute;
}

.w-full {
    width: 100%;
}

.h-full {
    height: 100%;
}

.px-4 {
    padding-left: 16px;
    padding-right: 16px;
}

.py-2 {
    padding-top: 8px;
    padding-bottom: 8px;
}

.py-3 {
    padding-top: 12px;
    padding-bottom: 12px;
}

.py-4 {
    padding-top: 16px;
    padding-bottom: 16px;
}

.rounded-full {
    border-radius: 9999px;
}

.rounded-none {
    border-radius: 0;
}

.shadow-none {
    box-shadow: none;
}

.transition-transform {
    transition: transform 300ms ease;
}

.transition-all {
    transition: all 200ms ease;
}

.shrink-0 {
    flex-shrink: 0;
}

/* Mobile-first adjustments */
@media (max-width: 768px) {
    .toolbar-btn svg {
        width: 18px;
        height: 18px;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* Focus visible styles */
:focus-visible {
    outline: 2px solid var(--color-neon-blue);
    outline-offset: 2px;
}

/* Glass effect for header */
.app-header {
    background: var(--color-bg-container);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Modal backdrop */
.notes-drawer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--color-bg-global);
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms ease, visibility 300ms ease;
}

.notes-drawer.active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

/* Notes modal */
.notes-modal {
    background: var(--color-bg-container);
    color: var(--color-text-main);
}

/* Notes toolbar */
.notes-toolbar {
    background: var(--color-bg-container);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    flex-shrink: 0;
}

/* Notes editor container */
.notes-editor-container {
    background: var(--color-bg-container);
}

/* O editor precisa ocupar toda a area do container.
   Sem isto o #notesEditor tem apenas a altura do proprio conteudo e, como
   notes/editor.css comprime linhas vazias para 8px, a area focavel/toque
   fica restrita a uma faixa de 8px no topo: tocar no resto da tela nao
   posiciona o cursor nem abre o teclado no celular. */
#notesEditor {
    min-height: 100%;
    outline: none;
    cursor: text;
}

/* Notes footer */
.notes-modal-footer {
    background: var(--color-bg-global);
}

/* Avisos (toasts) usados pelas ferramentas de inserção de notas */
.app-toast-region {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 5000;
    pointer-events: none;
    width: min(420px, calc(100vw - 32px));
}

.app-toast {
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--color-bg-container);
    color: var(--color-text-main);
    border: 1px solid var(--color-border);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    font-size: 14px;
    line-height: 1.4;
    animation: app-toast-in 220ms ease-out;
}

.app-toast.is-error {
    border-color: var(--color-neon-red);
    color: var(--color-neon-red);
}

@keyframes app-toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Visualizador de arquivos locais (imagens/PDF anexados) */
.notes-file-viewer .notes-local-file {
    display: block;
    width: 100%;
    max-height: 60vh;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    margin-bottom: 10px;
}

/* ============================================
 * PREFLIGHT ESSENCIAL (Tailwind v4)
 * Sem isto os controles herdam os valores do navegador (fonte Arial, tamanho
 * 13.33px, cor preta), divergindo do CSS compilado do projeto original.
 * ============================================ */
*, ::before, ::after, ::backdrop {
    box-sizing: border-box;
    border: 0 solid;
    margin: 0;
    padding: 0;
}

button, input, optgroup, select, textarea {
    font: inherit;
    color: inherit;
    letter-spacing: inherit;
    background: transparent;
}

button, [type="button"], [type="reset"], [type="submit"] {
    -webkit-appearance: button;
    appearance: button;
}

:disabled { cursor: not-allowed; }
ol, ul, menu { list-style: none; }
img, svg, video, canvas, audio, iframe, embed, object { display: block; vertical-align: middle; }

/* ============================================
 * UTILITÁRIOS TAILWIND USADOS PELO MODAL DE NOTAS
 * Transcritos do CSS compilado do projeto original (mesmos valores efetivos).
 * Os tokens (--spacing, --color-white, --leading-relaxed, --font-sans) vêm do
 * arquivo theme-origem.css, também extraído do compilado.
 * ============================================ */
.bg-white { background-color: var(--color-white); }
.border-2 { border-width: 2px; border-style: solid; }
.border-border { border-color: var(--color-border); }
.border-neon-blue { border-color: var(--color-neon-blue); }
.cursor-pointer { cursor: pointer; }
.duration-300 { transition-duration: 300ms; }
.font-sans { font-family: var(--font-sans); }
.h-10 { height: calc(var(--spacing) * 10); }
.w-10 { width: calc(var(--spacing) * 10); }
.justify-center { justify-content: center; }
.leading-relaxed { line-height: var(--leading-relaxed); }
.max-h-full { max-height: 100%; }
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.p-0 { padding: 0; }
.pb-4 { padding-bottom: calc(var(--spacing) * 4); }
.pt-4 { padding-top: calc(var(--spacing) * 4); }
.hover\:scale-105:hover { scale: 1.05; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: calc(var(--spacing) * 6); padding-right: calc(var(--spacing) * 6); }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.mt-0 { margin-top: 0; }
.mr-4 { margin-right: calc(var(--spacing) * 4); }
.rounded-none { border-radius: 0; }
.shadow-none { box-shadow: none; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.w-\[90\%\] { width: 90%; }
.max-w-\[600px\] { max-width: 600px; }
.h-\[70vh\] { height: 70vh; }
.max-h-\[70vh\] { max-height: 70vh; }
.rounded-\[20px\] { border-radius: 20px; }
.shadow-\[0_12px_32px_rgba\(0\,0\,0\,0\.12\)\] { box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12); }