/* ============================================================================
   MODERN RESPONSIVE CADASTRO FORM
   Mobile-first responsive design
   ============================================================================ */

:root {
  /* Colors */
  --primary-color: #006ba6;
  --primary-hover: #005a8d;
  --secondary-color: #0073b0;
  --success-color: #2e7d32;
  --success-light: #43a047;
  --error-color: #d32f2f;
  --warning-color: #ff6600;
  --text-primary: #333;
  --text-secondary: #666;
  --text-muted: #999;
  --border-color: #bcbcbc;
  --border-light: #e0e0e0;
  --bg-light: #f5f5f5;
  --bg-white: #ffffff;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 16px rgba(0,0,0,0.15);

  /* Spacing */
  --spacing-xs: 8px;
  --spacing-sm: 12px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
}

/* ============================================================================
   GLOBAL RESET & BASE STYLES
   ============================================================================ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text-primary);
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  min-height: 100vh;
  line-height: 1.6;
}

/* ============================================================================
   HEADER / TOP BAR
   ============================================================================ */

.top {
  background: var(--bg-white);
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo img {
  height: 50px;
  width: auto;
  display: block;
}

/* ============================================================================
   CONTAINER & LAYOUT
   ============================================================================ */

.container {
  max-width: 680px;
  margin: 0 auto;
  padding: var(--spacing-md);
  animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================================
   TYPOGRAPHY
   ============================================================================ */

h1 {
  color: var(--text-secondary);
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 var(--spacing-lg);
  text-align: center;
}

.info {
  background: #fff3cd;
  color: #856404;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: var(--spacing-md);
  border-left: 4px solid #ffc107;
  line-height: 1.5;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
  margin: var(--spacing-xs) 0;
}

/* ============================================================================
   FORM STYLES
   ============================================================================ */

form {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-md);
}

.row {
  margin-bottom: var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.row label {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.row label::before {
  content: '';
  width: 4px;
  height: 16px;
  background: var(--primary-color);
  border-radius: 2px;
}

.row input[type="text"],
.row input[type="email"] {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 15px;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  background: var(--bg-white);
  font-family: inherit;
}

.row input[type="text"]:focus,
.row input[type="email"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 107, 166, 0.1);
}

.row input[type="text"]::placeholder,
.row input[type="email"]::placeholder {
  color: var(--text-muted);
  font-size: 14px;
}

.row input[type="text"]:disabled,
.row input[type="email"]:disabled {
  background: var(--bg-light);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Input with inline button */
.row.has-button {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto auto;
  gap: var(--spacing-xs);
}

.row.has-button label {
  grid-column: 1 / -1;
}

.row.has-button input {
  grid-column: 1;
  grid-row: 2;
}

.row.has-button .btn {
  grid-column: 2;
  grid-row: 2;
  height: 46px;
  margin-left: var(--spacing-xs);
}

.row.has-button .msg,
.row.has-button .muted {
  grid-column: 1 / -1;
  grid-row: 3;
}

/* ============================================================================
   BUTTON STYLES
   ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  cursor: pointer;
  border: none;
  border-radius: var(--radius-md);
  padding: var(--spacing-sm) var(--spacing-lg);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: var(--bg-white);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary-color) 100%);
}

.btn-secondary {
  background: var(--primary-color);
  color: var(--bg-white);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--primary-hover);
}

/* ============================================================================
   FORM SECTIONS & GROUPING
   ============================================================================ */

.extra-fields {
  display: none;
}

.extra-fields.visible {
  display: block;
}

.form-section {
  margin-top: var(--spacing-xl);
  padding-top: var(--spacing-xl);
  border-top: 2px solid var(--border-light);
}

.form-section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.form-section-title::before {
  content: '';
  width: 6px;
  height: 24px;
  background: var(--primary-color);
  border-radius: 3px;
}

.address-row {
  display: none;
}

.address-row.visible {
  display: flex;
}

/* ============================================================================
   ALERTS & MESSAGES
   ============================================================================ */

.alert {
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-md);
  margin: var(--spacing-md) 0;
  color: var(--bg-white);
  box-shadow: var(--shadow-sm);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.alert h1,
.alert h3 {
  color: var(--bg-white);
  margin-bottom: var(--spacing-sm);
}

.alert h1 {
  font-size: 24px;
}

.alert h3 {
  font-size: 18px;
}

.alert p {
  margin: var(--spacing-xs) 0;
  line-height: 1.6;
}

.alert .note {
  color: #ffe1e1;
  font-size: 13px;
  font-style: italic;
  margin-top: var(--spacing-sm);
}

.alert.success {
  background: linear-gradient(135deg, var(--success-color) 0%, var(--success-light) 100%);
}

.alert.error {
  background: linear-gradient(135deg, #c62828 0%, var(--error-color) 100%);
}

.alert.warn {
  background: linear-gradient(135deg, #f57c00 0%, var(--warning-color) 100%);
}

.alert button {
  margin-top: var(--spacing-md);
  background: rgba(255, 255, 255, 0.3);
  border: 2px solid var(--bg-white);
  color: var(--bg-white);
  padding: var(--spacing-sm) var(--spacing-lg);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all var(--transition-fast);
}

.alert button:hover {
  background: var(--bg-white);
  color: var(--text-primary);
}

.msg {
  display: block;
  margin-top: var(--spacing-xs);
  color: var(--text-secondary);
  font-size: 13px;
}

.msg.error {
  color: var(--error-color);
  font-weight: 600;
}

/* ============================================================================
   ACTIONS / FOOTER BUTTONS
   ============================================================================ */

.actions {
  margin-top: var(--spacing-xl);
  padding-top: var(--spacing-lg);
  border-top: 2px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.actions .btn {
  width: 100%;
  padding: var(--spacing-md) var(--spacing-lg);
  font-size: 16px;
}

/* ============================================================================
   MODAL STYLES
   ============================================================================ */

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
}

.modal-content {
  background-color: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  animation: slideDown 0.3s;
  overflow: hidden;
}

.modal-header {
  background: linear-gradient(135deg, var(--success-color) 0%, var(--success-light) 100%);
  color: var(--bg-white);
  padding: var(--spacing-lg);
  text-align: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}

.modal-body {
  padding: var(--spacing-xl) var(--spacing-lg);
  text-align: center;
  color: var(--text-primary);
}

.modal-body p {
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
}

.modal-footer {
  padding: var(--spacing-lg);
  text-align: center;
  border-top: 1px solid var(--border-light);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideDown {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ============================================================================
   RESPONSIVE DESIGN - TABLET
   ============================================================================ */

@media (min-width: 640px) {
  .container {
    padding: var(--spacing-lg);
  }

  form {
    padding: var(--spacing-xl);
  }

  .logo img {
    height: 60px;
  }

  h1 {
    font-size: 32px;
  }

  .actions {
    flex-direction: row;
    justify-content: flex-end;
  }

  .actions .btn {
    width: auto;
    min-width: 200px;
  }
}

/* ============================================================================
   RESPONSIVE DESIGN - DESKTOP
   ============================================================================ */

@media (min-width: 768px) {
  .container {
    max-width: 760px;
    padding: var(--spacing-xl) var(--spacing-lg);
  }

  .top {
    padding: var(--spacing-md) var(--spacing-xl);
  }

  /* Two-column layout for certain fields */
  .row-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
  }

  .row-group .row {
    margin-bottom: 0;
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 920px;
  }

  /* Optional: Side-by-side label and input layout */
  .row.horizontal {
    flex-direction: row;
    align-items: center;
  }

  .row.horizontal label {
    width: 200px;
    min-width: 200px;
    text-align: right;
    margin-right: var(--spacing-md);
  }

  .row.horizontal label::before {
    display: none;
  }
}

/* ============================================================================
   LOADING STATES
   ============================================================================ */

.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 3px solid var(--primary-color);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
  body {
    background: white;
  }

  .top,
  .btn,
  .actions {
    display: none;
  }

  .container {
    max-width: 100%;
  }

  form {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* ============================================================================
   HIDE ADDRESS SECTION
   ============================================================================ */

/* Ocultar toda a seção de endereço */
.form-section:has(.address-row) {
  display: none !important;
}

/* Fallback para navegadores que não suportam :has() */
.address-row {
  display: none !important;
}
