/* ==========================================================================
   STYLE.CSS - Design System e Layout Base Móvel (PWA) MRS Logística S.A.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Dancing+Script:wght@700&display=swap');

:root {
  /* Paleta Corporativa MRS */
  --mrs-blue-primary: #002D62;
  --mrs-blue-dark: #001D40;
  --mrs-blue-light: #0D47A1;
  --mrs-yellow-accent: #FFCC00;
  --mrs-yellow-dark: #E6B800;
  --mrs-yellow-light: #FFF4CC;
  
  /* Cores de Estado e Sinalização Ferroviária */
  --state-green: #00875A;
  --state-green-light: #E3FCEF;
  --state-green-border: #ABF5D1;
  --state-red: #DE350B;
  --state-red-light: #FFEBE6;
  --state-amber: #D97706;
  --state-amber-light: #FEF3C7;

  /* Superfícies e Neutros */
  --bg-page: #F1F5F9;
  --bg-surface: #FFFFFF;
  --bg-card: #FFFFFF;
  --border-color: #CBD5E1;
  --border-subtle: #E2E8F0;
  
  /* Tipografia */
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --text-on-dark: #FFFFFF;

  /* Dimensões Móveis */
  --header-height: 64px;
  --bottom-nav-height: 64px;
  --border-radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 9999px;
  
  /* Sombras */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 45, 98, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 45, 98, 0.15);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: #0B192C;
  color: var(--text-primary);
  height: 100%;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: stretch;
  overflow: hidden;
  overscroll-behavior: none;
}

/* ==========================================================================
   Viewport Wrapper Móvel / PWA
   ========================================================================== */
#app-viewport-wrapper {
  width: 100%;
  max-width: 100%;
  display: flex;
  justify-content: center;
  align-items: stretch;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

.app-container {
  width: 100%;
  max-width: 480px;
  height: 100%;
  height: 100dvh;
  background-color: var(--bg-page);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

@media (max-width: 480px) {
  .app-container {
    max-width: 100%;
    box-shadow: none;
  }
}

/* ==========================================================================
   Cabeçalho Oficial MRS Logística S.A.
   ========================================================================== */
.mrs-app-header {
  position: relative;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--mrs-blue-primary);
  background-image: linear-gradient(90deg, rgba(0, 45, 98, 0.95) 0%, rgba(0, 45, 98, 0.88) 100%);
  color: #FFFFFF;
  border-bottom: 2px solid var(--mrs-yellow-accent);
  padding: 0 14px;
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  width: 100%;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-header-back {
  background: transparent;
  border: none;
  color: #FFFFFF;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

.btn-header-back:active {
  background-color: rgba(255, 255, 255, 0.2);
}

.header-brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-mrs-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
}

.header-titles {
  display: flex;
  flex-direction: column;
}

.header-main-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  color: #FFFFFF;
  letter-spacing: -0.2px;
}

.header-sub-title {
  font-size: 11px;
  font-weight: 500;
  color: #E2E8F0;
}

.header-right {
  display: flex;
  align-items: center;
}

.header-user-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-pill);
  padding: 4px 10px 4px 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #FFFFFF;
  cursor: pointer;
  transition: all 0.2s ease;
}

.header-user-btn:active {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(0.97);
}

.header-avatar {
  font-size: 18px;
  display: inline-block;
  line-height: 1;
}

.header-user-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.current-user-shortname {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
  color: #FFFFFF;
}

.current-user-role-badge {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--mrs-yellow-accent);
  text-transform: uppercase;
}

/* ==========================================================================
   Telas (App Screens) e Container de Scroll
   ========================================================================== */
.screen-scroll-container {
  flex: 1 1 0%;
  min-height: 0;
  height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 24px;
  background-color: var(--bg-page);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* Scrollbar sutil */
.screen-scroll-container::-webkit-scrollbar {
  width: 4px;
}
.screen-scroll-container::-webkit-scrollbar-track {
  background: transparent;
}
.screen-scroll-container::-webkit-scrollbar-thumb {
  background: rgba(0, 45, 98, 0.2);
  border-radius: 4px;
}

.app-screen {
  display: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  padding: 14px;
}

.app-screen.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Barra de Navegação Inferior Móvel (Bottom Navigation Bar)
   ========================================================================== */
.bottom-nav {
  position: relative;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background-color: var(--mrs-blue-primary);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.15);
  z-index: 45;
  flex-shrink: 0;
  width: 100%;
}

.bottom-nav-item {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.15s ease;
  position: relative;
}

.bottom-nav-item svg {
  width: 22px;
  height: 22px;
  margin-bottom: 2px;
  transition: transform 0.15s ease, stroke 0.15s ease;
}

.bottom-nav-item:active {
  background-color: rgba(255, 255, 255, 0.08);
}

.bottom-nav-item.active {
  color: #FFFFFF;
  font-weight: 700;
}

.bottom-nav-item.active svg {
  stroke: var(--mrs-yellow-accent);
  fill: var(--mrs-yellow-accent);
  transform: scale(1.1);
}

/* Botão Central de Nova Ficha Flutuante */
.bottom-nav-center-action {
  position: relative;
  top: -14px;
  background: var(--mrs-yellow-accent);
  color: var(--mrs-blue-dark);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--bg-page);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
  text-decoration: none;
  font-size: 9px;
  font-weight: 800;
}

.bottom-nav-center-action:active {
  transform: scale(0.94);
  background: #E6B800;
}

.bottom-nav-center-action svg {
  width: 22px;
  height: 22px;
  fill: var(--mrs-blue-dark);
  margin-bottom: 1px;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
#toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 420px;
}

.toast-message {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #FFFFFF;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  animation: slideDownToast 0.25s ease forwards;
  border-left: 5px solid var(--mrs-blue-primary);
}

.toast-success {
  border-left-color: var(--state-green);
}

.toast-warning {
  border-left-color: var(--mrs-yellow-accent);
}

.toast-error {
  border-left-color: var(--state-red);
}

.toast-message.fade-out {
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.2s ease;
}

@keyframes slideDownToast {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
