@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --primary: #1a2540;
  --primary-dark: #0f1b36;
  --text: #1a2540;
  --muted: #6b7280;
  --muted-light: #9ca3af;
  --success-bg: #e8f5e9;
  --success-text: #2e7d32;
  --error: #b91c1c;
  --error-bg: #fef2f2;
  --shadow: 0 4px 24px rgba(15, 27, 54, 0.08);
  --radius: 16px;
  --radius-sm: 12px;
  --max-width: 480px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--primary);
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page > .site-footer {
  margin-top: auto;
  padding-top: 2.5rem;
}

.page__main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
}

/* Header */
.header {
  display: flex;
  justify-content: center;
  padding: 1rem 1.25rem 0.75rem;
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
}

.header--dashboard {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 0.5rem;
  position: relative;
  padding-top: 1rem;
  padding-bottom: 0.5rem;
}

.header__center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
}

.header__logo-link {
  display: inline-block;
  line-height: 0;
  text-decoration: none;
}

.header__logo-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
  border-radius: 4px;
}

.header__logo {
  height: 80px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
  display: block;
}

.header__tagline {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.4;
  letter-spacing: normal;
  text-transform: none;
}

.header__user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  justify-self: end;
  grid-column: 3;
  grid-row: 1;
}

.btn-header-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  flex-shrink: 0;
  padding: 0.5rem 0.625rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease;
  justify-self: start;
  grid-column: 1;
  grid-row: 1;
  align-self: start;
}

.btn-header-home:hover {
  background: var(--primary-dark);
}

.btn-header-home__icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.btn-header-home__label {
  display: none;
}

.header--dashboard .header__center {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge--active {
  background: var(--success-bg);
  color: var(--success-text);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

.user-menu__trigger-wrap {
  position: relative;
}

.user-menu-trigger {
  border: none;
  padding: 0;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.user-menu-trigger:hover {
  opacity: 0.88;
  transform: scale(1.04);
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 220px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(15, 27, 54, 0.14);
  padding: 0.5rem 0;
  z-index: 100;
}

.menu-item {
  margin: 0;
}

.menu-item--static {
  padding: 0.5rem 1rem;
  pointer-events: none;
}

.menu-item--name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.menu-item--email {
  padding-top: 0.25rem;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.3;
}

.menu-divider {
  height: 1px;
  margin: 0.375rem 0;
  background: #e5e7eb;
}

.menu-logout {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.625rem 1rem;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--error);
  text-align: left;
  cursor: pointer;
  border-radius: 0;
}

.menu-logout:hover {
  background: var(--error-bg);
}

.menu-logout:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.menu-link {
  display: block;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}

.menu-link:hover {
  background: rgba(26, 37, 64, 0.05);
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

/* Welcome (login) */
.welcome {
  margin-bottom: 1.25rem;
  text-align: center;
}

.welcome__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.welcome__badge {
  margin: 0.375rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.4;
}

.welcome__text {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.5;
}

.card--login {
  margin-top: 0;
}

.card__title {
  margin: 0 0 1.25rem;
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--primary);
}

.card--hero {
  background: linear-gradient(145deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  margin-bottom: 1.25rem;
}

.card--hero .card__greeting {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.card--hero .card__subtitle {
  margin: 0.375rem 0 0;
  font-size: 0.875rem;
  opacity: 0.9;
}

.card--hero .card__date {
  margin: 0.75rem 0 0;
  font-size: 0.8125rem;
  opacity: 0.75;
}

/* Form */
.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form__group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form__label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s ease;
}

.input::placeholder {
  color: var(--muted-light);
}

.input:hover {
  border-color: #d1d5db;
}

.input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(26, 37, 64, 0.12);
}

.form__error {
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--error-bg);
  color: var(--error);
  font-size: 0.875rem;
  display: none;
}

.form__error.is-visible {
  display: block;
}

.hidden {
  display: none;
}

.contact-toggle-wrap {
  margin-top: 1.25rem;
  text-align: center;
}

.contact-toggle {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
}

.contact-toggle:hover {
  color: var(--primary);
  text-decoration: underline;
}

.contact-info {
  margin-top: 0.75rem;
  padding: 1rem 1.25rem;
  background: #eef0f4;
  border-radius: var(--radius-sm);
  text-align: left;
}

.contact-info__item {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.875rem;
  line-height: 1.4;
}

.contact-info__item + .contact-info__item {
  margin-top: 0.625rem;
}

.contact-info__icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
}

.contact-info a {
  color: var(--primary);
  text-decoration: none;
}

.contact-info a:hover {
  text-decoration: underline;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-ghost {
  width: 100%;
  margin-top: 1.5rem;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.875rem;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--primary);
  background: rgba(26, 37, 64, 0.05);
}

/* Dashboard */
.section-title {
  margin: 0 0 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.quick-access {
  display: grid;
  gap: 0.75rem;
}

.quick-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 1rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  font: inherit;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.quick-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(15, 27, 54, 0.12);
}

.quick-card__icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: rgba(26, 37, 64, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.quick-card__icon svg {
  width: 24px;
  height: 24px;
}

.quick-card__body {
  flex: 1;
  min-width: 0;
}

.quick-card__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.quick-card__meta {
  margin: 0.125rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

/* Footer */
.site-footer {
  width: 100%;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  padding: 0 1.25rem 1.5rem;
  text-align: center;
}

.site-footer__line {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

.site-footer__line + .site-footer__line {
  margin-top: 0.375rem;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Buildings pages */
.page-title {
  margin: 0 0 0.5rem;
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text);
}

.page-subtitle {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.page-toolbar .page-title {
  margin: 0;
  flex: 1;
  min-width: 0;
}

.btn-add-building {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  flex-shrink: 0;
  padding: 0.5rem 0.625rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-add-building:hover {
  background: var(--primary-dark);
}

.btn-add-building__icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.btn-add-building__label {
  display: none;
}

@media (min-width: 520px) {
  .btn-add-building {
    padding: 0.5rem 0.875rem;
  }

  .btn-add-building__label {
    display: inline;
  }
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--primary);
}

.search-bar {
  position: relative;
  margin-bottom: 1rem;
}

.search-bar__icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  line-height: 1;
  pointer-events: none;
}

.search-bar__input {
  padding-left: 2.5rem;
}

.buildings-list {
  display: grid;
  gap: 0.75rem;
}

.building-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.building-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(15, 27, 54, 0.12);
}

.building-card__name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.building-card__address {
  font-size: 0.75rem;
  color: var(--muted-light);
}

.empty-state {
  margin: 1.5rem 0 0;
  text-align: center;
  font-size: 0.9375rem;
  color: var(--muted);
}

.detail-meta {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.detail-notes {
  margin: 1rem 0 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.detail-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.detail-actions .btn {
  width: auto;
  flex: 1;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.form-actions .btn-ghost {
  margin-top: 0;
  text-align: center;
  text-decoration: none;
}

.input--textarea {
  min-height: 5rem;
  resize: vertical;
}

.btn-sm {
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-danger {
  background: var(--error);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #991b1b;
}

.trash-list {
  display: grid;
  gap: 0.75rem;
}

.trash-item__header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.trash-item__meta,
.trash-item__reason {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.trash-item .btn {
  margin-top: 1rem;
  width: auto;
}

/* Modal (suppression immeuble) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 27, 54, 0.45);
  z-index: 200;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 201;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.modal__card {
  width: 100%;
  max-width: var(--max-width);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 12px 48px rgba(15, 27, 54, 0.2);
  padding: 1.5rem;
}

.modal__title {
  margin: 0 0 0.75rem;
  font-size: 1.125rem;
  font-weight: 700;
}

.modal__text {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.5;
}

.modal__actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.modal__actions .btn {
  width: 100%;
}

.modal__actions .btn-ghost {
  margin-top: 0;
}

.form__fieldset {
  margin: 0;
  padding: 0;
  border: none;
}

.form__legend {
  margin: 0 0 0.75rem;
  padding: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.form__row {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 0.75rem;
}

.address-autocomplete-wrap {
  position: relative;
}

.address-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 280px;
  overflow-y: auto;
  z-index: 1000;
}

.address-suggestions.hidden {
  display: none;
}

.suggestion-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-bottom: 1px solid #f3f4f6;
  background: none;
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}

.suggestion-item:hover,
.suggestion-item:focus-visible {
  background: #f9fafb;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.address-suggestions__empty {
  margin: 0;
  padding: 10px 14px;
  font-size: 0.8125rem;
  color: var(--muted);
}

.form__field-error {
  display: none;
  margin: 0.375rem 0 0;
  font-size: 0.8125rem;
  color: var(--error);
  line-height: 1.4;
}

.form__field-error.is-visible {
  display: block;
}

.trash-item__location {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted-light);
}

@media (min-width: 520px) {
  .page__main {
    padding-top: 1.5rem;
  }

  .header__logo {
    height: 100px;
    max-width: 280px;
  }

  .btn-header-home {
    padding: 0.5rem 0.875rem;
  }

  .btn-header-home__label {
    display: inline;
  }

  .form-actions {
    flex-direction: row;
  }

  .form-actions .btn-primary {
    flex: 1;
  }

  .form-actions .btn-ghost {
    flex: 0 0 auto;
    width: auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .modal__actions {
    flex-direction: row-reverse;
    justify-content: flex-start;
  }

  .modal__actions .btn {
    width: auto;
    flex: 1;
  }
}
