/* ===== CUSTOM FORM STYLES ===== */

:root {
  --loader-size: 48px;
  --loader-color: #0b74de;
  --bg-color: rgba(0, 0, 0, 0.08);
  --primary-color: #5e72e4;
  --secondary-color: #f7fafc;
  --text-color: #222222;
  --border-color: #666666;
  --placeholder-color: #a2a2a2;
}

/* ===== BACKGROUND IMAGE ===== */
#background-image {
  background-image: url(https://digital.mogiguacu.sp.gov.br/images/guacudigital.png);
  width: 100%;
  top: 0;
  left: 0;
  height: 100%;
  opacity: 0.05;
  position: fixed;
  background-repeat: repeat;
  background-size: 20% auto;
  padding: 0;
  margin: 0;
  z-index: 0;
}

/* ===== FORM STYLES ===== */
.section-profile-cover {
  height: 230px;
}

.form-control {
  color: var(--text-color);
  border: 1px solid var(--border-color) !important;
}

.form-control:focus {
  color: #000000;
}

input, select, textarea {
  border: 1px solid var(--border-color) !important;
}

::placeholder {
  color: var(--placeholder-color);
  opacity: 1;
}

/* For Microsoft Edge */
::-ms-input-placeholder {
  color: var(--placeholder-color);
}

/* For Internet Explorer 10-11 */
:-ms-input-placeholder {
  color: var(--placeholder-color);
}

/* ===== MAP STYLES ===== */
#map {
  height: 400px;
  border-radius: 0.375rem;
  border: 1px solid #dee2e6;
}

.leaflet-button {
  padding: 0 10px;
  background: var(--primary-color) !important;
  color: white !important;
  text-decoration: none;
  border-radius: 4px;
}

.leaflet-button:hover {
  background: #4c63d2 !important;
  color: white !important;
}

/* ===== LOADER STYLES ===== */
.loading {
  display: none;
}

.loader {
  width: var(--loader-size);
  height: var(--loader-size);
  vertical-align: middle;
}

.svg-ring {
  width: 100%;
  height: 100%;
  display: block;
}

.ring-bg {
  stroke: var(--bg-color);
}

.ring {
  stroke: var(--loader-color);
  stroke-dasharray: 120;
  stroke-dashoffset: 80;
  transform-origin: 50% 50%;
  animation: 
    ring-rotate 1.5s linear infinite,
    ring-pulse 1.2s ease-in-out infinite;
}

@keyframes ring-rotate {
  100% {
    transform: rotate(360deg);
  }
}

@keyframes ring-pulse {
  0% {
    stroke-dashoffset: 80;
  }
  50% {
    stroke-dashoffset: 10;
  }
  100% {
    stroke-dashoffset: 80;
  }
}

/* ===== PHOTO UPLOAD STYLES ===== */
.dropzone {
  border: 2px dashed #6c757d;
  border-radius: 0.5rem;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background-color: #f8f9fa;
}

.dropzone:hover {
  border-color: var(--primary-color);
  background-color: #e9ecef;
}

.dropzone.dragover {
  background-color: #e3f2fd;
  border-color: var(--primary-color);
  transform: scale(1.02);
}

.preview {
  margin-top: 1rem;
}

.preview img {
  max-width: 100px;
  max-height: 100px;
  margin: 5px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid #dee2e6;
  transition: transform 0.2s ease;
}

.preview img:hover {
  transform: scale(1.05);
  border-color: var(--primary-color);
}

/* ===== PHOTO CONTAINER LEGACY (compatibility) ===== */
#photo-container {
  display: flex;
  flex-wrap: wrap;
  margin-top: 20px;
}

.thumbnail {
  margin: 5px;
  height: 150px;
  width: 150px;
  border-radius: 8px;
  object-fit: cover;
}

.upload-icon {
  cursor: pointer;
  height: 50px;
  width: 50px;
  float: left;
}

/* ===== UTILITY CLASSES ===== */
.masonry-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.masonry-form .form-group {
  break-inside: avoid;
}

.panel-body .btn:not(.btn-block) {
  margin-bottom: 10px;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  #map {
    height: 300px;
  }
  
  .dropzone {
    padding: 20px;
  }
  
  .section-profile-cover {
    height: 200px;
  }
  
  .card-profile {
    margin-top: -100px !important;
  }
}

@media (max-width: 576px) {
  .form-control {
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  .preview img {
    max-width: 80px;
    max-height: 80px;
  }
}

/* ===== ACCESSIBILITY ===== */
.form-control:focus {
  box-shadow: 0 0 0 2px rgba(94, 114, 228, 0.25);
}

.btn:focus {
  box-shadow: 0 0 0 2px rgba(94, 114, 228, 0.5);
}

/* ===== LOADING STATES ===== */
.btn.loading {
  position: relative;
  color: transparent;
}

.btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* ===== FORM VALIDATION STYLES ===== */
.form-control.is-invalid {
  border-color: #dc3545;
}

.form-control.is-valid {
  border-color: #28a745;
}

.invalid-feedback {
  display: block;
  color: #dc3545;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.valid-feedback {
  display: block;
  color: #28a745;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}