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

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-strong: #0f172a; /* Slate 900 */
  --line: #f1f5f9; /* Slate 100 */
  --border: #e2e8f0; /* Slate 200 */
  --border-focus: #00b67a; /* Verde Asaas */
  --text: #0f172a; /* Slate 900 */
  --muted: #64748b; /* Slate 500 */
  --primary: #00b67a; /* Verde Tecnológico */
  --primary-dark: #009e69;
  --primary-light: rgba(0, 182, 122, 0.1);
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --success: #00b67a;
  --success-soft: #ecfdf5;
  --warning: #f59e0b;
  --warning-soft: #fffbeb;
  --info: #3b82f6;
  --info-soft: #eff6ff;
  
  /* Sombras Modernas e Suaves */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.04), 0 2px 6px -1px rgba(15, 23, 42, 0.02);
  --shadow-md: 0 10px 20px -5px rgba(15, 23, 42, 0.06), 0 3px 8px -2px rgba(15, 23, 42, 0.02);
  --shadow-lg: 0 25px 40px -12px rgba(15, 23, 42, 0.08), 0 8px 16px -8px rgba(15, 23, 42, 0.04);
  --shadow-premium: 0 12px 30px -10px rgba(0, 182, 122, 0.12);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4,
.brand strong,
.nav-item,
.primary-button,
.ghost-button,
.danger-button {
  font-family: 'Plus Jakarta Sans', sans-serif;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* App Layout */
.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* Sidebar Estilo Premium */
.sidebar {
  background: var(--surface-strong);
  color: #ffffff;
  padding: 30px 24px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 40px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 10px;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.brand:hover .brand-icon {
  transform: rotate(360deg) scale(1.05);
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 10px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
  font-size: 18px;
}

.brand strong {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #ffffff;
}

.brand small {
  display: block;
  color: var(--primary);
  margin-top: 1px;
  text-transform: uppercase;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

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

.nav-item {
  min-height: 46px;
  border-radius: 12px;
  background: transparent;
  color: #94a3b8; /* Slate 400 */
  text-align: left;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  height: 50%;
  width: 4px;
  background: #ffffff;
  border-radius: 0 4px 4px 0;
  transform: scaleY(0);
  transition: transform 0.2s ease;
}

.nav-item.active::before {
  transform: scaleY(1);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #f1f5f9;
  padding-left: 20px;
}

.nav-item.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 8px 16px -6px rgba(0, 182, 122, 0.4);
}

/* Área de Conteúdo */
.content {
  padding: 40px;
  overflow-y: auto;
  max-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 24px;
}

h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}

.topbar p {
  color: var(--muted);
  margin-top: 4px;
  font-size: 14px;
}

/* Botões */
.primary-button,
.ghost-button,
.danger-button {
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 0 20px;
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.primary-button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 182, 122, 0.2);
}

.primary-button:active {
  transform: translateY(0);
}

.ghost-button {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.ghost-button:hover {
  background: var(--line);
  border-color: #cbd5e1;
  color: var(--text);
}

.danger-button {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.1);
}

.danger-button:hover {
  background: #fee2e2;
  color: #b91c1c;
}

/* SPA Views */
.view {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.view.active {
  display: block;
}

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

/* Cards e Métricas */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.metric:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.metric {
  min-height: 120px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.metric strong {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

.metric small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.metric.danger {
  background: linear-gradient(135deg, #ffffff, var(--danger-soft));
  border-color: rgba(239, 68, 68, 0.15);
}

.metric.danger strong {
  color: var(--danger);
}

.metric.success {
  background: linear-gradient(135deg, #ffffff, var(--success-soft));
  border-color: rgba(0, 182, 122, 0.15);
}

.metric.success strong {
  color: var(--success);
}

/* Painéis de Conteúdo */
.panel {
  padding: 24px;
}

.panel-header {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.panel-header h2 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text);
}

/* Split Layout */
.split-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
}

.form-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 0 16px;
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

textarea {
  min-height: 96px;
  padding: 12px 16px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px rgba(0, 182, 122, 0.12);
  background: #ffffff;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.search-input {
  max-width: 280px;
}

/* Tabelas Arredondadas */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}

th,
td {
  padding: 16px 20px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

td {
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--line);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: #fafbfc;
}

/* Badges e Status */
.status {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}

.status::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
}

.status.PAID::before,
.status.ACTIVE::before,
.status.DONE::before {
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(0, 182, 122, 0.4);
  animation: pulse-green 2s infinite;
}

.status.PENDING::before,
.status.TODO::before {
  background: var(--warning);
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
  animation: pulse-orange 2s infinite;
}

.status.OVERDUE::before,
.status.BLOCKED::before {
  background: var(--danger);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  animation: pulse-red 2s infinite;
}

.status.IN_PROGRESS::before {
  background: var(--info);
  box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
  animation: pulse-blue 2s infinite;
}

.status.CANCELED::before,
.status.REFUNDED::before {
  background: #64748b;
}

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 182, 122, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 5px rgba(0, 182, 122, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 182, 122, 0); }
}

@keyframes pulse-orange {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 5px rgba(245, 158, 11, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

@keyframes pulse-red {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes pulse-blue {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 5px rgba(59, 130, 246, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

.status.PENDING {
  background: var(--warning-soft);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.15);
}

.status.OVERDUE {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.15);
}

.status.PAID {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(0, 182, 122, 0.15);
}

.status.CANCELED,
.status.REFUNDED {
  background: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
}

.status.TODO {
  background: var(--warning-soft);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.15);
}

.status.IN_PROGRESS {
  background: var(--info-soft);
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, 0.15);
}

.status.DONE {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(0, 182, 122, 0.15);
}

.status.BLOCKED {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.15);
}

/* Priority Badges */
.priority {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.priority.LOW {
  background: #f1f5f9;
  color: #475569;
}

.priority.MEDIUM {
  background: var(--info-soft);
  color: #1d4ed8;
}

.priority.HIGH {
  background: var(--warning-soft);
  color: #b45309;
}

.priority.URGENT {
  background: var(--danger-soft);
  color: var(--danger);
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.actions button,
.actions select {
  min-height: 32px;
  font-size: 12px;
  border-radius: 8px;
}

.settings-panel {
  max-width: 980px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.settings-grid article {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.settings-grid p {
  color: var(--muted);
  margin: 8px 0 12px;
  line-height: 1.5;
  font-size: 14px;
}

code {
  display: inline-block;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  color: #0f172a;
  font-family: monospace;
  font-size: 13px;
}

/* Modais Glassmorphism */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  padding: 40px 10px;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.modal-content {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  width: 95%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.6);
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  margin: auto; /* Centraliza verticalmente se couber, rola se for maior */
  padding: 30px;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-content label {
  margin-bottom: 14px;
}

/* Toast */
#toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 380px;
  padding: 16px 20px;
  border-radius: 12px;
  background: var(--surface-strong);
  color: #ffffff;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 9999;
  font-size: 14px;
  font-weight: 500;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Estilo do Site Grid */
#sitesGrid .panel {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

#sitesGrid .panel:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(0, 182, 122, 0.3);
}

/* Responsividade */
@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    border-right: none;
  }

  .brand {
    margin-bottom: 16px;
    justify-content: center;
  }

  .nav {
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
  }

  .nav-item {
    min-height: 38px;
    padding: 0 12px;
    font-size: 13px;
    border-radius: 10px;
  }

  .metrics-grid,
  .split-layout,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 24px;
  }
}

@media (max-width: 620px) {
  .topbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

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

  .nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  
  .nav-item {
    justify-content: center;
  }
}
