:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --accent-color: #9F655A;
  --accent-light: #fdf5f2;
  --accent-hover: #8b554c;
  --secondary-accent: #10b981;
  --border-color: #e2e8f0;
  --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --card-hover-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --max-width: 1400px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 4rem 2rem;
}

header {
  text-align: center;
  margin-bottom: 5rem;
  padding-top: 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logo {
  max-width: 250px;
  height: auto;
  margin-bottom: 2rem;
  border-radius: 12px;
}

header h1 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #1e293b, var(--accent-color));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

header p {
  color: var(--text-secondary);
  font-size: 1.25rem;
  max-width: 600px;
  margin: 0 auto 2rem;
}

.status-legend {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
  background: var(--bg-secondary);
  padding: 1rem 2rem;
  border-radius: 50px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.03);
  border: 1px solid var(--border-color);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.dot.admin { background: #0ea5e9; box-shadow: 0 0 10px #0ea5e9; }
.dot.agente { background: #06b6d4; box-shadow: 0 0 10px #06b6d4; }
.dot.utilizador { background: #10b981; box-shadow: 0 0 10px #10b981; }
.dot.terminal { background: #f59e0b; box-shadow: 0 0 10px #f59e0b; }
.dot.processo { background: #ef4444; box-shadow: 0 0 10px #ef4444; }

/* Flowchart Section */
.flowchart {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3rem;
  padding-left: 2rem;
}

.flowchart::before {
  content: '';
  position: absolute;
  left: calc(2rem + 24px);
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--accent-color), transparent);
  z-index: 0;
}

.flow-step {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  z-index: 1;
  opacity: 0;
  transform: translateY(20px);
  transition: var(--transition);
}

.flow-step.visible {
  opacity: 1;
  transform: translateY(0);
}

.step-marker {
  width: 50px;
  height: 50px;
  background-color: var(--bg-secondary);
  border: 2px solid var(--accent-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--accent-color);
  flex-shrink: 0;
  box-shadow: var(--card-shadow);
  transition: var(--transition);
}

.flow-step:hover .step-marker {
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(0,0,0,0.1);
}

/* Role Specific Colors */
.flow-step[data-role="admin"] .step-marker { border-color: #0ea5e9; color: #0ea5e9; }
.flow-step[data-role="admin"]:hover .step-marker { background: #0ea5e9; color: white; }
.flow-step[data-role="admin"] .step-summary { border-left-color: #0ea5e9; background: #e0f2fe; }
.flow-step[data-role="admin"] .sub-step i { color: #0ea5e9; background: #e0f2fe; }

.flow-step[data-role="agente"] .step-marker { border-color: #06b6d4; color: #06b6d4; }
.flow-step[data-role="agente"]:hover .step-marker { background: #06b6d4; color: white; }
.flow-step[data-role="agente"] .step-summary { border-left-color: #06b6d4; background: #ecfeff; }
.flow-step[data-role="agente"] .sub-step i { color: #06b6d4; background: #ecfeff; }

.flow-step[data-role="utilizador"] .step-marker { border-color: #10b981; color: #10b981; }
.flow-step[data-role="utilizador"]:hover .step-marker { background: #10b981; color: white; }
.flow-step[data-role="utilizador"] .step-summary { border-left-color: #10b981; background: #ecfdf5; }
.flow-step[data-role="utilizador"] .sub-step i { color: #10b981; background: #ecfdf5; }

.flow-step[data-role="terminal"] .step-marker { border-color: #f59e0b; color: #f59e0b; }
.flow-step[data-role="terminal"]:hover .step-marker { background: #f59e0b; color: white; }
.flow-step[data-role="terminal"] .step-summary { border-left-color: #f59e0b; background: #fffbeb; }
.flow-step[data-role="terminal"] .sub-step i { color: #f59e0b; background: #fffbeb; }

.flow-step[data-role="processo"] .step-marker { border-color: #ef4444; color: #ef4444; }
.flow-step[data-role="processo"]:hover .step-marker { background: #ef4444; color: white; }
.flow-step[data-role="processo"] .step-summary { border-left-color: #ef4444; background: #fef2f2; }
.flow-step[data-role="processo"] .sub-step i { color: #ef4444; background: #fef2f2; }

.step-content {
  background: var(--bg-secondary);
  padding: 2.5rem;
  border-radius: 1.5rem;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border-color);
  flex-grow: 1;
  transition: var(--transition);
  overflow: hidden;
}

.step-content:hover {
  box-shadow: var(--card-hover-shadow);
  border-color: var(--accent-color);
}

.step-content h2 {
  font-size: 1.25rem;
  margin-bottom: 2rem;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.step-content h2::after {
  content: '';
  height: 2px;
  flex-grow: 1;
  background: linear-gradient(to right, var(--accent-light), transparent);
}

.step-summary {
  margin-top: 2rem;
  padding: 1.25rem 1.5rem;
  background: var(--accent-light);
  border-left: 4px solid var(--accent-color);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-size: 1.05rem;
  line-height: 1.6;
  font-weight: 450;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.6s ease-out;
}

.step-summary.visible {
  opacity: 1;
  transform: translateY(0);
}

.step-summary i {
  color: var(--accent-color);
  margin-right: 0.5rem;
}

/* Sub-flow horizontal layout */
.sub-flow {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.sub-step {
  flex: 1;
  min-width: 180px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 1.25rem;
  padding: 2rem 1rem;
  text-align: center;
  position: relative;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.sub-step:hover {
  transform: translateY(-8px);
  background: white;
  border-color: var(--accent-color);
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.05);
}

.sub-step i {
  font-size: 2rem;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  margin-bottom: 0.5rem;
  transition: var(--transition);
}

.sub-step:hover i {
  background: var(--accent-color);
  color: white;
  transform: rotate(5deg);
}

.sub-step p {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.3;
}

.sub-step .step-num {
  position: absolute;
  top: -12px;
  background: var(--text-primary);
  color: white;
  font-size: 0.65rem;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.flow-arrow {
  color: var(--accent-color);
  opacity: 0.4;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  animation: pulseArrow 2s infinite;
}

@keyframes pulseArrow {

  0%,
  100% {
    transform: translateX(0);
    opacity: 0.4;
  }

  50% {
    transform: translateX(5px);
    opacity: 0.8;
  }
}

@media (max-width: 1024px) {
  .sub-flow {
    flex-direction: column;
  }

  .flow-arrow {
    transform: rotate(90deg);
    margin: 0.5rem 0;
  }

  @keyframes pulseArrow {

    0%,
    100% {
      transform: translateY(0);
      opacity: 0.4;
    }

    50% {
      transform: translateY(5px);
      opacity: 0.8;
    }
  }
}

/* Database Section */
.database-section {
  margin-top: 6rem;
  padding: 4rem;
  background-color: var(--bg-secondary);
  border-radius: 1.5rem;
  box-shadow: var(--card-shadow);
}

.database-section h2 {
  text-align: center;
  margin-bottom: 3rem;
  font-size: 2rem;
}

.db-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}

.db-table {
  background: var(--bg-primary);
  padding: 1.5rem;
  border-radius: 1rem;
  border: 1px solid var(--border-color);
}

.db-table h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--accent-color);
  border-bottom: 2px solid var(--accent-light);
  padding-bottom: 0.5rem;
}

.db-fields {
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.db-fields div {
  margin-bottom: 0.25rem;
}

.field-name {
  color: #c2410c;
}

.field-type {
  color: #0369a1;
}

@media (max-width: 768px) {
  header h1 {
    font-size: 2rem;
  }

  .flowchart::before {
    left: calc(2rem + 15px);
  }

  .step-marker {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }
}