/* Copyright 2025-2026 Renofy Ltd. All rights reserved. */
/* === Base Styles === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  color: var(--color-text-primary);
  background-color: var(--color-bg-light);
}

/* === Prevent zoom on input boxes in iOS when text is smaller than 16px === */
input,
textarea,
select {
  font-size: 16px;
  font-family: var(--font-sans);
  font-weight: var(--font-weight-regular);
}

/* === Layout === */
img {
  max-width: 100%;
  height: auto;
}

/* Mobile body background */
body {
  background-color: var(--color-white);
}

body.page-auth,
body.signup-wizard-page {
  background-color: var(--color-bg-light);
}

/* Mobile main layout */
main {
  margin-top: var(--height-header);
}

/* Only pages with bottom nav need bottom margin */
body:has(header[data-level="home"]) main,
body:has(header[data-level="section"]) main {
  padding-bottom: var(--height-bottom-nav);
}

/* Section-level pages that hide bottom nav don't need the padding */
body.signup-wizard-page:has(header[data-level="section"]) main {
  padding-bottom: 0;
}

/* Level 2 pages without bottom navigation */
body:has(header[data-level="detail"]) main,
body:has(header[data-level="messages"]) main,
body:has(header[data-level="workflow"]) main {
  margin-bottom: 0;
}

/* Desktop styles */
@media (min-width: 821px) {
  /* Desktop background */
  body {
    background-color: var(--color-bg-light);
  }

  /* Desktop main layout */
  main {
    margin-block-start: calc(var(--height-header) + 1rem);
    margin-block-end: 1rem;
    padding-inline: clamp(1rem, 2vw, 2rem);
  }

  /* Remove main spacing on home page - sections handle their own spacing */
  body.page-home main {
    margin-block-end: 0;
    padding-inline: 0;
  }
}

/* === Django Messages === */
.messages-container {
  position: sticky;
  top: 0;
  z-index: var(--z-index-header);
  margin-bottom: 1rem;
}

.alert {
  padding: 1rem 1.5rem;
  margin: 0.5rem 1rem;
  border-radius: var(--radius-base);
  font-weight: 500;
}

.alert-success {
  background-color: #d1fae5;
  border: 1px solid #059669;
  color: #065f46;
}

.alert-error {
  background-color: #fee2e2;
  border: 1px solid #dc2626;
  color: #991b1b;
}

.alert-warning {
  background-color: #fef3cd;
  border: 1px solid #d97706;
  color: #92400e;
}

.alert-info {
  background-color: #e7f3ff;
  border: 1px solid #2563eb;
  color: #1e40af;
}

/* === Accessibility & Touch Improvements === */
/* Mobile tap highlight - only applies on touch devices */
button,
.button,
input,
textarea,
select,
a,
[role="button"],
[onclick],
label {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Keyboard navigation focus - shows outline on Tab, hidden on click */
button:focus-visible,
.button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* === PWA Standalone Mode === */
/* Disable double-tap zoom in PWA mode for native app-like experience */
@media (display-mode: standalone) {
  * {
    touch-action: manipulation;
  }
}
