/* ========================================= */
/* FINANCEHUB - DARK MODE PROFISSIONAL       */
/* ========================================= */

:root {
  --bg: #0f172a;
  --bg-secondary: #1a2332;
  --surface: #111827;
  --surface-2: #1f2937;
  --border: #2d3e52;
  --text: #f0f1f3;
  --text-muted: #9ca3af;
  --green: #22c55e;
  --green-dark: #16a34a;
  --red: #ef4444;
  --blue: #3b82f6;
  --yellow: #f59e0b;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --radius: 16px;
}

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

html, body {
  height: 100vh;
  width: 100vw;
  max-width: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg-secondary) 100%);
  color: var(--text);
  overflow-x: hidden;
}

/* ========================================= */
/* LAYOUT PRINCIPAL                          */
/* ========================================= */

.app {
  min-height: 100vh;
  position: relative;
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 0;
  width: 100%;
  overflow: hidden;
}

/* ========================================= */
/* SIDEBAR                                   */
/* ========================================= */

.sidebar {
  background: rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(10px);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  padding: 28px 20px;
  position: fixed;
  left: 0;
  top: 0;
  width: 250px;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}

.logo-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--green) 0%, #16a34a 100%);
  font-size: 24px;
  box-shadow: 0 8px 20px rgba(34, 197, 94, 0.3);
}

.logo h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--green), #86efac);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  font-family: inherit;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.nav-item.active {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
  border-left: 3px solid var(--green);
  padding-left: 11px;
}

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

.nav-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
  padding: 0 14px 8px;
}

.badge-new {
  display: inline-block;
  background: var(--green);
  color: #000;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 6px;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-ghost, .btn-danger-ghost {
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-ghost:hover {
  border-color: var(--green);
  color: var(--green);
  background: rgba(34, 197, 94, 0.1);
}

.btn-danger-ghost:hover {
  border-color: var(--red);
  color: var(--red);
  background: rgba(239, 68, 68, 0.1);
}

/* ========================================= */
/* MAIN CONTENT                              */
/* ========================================= */

.main {
  margin-left: 250px;
  padding: 32px 36px;
  width: calc(100vw - 250px);
  max-width: calc(100vw - 250px);
  min-width: 0;
  position: relative;
  z-index: 1;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 32px;
}

.header h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 6px;
}

.filters {
  display: flex;
  gap: 12px;
  align-items: center;
}

select {
  background: rgba(17, 24, 39, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}

select:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.btn-atualizar {
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--green), #34d399);
  border: 0;
  border-radius: 10px;
  color: #000;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-atualizar:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(34, 197, 94, 0.3);
}

/* ========================================= */
/* PAGES                                     */
/* ========================================= */

.page {
  display: none;
  animation: fadeIn 0.3s ease;
  width: 100%;
  min-width: 0;
}

.page.active {
  display: block;
  width: 100%;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================= */
/* CARDS DE MÉTRICA                          */
/* ========================================= */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
  width: 100%;
  min-width: 0;
}

.card {
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--green), transparent);
}

.card:hover {
  border-color: rgba(34, 197, 94, 0.3);
  box-shadow: 0 8px 24px rgba(34, 197, 94, 0.15);
  transform: translateY(-4px);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(34, 197, 94, 0.15);
  font-size: 22px;
}

.card-revenue .card-icon {
  background: rgba(34, 197, 94, 0.15);
}

.card-expense .card-icon {
  background: rgba(239, 68, 68, 0.15);
}

.card-profit .card-icon {
  background: rgba(59, 130, 246, 0.15);
}

.card-clients .card-icon {
  background: rgba(245, 158, 11, 0.15);
}

.card-title {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card h3 {
  font-size: 32px;
  font-weight: 700;
  margin: 12px 0 8px;
  background: linear-gradient(135deg, var(--green), #86efac);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
}

.card-revenue h3 {
  background: linear-gradient(135deg, var(--green), #86efac);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.card-expense h3 {
  background: linear-gradient(135deg, var(--red), #fca5a5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.card-profit h3 {
  background: linear-gradient(135deg, var(--blue), #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.card-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
  font-weight: 600;
}

/* ========================================= */
/* GRÁFICOS                                  */
/* ========================================= */

.charts-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 20px;
  margin-bottom: 32px;
  width: 100%;
  min-width: 0;
}

.chart-card {
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  min-width: 0;
}

.chart-card h4 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

.chart-card canvas {
  max-height: 300px;
  width: 100% !important;
  height: auto !important;
}

/* ========================================= */
/* FORMULÁRIOS                               */
/* ========================================= */

.form-card, .list-card {
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  width: 100%;
  min-width: 0;
}

.form-card h3, .list-card h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
  width: 100%;
  min-width: 0;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.form-group label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group select {
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s ease;
  width: 100%;
  min-width: 0;
}

.form-group input::placeholder,
.form-group select {
  color: var(--text-muted);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.btn-primary, .btn-danger {
  width: 100%;
  padding: 14px 20px;
  border: 0;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  color: #fff;
}

.btn-primary {
  background: linear-gradient(135deg, var(--green), #34d399);
  color: #000;
  font-weight: 700;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(34, 197, 94, 0.3);
}

.btn-danger {
  background: linear-gradient(135deg, var(--red), #f87171);
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
}

/* ========================================= */
/* TABELAS E LISTAS                          */
/* ========================================= */

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  width: 100%;
  min-width: 0;
  flex-wrap: wrap;
}

.list-header input,
.list-header select {
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  min-width: 240px;
}

.list-header input:focus,
.list-header select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.table-wrapper {
  overflow-x: auto;
  width: 100%;
  min-width: 0;
}

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

thead th {
  padding: 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

tbody td {
  padding: 14px;
  font-size: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

tbody tr:hover {
  background: rgba(34, 197, 94, 0.05);
}

.badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.badge-success {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

.badge-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.value-green {
  color: var(--green);
  font-weight: 600;
}

.value-red {
  color: var(--red);
  font-weight: 600;
}

.action-btn {
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
  font-family: inherit;
}

.action-btn:hover {
  background: rgba(239, 68, 68, 0.3);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

/* ========================================= */
/* NOTIFICAÇÕES                              */
/* ========================================= */

#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease;
  min-width: 280px;
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.1);
  color: #86efac;
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(400px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ========================================= */
/* INTEGRATIONS PAGE                        */
/* ========================================= */

.integrations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  margin-top: 24px;
  width: 100%;
  min-width: 0;
}

.integration-card {
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 28px;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.integration-card:hover {
  border-color: rgba(34, 197, 94, 0.3);
  box-shadow: 0 8px 24px rgba(34, 197, 94, 0.15);
}

.integration-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.integration-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(34, 197, 94, 0.1));
  font-size: 28px;
}

.integration-title {
  flex: 1;
}

.integration-title h3 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--text);
}

.integration-title p {
  margin: 4px 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ef4444;
  animation: pulse 2s ease-in-out infinite;
}

.status-indicator.connected {
  background: var(--green);
}

@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.integration-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-group-integration {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group-integration label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.form-group-integration input {
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.93rem;
  outline: none;
  transition: all 0.2s ease;
}

.form-group-integration input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.btn-connect {
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--green), #34d399);
  color: #000;
  font-weight: 700;
  font-size: 0.93rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
}

.btn-connect:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(34, 197, 94, 0.3);
}

.btn-connect.connected {
  background: linear-gradient(135deg, var(--green), #34d399);
}

.btn-connect.connected:hover {
  box-shadow: 0 8px 20px rgba(34, 197, 94, 0.3);
}

.integration-info {
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.1);
  border-left: 3px solid var(--blue);
  font-size: 0.85rem;
  color: #93c5fd;
  line-height: 1.5;
}

/* ========================================= */
/* MOBILE MENU                               */
/* ========================================= */

.mobile-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 100;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(17, 24, 39, 0.9);
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  transition: all 0.2s ease;
  font-family: inherit;
}

.mobile-toggle:hover {
  border-color: var(--green);
  background: rgba(34, 197, 94, 0.1);
}

/* ========================================= */
/* RESPONSIVE                                */
/* ========================================= */

@media (max-width: 1200px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 880px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 250px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 99;
  }

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

  .mobile-toggle {
    display: block;
  }

  .main {
    margin-left: 0;
    padding-top: 80px;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 20px 16px;
  }

  .header {
    flex-direction: column;
  }

  .header h2 {
    font-size: 24px;
  }

  .filters {
    width: 100%;
  }

  .filters select {
    flex: 1;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  table {
    font-size: 12px;
  }

  thead th,
  tbody td {
    padding: 10px;
  }
}
