/* layout.css — grid, header, nav, fab, drawer */

/* ─── ESTRUTURA PRINCIPAL ─── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ─── HEADER FIXO ─── */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-lg);
  gap: var(--space-sm);
  z-index: 200;
  padding-top: env(safe-area-inset-top);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
}

.header-title {
  font-size: var(--fs-sub);
  font-weight: 500;
}

.header-subtitle {
  font-size: var(--fs-meta);
  color: var(--text3);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* Indicador de sync */
.sync-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-meta);
  color: var(--text3);
  padding: 6px 10px;
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background var(--t-base);
}
.sync-indicator:hover { background: var(--bg3); }

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sync-dot.online  { background: var(--green); }
.sync-dot.pending { background: var(--amber); animation: pulse 1.5s ease infinite; }
.sync-dot.offline { background: var(--text3); }
.sync-dot.syncing { background: var(--accent2); animation: pulse 0.8s ease infinite; }

.sync-icon { font-size: 16px; }
.sync-icon.spinning { animation: spin 1s linear infinite; display: inline-block; }

/* ─── CONTEÚDO PRINCIPAL ─── */
.main-content {
  flex: 1;
  padding-top: 56px;
  padding-bottom: calc(60px + env(safe-area-inset-bottom));
  overflow-y: auto;
  overflow-x: hidden;
}

.page {
  padding: var(--space-lg);
  max-width: 600px;
  margin: 0 auto;
}

/* ─── BOTTOM NAVIGATION (mobile) ─── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(60px + env(safe-area-inset-bottom));
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  transition: color var(--t-base);
  color: var(--text3);
  text-decoration: none;
  padding: 8px 0;
}

.nav-item:hover { color: var(--text2); }

.nav-item.active { color: var(--accent2); }

.nav-icon { font-size: 22px; line-height: 1; }

.nav-label {
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
}

/* ─── SIDE NAVIGATION (desktop) ─── */
@media (min-width: 768px) {
  #app { flex-direction: row; }

  .side-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 220px;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    padding-top: env(safe-area-inset-top);
    overflow-y: auto;
  }

  .side-nav-header {
    padding: var(--space-xl) var(--space-lg);
    border-bottom: 1px solid var(--border);
  }

  .side-nav-logo {
    font-size: var(--fs-sub);
    font-weight: 500;
  }

  .side-nav-items {
    flex: 1;
    padding: var(--space-md) var(--space-sm);
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .side-nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 10px var(--space-md);
    border-radius: var(--r-md);
    cursor: pointer;
    color: var(--text2);
    text-decoration: none;
    font-size: var(--fs-body);
    font-weight: 500;
    transition: background var(--t-base), color var(--t-base);
  }

  .side-nav-item:hover { background: var(--bg3); color: var(--text); }
  .side-nav-item.active { background: var(--accent-bg); color: var(--accent2); }

  .side-nav-item-icon { font-size: 18px; }

  .side-nav-footer {
    padding: var(--space-md) var(--space-sm);
    border-top: 1px solid var(--border);
  }

  .side-nav-drive-status {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--fs-meta);
    color: var(--text3);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
  }

  .bottom-nav { display: none; }

  .main-content {
    margin-left: 220px;
    padding-top: 56px;
    padding-bottom: var(--space-xl);
  }

  .app-header { left: 220px; }

  .fab {
    bottom: var(--space-xl);
  }

  #toast-container {
    bottom: var(--space-xl);
    left: calc(220px + 50%);
  }
}

/* ─── DRAWER MOBILE ─── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(280px, 80vw);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  z-index: 301;
  transform: translateX(-100%);
  transition: transform var(--t-slow) cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-top: env(safe-area-inset-top);
}

.drawer.open { transform: translateX(0); }

.drawer-header {
  padding: var(--space-xl) var(--space-lg) var(--space-lg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-nav {
  padding: var(--space-md) var(--space-sm);
  flex: 1;
}

.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 12px var(--space-md);
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--text2);
  text-decoration: none;
  font-size: var(--fs-body);
  font-weight: 500;
  transition: background var(--t-base), color var(--t-base);
}

.drawer-nav-item:hover { background: var(--bg3); color: var(--text); }
.drawer-nav-item.active { background: var(--accent-bg); color: var(--accent2); }

.drawer-nav-icon { font-size: 20px; }

.drawer-section-title {
  font-size: var(--fs-label);
  font-weight: 500;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-md) var(--space-md) var(--space-xs);
  margin-top: var(--space-sm);
}

.drawer-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--border);
}

/* ─── PAGE SECTIONS ─── */
.page-section {
  margin-bottom: var(--space-xl);
}

.section-gap {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* ─── MONTH NAVIGATION ─── */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
}

.month-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text2);
  transition: background var(--t-base), color var(--t-base);
}
.month-nav-btn:hover { background: var(--bg3); color: var(--text); }

.month-nav-title {
  font-size: var(--fs-sub);
  font-weight: 500;
  min-width: 140px;
  text-align: center;
}

/* ─── QUICK ACTIONS GRID ─── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

.quick-action-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  cursor: pointer;
  transition: background var(--t-base), border-color var(--t-base);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 500;
}

.quick-action-btn:hover { background: var(--bg4); border-color: var(--border2); }
.quick-action-btn:active { transform: scale(0.98); }

.quick-action-icon { font-size: 22px; }

/* ─── OFFLINE BANNER ─── */
.offline-banner {
  background: rgba(245,166,35,0.1);
  border: 1px solid rgba(245,166,35,0.2);
  color: var(--amber);
  text-align: center;
  padding: 8px;
  font-size: var(--fs-sm);
  font-weight: 500;
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  z-index: 190;
  transform: translateY(-100%);
  transition: transform var(--t-base);
}

.offline-banner.visible { transform: translateY(0); }

@media (min-width: 768px) {
  .offline-banner { left: 220px; }
}

/* ─── SCROLLABLE CONTENT ─── */
.scroll-x {
  overflow-x: auto;
  scrollbar-width: none;
}
.scroll-x::-webkit-scrollbar { display: none; }

/* ─── RESPONSIVE UTILS ─── */
@media (max-width: 767px) {
  .hide-mobile { display: none !important; }
  .side-nav { display: none; }
}

@media (min-width: 768px) {
  .hide-desktop { display: none !important; }
}
