/* css/app.css */

/* ---------- Reset & Estrutura Base -------------------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--rodin-paper);
  color: var(--rodin-ink);
  overflow-x: hidden;
}

/* Scrollbar sutil */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--rodin-paper);
}
::-webkit-scrollbar-thumb {
  background: var(--rodin-concrete);
  border-radius: var(--radius-pill);
}

/* Layout Geral */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar (Navegação Principal) ------------------------ */
.sidebar {
  width: 260px;
  background-color: var(--rodin-graphite);
  color: var(--rodin-white);
  padding: var(--space-5) var(--space-4);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform var(--dur) var(--ease-out);
  border-right: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand {
  margin-bottom: var(--space-7);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: var(--space-4);
}

/* Toggle de Recolher/Expandir Sidebar (Desktop) */
body.sidebar-collapsed #app-sidebar {
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

body.sidebar-collapsed .main-content {
  margin-left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  transition: margin-left 0.3s cubic-bezier(0.16, 1, 0.3, 1), width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-collapse-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--rodin-white);
  border-radius: var(--radius-1);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-right: var(--space-3);
  transition: background 0.2s ease;
}

.sidebar-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.sidebar-collapse-btn i {
  width: 18px;
  height: 18px;
  stroke: var(--rodin-white);
}

.menu-toggle-btn {
  background: var(--rodin-white);
  border: 1px solid var(--rodin-line);
  color: var(--rodin-graphite);
  border-radius: var(--radius-1);
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  margin-right: var(--space-3);
  transition: all 0.2s ease;
}

.menu-toggle-btn:hover {
  background: var(--rodin-paper);
  border-color: var(--rodin-orange);
  color: var(--rodin-orange);
}

.menu-toggle-btn i {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.sidebar-logo {
  max-height: 52px;
  max-width: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex-grow: 1;
}

.sidebar-item a,
.sidebar-item a:focus,
.sidebar-item a:focus-visible,
.sidebar-item a:active {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 14px;
  color: var(--rodin-beige);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: var(--radius-1);
  box-sizing: border-box;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  outline: none !important;
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.sidebar-item a i,
.sidebar-item a svg {
  width: 18px;
  height: 18px;
  stroke: var(--rodin-beige);
  stroke-width: 1.8px;
  flex-shrink: 0;
  transition: stroke var(--dur-fast) var(--ease-out);
}

.sidebar-item.active a {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--rodin-orange);
  box-shadow: inset 3px 0 0 var(--rodin-orange) !important;
}

.sidebar-item a:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--rodin-orange);
}

.sidebar-item.active a i,
.sidebar-item.active a svg,
.sidebar-item a:hover i,
.sidebar-item a:hover svg {
  stroke: var(--rodin-orange);
}

.sidebar-user {
  padding-top: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
}

.sidebar-user-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-small);
  text-transform: uppercase;
  color: var(--rodin-white);
}

.sidebar-user-role {
  font-size: var(--fs-eyebrow);
  color: var(--rodin-cool-gray);
  text-transform: uppercase;
  margin-top: 2px;
}

/* ---------- Header Mobile ---------------------------------------- */
.mobile-header {
  display: none;
  height: 64px;
  background-color: var(--rodin-graphite);
  color: var(--rodin-white);
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 110;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.menu-toggle {
  background: none;
  border: none;
  color: var(--rodin-white);
  cursor: pointer;
  padding: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu-toggle i {
  width: 24px;
  height: 24px;
  stroke: var(--rodin-white);
  stroke-width: 1.8px;
}

/* ---------- Main Content Area ------------------------------------ */
.main-content {
  flex-grow: 1;
  margin-left: 260px;
  width: calc(100% - 260px);
  max-width: calc(100% - 260px);
  box-sizing: border-box;
  overflow-x: hidden;
  padding: var(--space-6) var(--space-6) var(--space-8) var(--space-6);
  min-height: 100vh;
  transition: padding var(--dur) var(--ease-out);
}

.page-header {
  margin-bottom: var(--space-6);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--space-4);
  border-bottom: 1px solid var(--rodin-line);
  padding-bottom: var(--space-4);
}

.page-title-container {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.page-title-divider {
  width: 3px;
  height: 28px;
  background-color: var(--rodin-orange);
}

.page-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-h3);
  text-transform: uppercase;
  letter-spacing: var(--tracking-tight);
}

.page-subtitle {
  font-family: var(--font-script);
  font-size: 24px;
  color: var(--rodin-orange);
  margin-top: -6px;
}

/* ---------- Dashboard Filter Bar -------------------------------- */
.filter-bar {
  background: var(--rodin-white);
  padding: var(--space-4);
  border: 1px solid var(--rodin-line);
  border-radius: var(--radius-1);
  margin-bottom: var(--space-5);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  box-shadow: var(--shadow-1);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.filter-group label {
  font-size: var(--fs-eyebrow);
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  color: var(--rodin-graphite);
  letter-spacing: var(--tracking-eyebrow);
}

.form-select, .form-input, .form-textarea {
  width: 100%;
  padding: 10px var(--space-3);
  border: 1px solid var(--rodin-concrete);
  background-color: var(--rodin-white);
  color: var(--rodin-ink);
  font-family: var(--font-body);
  font-size: var(--fs-small);
  border-radius: var(--radius-2);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  outline: none;
}

.form-select:focus, .form-input:focus, .form-textarea:focus {
  border-color: var(--rodin-orange);
  box-shadow: 0 0 0 3px rgba(244, 82, 6, 0.16);
}

/* ---------- Grid de Cards do Dashboard -------------------------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.dashboard-card {
  background: var(--rodin-white);
  border: 1px solid var(--rodin-line);
  border-radius: var(--radius-1);
  padding: var(--space-5);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  position: relative;
}

.dashboard-card-label {
  font-size: var(--fs-eyebrow);
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  color: var(--rodin-cool-gray);
  letter-spacing: var(--tracking-eyebrow);
  margin-bottom: var(--space-2);
}

.dashboard-card-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.2rem, 1.7vw, 1.65rem);
  color: var(--rodin-graphite);
  line-height: var(--lh-tight);
  white-space: nowrap;
  word-break: keep-all;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.dashboard-card-comparison {
  font-size: 11px;
  color: var(--rodin-cool-gray);
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  gap: 4px;
}

.dashboard-card-comparison.comp-up {
  color: #c5400b; /* Aumentou gastos - alerta laranja escuro */
}

.dashboard-card-comparison.comp-down {
  color: #2e7d32; /* Economia - verde */
}

/* ---------- Layout de Gráficos --------------------------------- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-6);
  min-width: 0;
  width: 100%;
}

.chart-card {
  background: var(--rodin-white);
  border: 1px solid var(--rodin-line);
  border-radius: var(--radius-1);
  padding: var(--space-5);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  height: 340px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.chart-container {
  position: relative;
  flex-grow: 1;
  height: calc(100% - 30px);
  min-width: 0;
  width: 100%;
  overflow: hidden;
}

.chart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--rodin-cool-gray);
  text-align: center;
}

/* ---------- Botões ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 12px var(--space-5);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-small);
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow);
  border: none;
  cursor: pointer;
  border-radius: var(--radius-pill); /* Pill como manda o design */
  transition: all var(--dur) var(--ease-out);
  text-decoration: none;
}

.btn-primary {
  background-color: var(--rodin-orange);
  color: var(--rodin-white);
}

.btn-primary:hover {
  background-color: var(--rodin-orange-080);
  text-decoration: underline;
}

.btn-primary:active {
  background-color: var(--rodin-orange-press);
}

.btn-secondary {
  background-color: var(--rodin-graphite);
  color: var(--rodin-white);
}

.btn-secondary:hover {
  background-color: var(--rodin-graphite-080);
  text-decoration: underline;
}

.btn-success {
  background-color: #2e7d32;
  color: var(--rodin-white);
}

.btn-success:hover {
  background-color: #1b5e20;
  text-decoration: underline;
}

.btn-danger {
  background-color: #d32f2f;
  color: var(--rodin-white);
}

.btn-danger:hover {
  background-color: #c62828;
  text-decoration: underline;
}

.btn-ghost {
  background-color: transparent;
  border: 1.5px solid var(--rodin-ink);
  color: var(--rodin-ink);
}

.btn-ghost:hover {
  background-color: rgba(31, 34, 34, 0.05);
  text-decoration: underline;
}

.btn-sm {
  padding: 6px var(--space-3);
  font-size: 10px;
}

/* ---------- Tabelas e Listas de Dados --------------------------- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--rodin-line);
  background: var(--rodin-white);
  border-radius: var(--radius-1);
  box-shadow: var(--shadow-1);
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th, .table td {
  padding: var(--space-4) var(--space-5);
  font-size: var(--fs-small);
  border-bottom: 1px solid var(--rodin-line);
  vertical-align: middle;
}

.table th {
  background-color: #fcfbf9;
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  color: var(--rodin-graphite);
  letter-spacing: var(--tracking-eyebrow);
  font-size: 11px;
}

.table tbody tr:hover {
  background-color: #faf9f6;
}

.table-actions {
  white-space: nowrap;
}

.table-actions .btn {
  display: inline-flex;
  margin-right: var(--space-2);
}

.table-actions .btn:last-child {
  margin-right: 0;
}

/* ---------- Badges / Status ------------------------------------- */
.badge {
  display: inline-flex;
  padding: 4px var(--space-2);
  font-size: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-1);
  background-color: var(--rodin-beige);
  color: var(--rodin-graphite);
}

.badge-success {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.badge-danger {
  background-color: #ffebee;
  color: #c62828;
}

.badge-warning {
  background-color: #fff3e0;
  color: #ef6c00;
}

.badge-accent {
  background-color: #fbeee6;
  color: var(--rodin-orange);
}

.badge-sm {
  font-size: 9px;
  padding: 2px 6px;
}

/* ---------- Guias/Abas (Tabs) ----------------------------------- */
.approvals-tabs {
  display: flex;
  border-bottom: 2px solid var(--rodin-line);
  margin-bottom: var(--space-5);
  gap: var(--space-2);
}

.tab-btn {
  background: none;
  border: none;
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-small);
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow);
  color: var(--rodin-cool-gray);
  cursor: pointer;
  position: relative;
  transition: color var(--dur) var(--ease-out);
}

.tab-btn:hover {
  color: var(--rodin-graphite);
}

.tab-btn.active {
  color: var(--rodin-orange);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--rodin-orange);
}

/* ---------- Aba 3 (Tipagem) Escopo Cards ------------------------- */
.escopo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}

.escopo-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.escopo-card {
  background: var(--rodin-white);
  border: 1px solid var(--rodin-line);
  border-left: 4px solid var(--rodin-cool-gray);
  padding: var(--space-4);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  transition: transform var(--dur) var(--ease-out);
  position: relative;
}

.escopo-card.status-pendente {
  border-left-color: var(--rodin-orange);
}

.escopo-card.status-aprovado {
  border-left-color: #2e7d32;
}

.escopo-card.status-recusado {
  border-left-color: #d32f2f;
}

.escopo-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.pedido-id {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-small);
  color: var(--rodin-cool-gray);
}

.pedido-status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background-color: var(--rodin-cool-gray);
}

.status-pendente .pedido-status-dot { background-color: var(--rodin-orange); }
.status-aprovado .pedido-status-dot { background-color: #2e7d32; }
.status-recusado .pedido-status-dot { background-color: #d32f2f; }

.escopo-card-details {
  background: #fbfbf9;
  padding: var(--space-3);
  margin-top: var(--space-3);
  font-size: var(--fs-small);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.escopo-card-details div {
  display: flex;
  justify-content: space-between;
}

.escopo-card-details span {
  color: var(--rodin-cool-gray);
}

/* ---------- Modais (Overlays) ------------------------------------ */
.modal-overlay {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(31, 34, 34, 0.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease-out);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background-color: var(--rodin-white);
  border-radius: var(--radius-1);
  border: 1px solid var(--rodin-line);
  box-shadow: var(--shadow-3);
  width: 90%;
  max-width: 500px;
  padding: var(--space-6);
  transform: translateY(20px);
  transition: transform var(--dur) var(--ease-out);
}

.modal-overlay.active .modal-box {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-5);
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-h4);
  text-transform: uppercase;
  letter-spacing: var(--tracking-tight);
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--rodin-cool-gray);
}

.modal-close i {
  width: 20px;
  height: 20px;
  stroke: var(--rodin-cool-gray);
}

.modal-footer {
  margin-top: var(--space-6);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

.justificativa-nota {
  margin-top: 6px;
  padding: var(--space-2);
  background-color: #fff8f8;
  border-left: 2px solid #d32f2f;
  color: #c62828;
}

/* ---------- Tela de Login ---------------------------------------- */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background-color: var(--rodin-paper);
}

.login-card {
  background-color: var(--rodin-white);
  border: 1px solid var(--rodin-line);
  border-radius: var(--radius-1);
  box-shadow: var(--shadow-2);
  width: 100%;
  max-width: 400px;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-logo {
  height: 60px;
  margin-bottom: var(--space-6);
}

.login-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-h4);
  text-transform: uppercase;
  letter-spacing: var(--tracking-tight);
  text-align: center;
  margin-bottom: var(--space-5);
}

.form-group {
  width: 100%;
  margin-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: var(--fs-eyebrow);
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow);
  color: var(--rodin-graphite);
}

/* ---------- Responsividade Completa e Fluida ------------------------ */

/* Ajustes gerais de tabelas e containers para touch */
.table-responsive,
.table-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-1);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table-responsive .table {
  min-width: 650px;
}

.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

td .btn, td button {
  white-space: nowrap;
}

.modal-content {
  width: 92%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-5);
  border-radius: var(--radius-1);
}

.approvals-tabs {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.tab-btn {
  white-space: nowrap;
}

/* Breakpoint: Notebooks / Monitores Intermediários com Sidebar Aberta (1366px e abaixo) */
@media (max-width: 1366px) {
  .charts-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
  }

  .filter-group {
    flex: 1 1 200px;
  }
}

/* Breakpoint: Desktop Pequeno / Tablet (1024px e abaixo) */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }
  
  .sidebar.mobile-active {
    transform: translateX(0);
  }
  
  .mobile-header {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99;
  }
  
  .main-content {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: calc(64px + var(--space-4)) var(--space-4) var(--space-5) var(--space-4);
  }
  
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  .escopo-grid {
    grid-template-columns: 1fr;
  }
}

/* Breakpoint: Tablet e Celulares Grandes (768px e abaixo) */
@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .filter-bar {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }
  
  .page-header .btn,
  .page-header div button {
    width: 100%;
    justify-content: center;
  }

  .login-card {
    padding: var(--space-4);
  }

  /* Ajustar grids de 2 colunas nos formulários de modais para 1 coluna no mobile */
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* Breakpoint: Celulares Pequenos (480px e abaixo) */
@media (max-width: 480px) {
  body {
    font-size: 14px;
  }

  .form-input, .btn, select {
    font-size: 16px !important; /* Previne auto-zoom no iOS ao focar nos campos */
  }

  .login-screen {
    padding: var(--space-3);
  }

  .login-card {
    padding: var(--space-4) var(--space-3);
  }

  .modal-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }
}
