/* Water.css inspired minimal styling */
* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
  margin: 0;
  padding: 20px;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.loading-indicator {
  text-align: center;
  padding: 2rem;
}

.loading-indicator p {
  margin: 0;
}

/* Wrapper for banner with overlaid white band (building name + company logo) */
.banner-with-overlay {
  position: relative;
  width: 100%;
  height: 200px;
  margin-bottom: 30px;
  border-radius: 8px;
  overflow: hidden;
}

.banner-with-overlay .app-logo {
  position: relative;
  margin-bottom: 0;
  height: 100%;
  border-radius: 8px;
}

.banner-white-band {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  background: white;
  opacity: 0.8;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.1);
}

.banner-white-band .building-header {
  margin: 0;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.banner-white-band .building-name-header {
  margin: 0;
}

/* Hide white band when no building info (e.g. default logo before token) */
.banner-white-band:has(#building-header:empty) {
  display: none;
}

.app-logo {
  text-align: center;
  margin-bottom: 30px;
  width: 100%;
  height: 200px;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
}

/* Uncropped logo for welcome page (no building ID) */
.app-logo-uncropped {
  height: auto;
  overflow: visible;
  margin-bottom: 0;
}

.app-logo-uncropped .logo-image {
  width: auto;
  height: auto;
  max-width: 200px;
  object-fit: contain;
  object-position: center;
  display: block;
  margin: 0 auto;
}

/* Cropped logo for form page (with building ID) */
.logo-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.building-header {
  margin-bottom: 20px;
  text-align: center;
}

.building-name-header {
  margin: 0 0 12px 0;
  color: #2c3e50;
  font-size: 1.5em;
  font-weight: 600;
}

.management-company-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.management-company-logo {
  max-height: 40px;
  width: auto;
  object-fit: contain;
}

.management-company-name {
  font-size: 0.9em;
  color: #7f8c8d;
  font-style: italic;
}

.app-header-title {
  text-align: center;
}

.app-header-title h1 {
  color: rgba(47, 85, 151, 1);
  font-size: xxx-large;
  margin-bottom: 0;
  height: 55px;
}

.app-header-title h3 {
  color: #7c7878;
  font-size: x-large;
  margin-top: 0;
  margin-bottom: 0;
  letter-spacing: 0.7px;
}

h1 {
  margin-top: 0;
  color: #2c3e50;
  font-size: 2em;
}

h2 {
  color: #34495e;
  font-size: 1.5em;
}

.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #555;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="file"],
textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
  font-family: inherit;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
textarea:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  font-weight: normal;
  cursor: pointer;
}

input[type="checkbox"] {
  width: auto;
  margin-right: 8px;
  cursor: pointer;
}

.btn {
  display: inline-block;
  padding: 12px 24px;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary {
  background-color: #3498db;
  color: white;
}

.btn-primary:hover {
  background-color: #2980b9;
}

.btn-secondary {
  background-color: #95a5a6;
  color: white;
}

.btn-secondary:hover {
  background-color: #7f8c8d;
}

.btn-link {
  background: none;
  color: #3498db;
  padding: 12px 0;
}

.btn-link:hover {
  text-decoration: underline;
}

/* Submit issue / report button loading state (htmx adds htmx-request to form) */
#issue-form.htmx-request button[type="submit"],
#report-form.htmx-request button[type="submit"] {
  pointer-events: none;
  position: relative;
  color: transparent;
}

#issue-form.htmx-request .submit-loading-spinner,
#report-form.htmx-request .submit-loading-spinner {
  display: inline-block;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -10px;
  margin-top: -10px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  animation: submit-spinner-spin 0.7s linear infinite;
}

.submit-loading-spinner {
  display: none;
}

@keyframes submit-spinner-spin {
  to {
    transform: rotate(360deg);
  }
}

.residence-info {
  background-color: #ecf0f1;
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 20px;
}

.residence-info h2 {
  margin: 0 0 10px 0;
  font-size: 1.3em;
}

.photo-preview {
  margin-top: 15px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}

.photo-preview-item {
  position: relative;
}

.photo-preview-item img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #ddd;
  display: block;
}

.photo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-remove:hover {
  background: rgba(0, 0, 0, 0.85);
}

.success-message {
  text-align: center;
  padding: 20px 0;
}

.success-message h1 {
  color: #27ae60;
  margin-bottom: 15px;
}

.success {
  background-color: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
  padding: 15px;
  border-radius: 4px;
  margin-top: 20px;
}

.success h2 {
  margin-top: 0;
  color: #155724;
}

.error {
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
  padding: 15px;
  border-radius: 4px;
  margin-top: 20px;
}

.actions {
  margin-top: 30px;
  display: flex;
  gap: 15px;
  justify-content: center;
}

small {
  display: block;
  color: #7f8c8d;
  font-size: 0.9em;
  margin-top: 5px;
}

#result {
  margin-top: 20px;
}

.language-switcher {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border: 1px solid #e0e0e0;
  margin-bottom: 20px;
  width: fit-content;
}

.language-flag {
  background: transparent;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 1.5em;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.language-flag:hover {
  background: #f0f0f0;
  border-color: #3498db;
  transform: scale(1.1);
}

.language-flag.active {
  border-color: #3498db;
  background: #e8f4f8;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.welcome-description {
  font-size: 1.1em;
  color: #555;
  line-height: 1.8;
  margin-bottom: 30px;
}

#buildings-list {
  margin-top: 30px;
}

#buildings-list h2 {
  margin-bottom: 15px;
  color: #2c3e50;
  font-size: 1.3em;
}

.buildings-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.buildings-list li {
  padding: 0;
  margin-bottom: 8px;
  background-color: #f8f9fa;
  border-left: 3px solid #3498db;
  border-radius: 4px;
  color: #333;
  transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.buildings-list li:hover {
  background-color: #e9ecef;
  transform: translateX(3px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.buildings-list li[data-building-id] {
  cursor: pointer;
}

.buildings-list li[data-building-id]:hover {
  background-color: #e3f2fd;
  border-left-color: #2196f3;
}

.buildings-list li:last-child {
  margin-bottom: 0;
}

.building-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 80px;
}

.building-banner-container {
  position: relative;
  width: 120px;
  height: 80px;
  flex-shrink: 0;
  overflow: hidden;
}

.building-banner {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background-color: #e9ecef;
}

.banner-loading .logo-image,
.banner-loading .building-banner {
  opacity: 0;
}

.banner-loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  margin-top: -16px;
  margin-left: -16px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.7);
  border-top-color: #3498db;
  animation: banner-spinner-spin 0.8s linear infinite;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.15);
}

@keyframes banner-spinner-spin {
  to {
    transform: rotate(360deg);
  }
}

.building-info {
  padding: 12px 15px;
  flex: 1;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.building-name {
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 4px;
}

.building-managed-by {
  font-size: 0.9em;
  color: #7f8c8d;
  font-style: italic;
}

/* Responsive */
@media (max-width: 600px) {
  body {
    padding: 10px;
  }

  .container {
    padding: 20px;
  }

  .app-logo {
    margin-bottom: 20px;
  }

  .app-header-title {
    text-align: center;
  }

  .app-header-title h1 {
    font-size: xxx-large;
    color: #2f5597;
  }

  .app-header-title h3 {
    font-size: x-large;
  }
  .actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    text-align: center;
  }

  .language-switcher {
    margin-bottom: 15px;
  }
}
