@font-face {
    font-family: 'Bowlby One';
    src: url('../assets/fonts/BowlbyOne-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

:root {
    --bg-pure: #ffffff;
    --bg-offwhite: #ffffff;
    --text-primary: #000000;
    --text-secondary: #737373;
    --action-blue: #000000;
    --action-blue-hover: #090909;
    --border-light: #e5e5e5;
    --hairline-strong: #d4d4d4;
    --alert-red: #ff5f56;
    --success-green: #27c93f;
    --nav-bg: #ffffff;
    --nav-text: #000000;
    --nav-active: #000000;
    --nav-inactive: #a3a3a3;
    
    --radius-card: 12px;
    --radius-pill: 9999px;
    --radius-btn: 9999px;
    
    --shadow-soft: none;
    --shadow-nav: none;
    --spacing-section: 88px;
}

:root.dark-mode {
    --bg-pure: #171717;
    --bg-offwhite: #171717;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --border-light: #38383a;
    --nav-bg: #171717;
    --shadow-soft: none;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-pure);
    color: var(--text-primary);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

/* Typography */
h1, h2, h3, h4 {
    font-family: 'SF Pro Rounded', Nunito, ui-sans-serif, system-ui, sans-serif;
    font-weight: 600;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 1.875rem; /* 30px display-lg */
    margin-bottom: 0.5rem;
    font-weight: 500;
}

p {
    line-height: 1.5;
}

.text-sm { font-size: 0.875rem; }
.text-gray { color: var(--text-secondary); }
.text-center { text-align: center; }

/* Layout Structure */
#app-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-offwhite);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 10;
}

.view.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    z-index: 1;
}

.hidden {
    display: none !important;
}

.content-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1rem 6rem 1rem; /* Extra padding bottom for nav */
}

/* Top Status Bar */
.top-status-bar {
    position: fixed;
    top: 0;
    width: 100%;
    background: var(--bg-pure);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
    z-index: 50;
    height: 30px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.status-indicator.online { background-color: var(--success-green); }
.status-indicator.offline { background-color: var(--alert-red); }

/* View Headers */
.view-header {
    margin-top: 30px; /* Offset for top-status-bar */
    padding: 1rem;
    background-color: var(--bg-offwhite);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 20;
}

/* Cards */
.card {
    background-color: var(--bg-pure);
    border-radius: var(--radius-card);
    border: 1px solid var(--border-light);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: none;
}

.greeting-card {
    margin-bottom: var(--spacing-section);
    padding: 0.5rem 0;
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    background-color: var(--bg-pure);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-pill);
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: 0.25rem;
}

/* Buttons */
button {
    cursor: pointer;
    border: none;
    outline: none;
    font-family: inherit;
    transition: all 0.2s ease;
}

.btn-primary, .btn-secondary, .btn-dashed {
    width: 100%;
    padding: 8px 20px;
    height: 36px;
    border-radius: var(--radius-btn);
    font-weight: 500;
    font-size: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.btn-primary {
    background-color: var(--text-primary);
    color: var(--bg-pure);
}
.btn-primary:active { background-color: var(--action-blue-hover); transform: scale(0.98); }

.btn-secondary {
    background-color: var(--bg-pure);
    color: var(--text-primary);
    border: 1px solid var(--hairline-strong);
}
.btn-secondary:active { background-color: #fafafa; transform: scale(0.98); }

.btn-dashed {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px dashed var(--border-light);
}

.btn-sm { padding: 4px 16px; font-size: 14px; height: 32px; }
.btn-text { background: none; color: var(--text-primary); font-size: 14px; margin-bottom: 1rem; text-decoration: underline; }

.icon-btn, .icon-btn-small {
    background: none;
    color: var(--action-blue);
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-btn { padding: 0.5rem; }
.icon-btn-small { padding: 0.25rem; }
.icon-btn:active { opacity: 0.7; }

/* Login */
.login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    background-color: var(--bg-pure);
}

.logo-area {
    text-align: center;
    margin-bottom: var(--spacing-section);
}
.logo-area h1 {
    font-size: 2.25rem; /* 36px display-xl */
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.input-group {
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-group input, .title-input, .date-input, select {
    width: 100%;
    padding: 8px 16px;
    height: 40px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-btn); /* 9999px from tokens */
    background-color: var(--bg-pure);
    font-size: 1rem;
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.input-group input:focus, .title-input:focus, .date-input:focus, select:focus {
    outline: none;
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.5); /* focus-ring */
    background-color: var(--bg-pure);
}

.login-form-wrapper {
    width: 100%;
    margin: 0 auto;
}

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background-color: var(--bg-pure);
    border-radius: var(--radius-card);
    border: 1px solid var(--border-light);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-icon { color: var(--action-blue); margin-bottom: 0.5rem; width: 24px; height: 24px; }
.stat-icon.alert { color: var(--alert-red); }
.stat-value { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.stat-value.alert { color: var(--alert-red); }
.stat-label { font-size: 0.75rem; color: var(--text-secondary); }

.chart-container {
    width: 100%;
    position: relative;
    height: 250px;
}

/* A4 Form Simulator */
.a4-sheet {
    background-color: var(--bg-pure);
    border: none;
    border-radius: 0;
    padding: 0;
    margin-bottom: var(--spacing-section);
    box-shadow: none;
    width: 100%;
}

.form-header-info {
    margin-bottom: var(--spacing-section);
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 1rem;
}

.title-input { font-size: 1.25rem; font-weight: 600; border: none; border-bottom: 1px solid var(--border-light); border-radius: 0; background: transparent; padding: 0.5rem 0; margin-bottom: 0.5rem; height: auto; }
.date-input { border: none; background: transparent; padding: 0.5rem 0; color: var(--text-secondary); height: auto; }

.form-block {
    background-color: transparent;
    border-radius: 0;
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 0;
    margin-bottom: 1rem;
    position: relative;
}

.form-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.form-block-title { font-size: 1rem; font-weight: 600; }
.btn-remove-block { color: var(--text-secondary); }

.auto-save-indicator { font-size: 0.75rem; color: var(--text-secondary); background: rgba(0,0,0,0.05); padding: 4px 8px; border-radius: 12px; }

/* Lists & Sync */
.item-list { list-style: none; }
.item-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-light);
}
.item-list li:last-child { border-bottom: none; }
.list-item-info h4 { font-size: 1rem; margin-bottom: 0.25rem; }

.qr-container { text-align: center; }
#qr-canvas { margin: 1.5rem auto; border-radius: 8px; }
.export-actions { display: flex; gap: 0.5rem; justify-content: center; }

/* Profile & Users */
.avatar-placeholder {
    width: 64px; height: 64px;
    background-color: var(--bg-offwhite);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1rem auto;
    color: var(--text-secondary);
}
.avatar-placeholder svg { width: 32px; height: 32px; }
.profile-card { text-align: center; }
.profile-actions { margin-top: 1.5rem; }

.filter-row { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.mt-10 { margin-top: 10px; }

/* Floating Bottom Navigation */
.floating-nav {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-pure);
    border: 1px solid var(--border-light);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    box-shadow: none;
    z-index: 100;
    width: 90%;
    max-width: 400px;
}

.floating-nav.hidden {
    display: none;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--nav-inactive);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

.nav-item svg { width: 24px; height: 24px; transition: transform 0.2s; }
.nav-item.active { color: var(--nav-active); }
.nav-item.active svg { transform: scale(1.15); stroke-width: 2.5px; }

/* Modal */
.modal-backdrop {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    z-index: 1000; opacity: 1; transition: opacity 0.3s;
}
.modal-backdrop.hidden { opacity: 0; pointer-events: none; }

.modal {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: var(--bg-pure);
    border-radius: var(--radius-card);
    border: 1px solid var(--border-light);
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    box-shadow: none;
    z-index: 1001;
    opacity: 1; transition: all 0.3s;
}
.modal.hidden { opacity: 0; transform: translate(-50%, -40%); pointer-events: none; }
.modal-actions { margin-top: 1.5rem; }

/* Responsive Adjustments (Tela Livre) */
@media (min-width: 768px) {
    .content-scrollable { max-width: 100%; padding: 2rem; }
    
    .login-container { 
        justify-content: center; 
        align-items: center;
        background-color: var(--bg-pure); 
    }
    .login-form-wrapper {
        max-width: 80%; /* Expandido, mas sem esticar aos cantos em 4k */
    }
    .logo-area h1 { font-size: 4rem; }
    .input-group input { padding: 1.25rem; font-size: 1.25rem; }
    .btn-primary { padding: 1.25rem; font-size: 1.25rem; }

    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
    
    .form-block { 
        display: grid; 
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
        gap: 1.5rem; 
        align-items: end; 
    }
    .form-block-header { grid-column: 1 / -1; }
    .floating-nav { max-width: 800px; padding: 16px 32px; }
    .nav-item svg { width: 28px; height: 28px; }
}

@media (min-width: 1024px) {
    .form-scrollable { display: flex; flex-direction: column; width: 100%; }
    .a4-sheet { max-width: 100%; width: 100%; box-shadow: none; border: none; padding: 2rem; margin-top: 0; background: transparent; }
    .form-actions-bottom { max-width: 100%; margin: 0 auto; padding: 0 2rem; }
}
