/* ============================================
   Submissão de Informações e Documentos
   Visual institucional com compatibilidade funcional
   ============================================ */

:root {
  --color-bg: #f5f6f8;
  --color-bg-shape: #e8eaef;
  --color-card: #ffffff;
  --color-border: #ddd;
  --color-border-dark: #ccc;
  --color-text: #333;
  --color-text-muted: #666;
  --color-placeholder: #999;
  --color-primary: #003333;
  --color-primary-hover: #0b4a4a;
  --color-accent: #E27C02;
  --color-accent-hover: #c86f03;
  --color-required: #c53030;
  --color-error: #c53030;
  --color-icon: #999;
  --color-upload-icon: #a8b8d4;
  --font-body: "Outfit", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --radius: 8px;
  --radius-card: 18px;
  --shadow-card: 0 8px 40px rgba(0, 0, 0, 0.08);
  --shadow-btn: 0 4px 12px rgba(26, 55, 108, 0.2);
  --transition: 0.2s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Fundo e composição */
.page-wrap {
  position: relative;
  min-height: 100vh;
  padding: 2.5rem 1.5rem 4rem;
  overflow: hidden;
}

.page-wrap::before,
.page-wrap::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.page-wrap::before {
  width: 80vw;
  height: 80vw;
  max-width: 520px;
  max-height: 520px;
  background: var(--color-bg-shape);
  opacity: 0.6;
  top: -20%;
  right: -15%;
}

.page-wrap::after {
  width: 40vw;
  height: 40vw;
  max-width: 280px;
  max-height: 280px;
  background: var(--color-bg-shape);
  opacity: 0.5;
  bottom: -5%;
  left: -10%;
}

.sparkle {
  position: absolute;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(168, 184, 212, 0.35) 0%, transparent 70%);
  bottom: 15%;
  right: 10%;
  pointer-events: none;
  z-index: 0;
}

/* Card principal */
.card {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  background: var(--color-card);
  border-radius: var(--radius-card);
  padding: 2.5rem 2rem 3rem;
  box-shadow: var(--shadow-card);
}

/* Header */
.header {
  margin-bottom: 2rem;
}

.title {
  font-size: clamp(1.5rem, 4vw, 1.9rem);
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 0.35rem;
}

.subtitle {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 1rem;
  font-weight: 400;
}

/* Indicador de etapa */
.step-progress {
  margin-bottom: 1rem;
}

.step-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.step-progress-label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.step-progress-value {
  color: var(--color-primary);
  font-size: 0.9rem;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--color-accent);
  transition: width var(--transition);
}

/* Abas */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--color-border);
  overflow-x: auto;
}

.tab {
  flex: 1;
  padding: 0.85rem 1rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.tab:hover {
  color: var(--color-text);
}

.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-panel[hidden] {
  display: none !important;
}

/* Sections */
.section {
  margin-bottom: 2rem;
}

.section:last-of-type {
  margin-bottom: 0;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 1.25rem;
}

/* Grid */
.grid {
  display: grid;
  gap: 1.25rem;
}

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
  .grid-cols-2,
  .grid-cols-3 {
    grid-template-columns: 1fr;
  }
}

/* Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text);
}

.required {
  color: var(--color-required);
}

.optional {
  font-weight: 400;
  color: var(--color-placeholder);
}

/* Inputs base */
input[type="text"],
input[type="url"],
input[type="email"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--color-text);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input::placeholder,
textarea::placeholder {
  color: var(--color-placeholder);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--color-border-dark);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(26, 55, 108, 0.12);
}

input:disabled,
select:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  background: #f9f9f9;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='%23999'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

textarea {
  resize: vertical;
  min-height: 88px;
}

/* Input com ícone */
.input-with-icon .input-wrapper {
  position: relative;
  display: block;
}

.input-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-icon);
  pointer-events: none;
}

.input-icon-left .input-icon {
  left: 1rem;
}

.input-icon-right .input-icon {
  right: 1rem;
}

.input-with-icon .input-wrapper input {
  padding-left: 2.75rem;
}

.input-icon-right.input-with-icon .input-wrapper input {
  padding-left: 1rem;
  padding-right: 2.75rem;
}

/* Upload zone */
.upload-zone {
  position: relative;
  min-height: 140px;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  background: #fafbfc;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition), background var(--transition);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--color-primary);
  background: rgba(26, 55, 108, 0.04);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  pointer-events: none;
  text-align: center;
}

.upload-icon {
  color: var(--color-upload-icon);
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.upload-sub {
  font-size: 0.85rem;
  color: var(--color-placeholder);
}

.upload-zone.has-file .upload-text {
  color: var(--color-primary);
}

.upload-zone.has-file .upload-sub {
  color: var(--color-text-muted);
}

/* File wrap */
.file-wrap {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 1rem;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.file-wrap:hover {
  border-color: var(--color-border-dark);
}

.file-wrap:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(26, 55, 108, 0.12);
}

.file-wrap input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-name {
  font-size: 0.9rem;
  color: var(--color-placeholder);
  word-break: break-word;
}

.file-name.has-file {
  color: var(--color-primary);
}

/* Originadores */
.originadores-block {
  margin-bottom: 1.5rem;
}

.originadores-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.originadores-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--color-text);
}

.muted {
  font-weight: 400;
  color: var(--color-text-muted);
}

.lista-originadores {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.originador-item,
.originador-card {
  background: #f9fafb;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.originador-card h4,
.originador-item h4 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin: 0 0 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.originador-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1rem;
  align-items: end;
}

.originador-row .field {
  margin: 0;
}

.originador-row .file-wrap {
  min-width: 0;
}

@media (max-width: 640px) {
  .originador-row {
    grid-template-columns: 1fr;
  }
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform 0.15s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  box-shadow: 0 6px 16px rgba(26, 55, 108, 0.25);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.99);
}

.btn-secondary {
  background: rgba(0, 51, 51, 0.08);
  color: var(--color-primary);
  border: 1px solid rgba(0, 51, 51, 0.2);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(26, 55, 108, 0.12);
}

.btn-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.btn-remover {
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-error);
  background: transparent;
  border: 1px solid rgba(197, 48, 48, 0.4);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.btn-remover:hover {
  background: rgba(197, 48, 48, 0.08);
  border-color: var(--color-error);
}

/* Checkboxes */
.checkboxes {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--color-text);
}

.checkbox-label input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkmark {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  background: #fff;
  transition: border-color var(--transition), background var(--transition);
}

.checkbox-label input:checked + .checkmark {
  background: var(--color-primary);
  border-color: var(--color-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='white' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M2 6l3 3 5-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px;
}

.checkbox-label input:focus-visible + .checkmark {
  box-shadow: 0 0 0 2px rgba(26, 55, 108, 0.3);
}

/* Actions */
.form-actions {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.form-actions-inline .btn,
.form-actions .btn {
  flex: 1;
  min-width: 160px;
}

/* Resultado */
.resultado {
  display: none;
}

/* Validation */
.field.error input,
.field.error select,
.field.error textarea,
.field.error .file-wrap,
.field.error .upload-zone {
  border-color: var(--color-error);
}

.error-msg,
.field .error-msg {
  font-size: 0.8rem;
  color: var(--color-error);
  margin-top: 0.25rem;
}

/* Utilitários */
.hidden {
  display: none !important;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 51, 51, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal-card {
  width: min(460px, 100%);
  background: #fff;
  border-radius: 12px;
  border-top: 4px solid var(--color-accent);
  padding: 1.5rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
}

.modal-title {
  margin: 0 0 0.75rem;
  color: var(--color-primary);
}

.modal-message {
  margin: 0 0 1rem;
}

.modal-protocolo {
  margin: 0 0 1.25rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: rgba(226, 124, 2, 0.12);
  color: #6a3a00;
}

.modal-overlay[data-status="error"] .modal-card {
  border-top-color: #b3261e;
}

/* Espaçamento */
.section > .field:not(.grid *) {
  margin-top: 1.25rem;
}

.section > .field:first-of-type,
.section > .grid:first-child .field {
  margin-top: 0;
}

.section > .grid + .field,
.section > .field + .grid {
  margin-top: 1.25rem;
}

.section > .grid + .grid {
  margin-top: 1.25rem;
}

.section > .originadores-block {
  margin-top: 1.25rem;
}

@media (max-width: 640px) {
  .page-wrap {
    padding: 1.25rem 1rem 2rem;
  }

  .card {
    padding: 1.5rem 1rem 2rem;
    border-radius: 14px;
  }

  .tabs {
    gap: 0.25rem;
  }

  .tab {
    font-size: 0.85rem;
    padding: 0.75rem 0.5rem;
  }
}
