/* ============================================
   Quick Return - App-like Design System
   Octagon motif, mobile-native feel
   ============================================ */

/* --- Reset & Base --- */
html { scroll-padding-top: 80px; }
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --clr-bg: #faf9f7;
  --clr-surface: #ffffff;
  --clr-primary: #2d6a5a;
  --clr-primary-hover: #235548;
  --clr-primary-light: #e8f3ef;
  --clr-accent: #e8734a;
  --clr-accent-hover: #d4632e;
  --clr-accent-light: #fef0eb;
  --clr-text: #1a1a1a;
  --clr-text-muted: #7a7a7a;
  --clr-border: #eae8e4;
  --clr-danger: #c0392b;
  --clr-success: #1a9956;
  --clr-success-light: #e6f7ee;
  --oct: 12px;  /* octagon corner cut size */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 100px;
  --shadow: 0 1px 8px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
  --max-width: 430px;
  --transition: 0.18s ease;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* --- Octagon clip-path helper --- */
.oct-clip {
  clip-path: polygon(
    var(--oct) 0%, calc(100% - var(--oct)) 0%,
    100% var(--oct), 100% calc(100% - var(--oct)),
    calc(100% - var(--oct)) 100%, var(--oct) 100%,
    0% calc(100% - var(--oct)), 0% var(--oct)
  );
}

/* --- Layout --- */
.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 0 calc(24px + var(--safe-bottom));
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--clr-surface);
}

.page-padded {
  padding-left: 20px;
  padding-right: 20px;
  padding-top: 20px;
}

.page-center {
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 24px 20px;
}

.section {
  padding: 0 20px;
}

/* --- Typography --- */
h1 {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--clr-text);
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

p {
  color: var(--clr-text-muted);
  margin-bottom: 12px;
}

a {
  color: var(--clr-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

small, .text-sm {
  font-size: 0.8125rem;
}

/* --- Logo / Brand --- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  position: relative;
}

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

.brand-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--clr-text);
}

/* --- Top Bar --- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  border-bottom: 1px solid var(--clr-border);
}

.top-bar .brand {
  margin-bottom: 0;
}

.top-bar-action {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--clr-accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 8px 0;
}

/* --- Card --- */
.card {
  background: var(--clr-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--clr-border);
}

.card-flat {
  box-shadow: none;
  border: none;
  border-radius: 0;
  padding: 20px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 24px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  text-align: center;
  -webkit-user-select: none;
  user-select: none;
  min-height: 50px;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: scale(0.98);
  box-shadow: none;
}

.btn-primary {
  background: var(--clr-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--clr-primary-hover);
}

.btn-accent {
  background: var(--clr-accent);
  color: white;
}

.btn-accent:hover {
  background: var(--clr-accent-hover);
}

.btn-outline {
  background: transparent;
  color: var(--clr-primary);
  border: 2px solid var(--clr-border);
}

.btn-outline:hover {
  background: var(--clr-primary-light);
  border-color: var(--clr-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--clr-text-muted);
  font-weight: 500;
  padding: 10px;
}

.btn-sm {
  padding: 10px 18px;
  font-size: 0.875rem;
  min-height: 40px;
}

.btn-icon-left {
  padding-left: 18px;
}

.btn + .btn {
  margin-top: 10px;
}

.btn-row {
  display: flex;
  gap: 10px;
}

.btn-row .btn {
  flex: 1;
  margin-top: 0;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* --- Forms --- */
.form-group {
  margin-bottom: 18px;
  text-align: left;
}

label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--clr-text);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 13px 16px;
  font-size: 1rem;
  border: 1.5px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: var(--clr-bg);
  color: var(--clr-text);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
  -webkit-appearance: none;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(45,106,90,0.1);
  background: var(--clr-surface);
}

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

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a7a7a' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--clr-text-muted);
  margin-top: 5px;
}

/* --- File Upload (octagon frame) --- */
.file-upload {
  border: 2px dashed var(--clr-border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.file-upload:hover {
  border-color: var(--clr-primary);
  background: var(--clr-primary-light);
}

.file-upload input[type="file"] {
  display: none;
}

.file-upload-label {
  font-size: 0.875rem;
  color: var(--clr-text-muted);
}

.file-upload-label strong {
  color: var(--clr-primary);
}

.file-preview {
  margin-top: 12px;
  display: none;
  text-align: center;
}

.file-preview img {
  width: 180px;
  height: 180px;
  object-fit: cover;
  clip-path: polygon(
    15% 0%, 85% 0%, 100% 15%, 100% 85%,
    85% 100%, 15% 100%, 0% 85%, 0% 15%
  );
}

/* --- Alerts --- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 16px;
  display: none;
}

.alert-error {
  background: #fdecea;
  color: var(--clr-danger);
}

.alert-success {
  background: var(--clr-success-light);
  color: var(--clr-success);
}

.alert.show {
  display: block;
}

/* --- Pill badges --- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  background: var(--clr-bg);
  color: var(--clr-text);
  border-radius: var(--radius-pill);
  border: 1px solid var(--clr-border);
}

.pill-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--clr-text-muted);
  font-weight: 500;
}

.pill-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 12px 0;
}

/* --- Contact card (Crumb-style) --- */
.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--clr-border);
}

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

.contact-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--clr-bg);
  border: 1.5px solid var(--clr-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--clr-text);
  flex-shrink: 0;
  text-transform: uppercase;
}

.contact-info {
  flex: 1;
  min-width: 0;
}

.contact-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--clr-text);
}

.contact-role {
  font-size: 0.75rem;
  color: var(--clr-text-muted);
}

.contact-actions {
  display: flex;
  gap: 6px;
}

.contact-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  min-height: 36px;
  white-space: nowrap;
}

.contact-btn-call {
  background: var(--clr-accent);
  color: white;
}

.contact-btn-call:hover {
  background: var(--clr-accent-hover);
}

.contact-btn-text {
  background: var(--clr-primary);
  color: white;
}

.contact-btn-text:hover {
  background: var(--clr-primary-hover);
}

/* --- Dividers --- */
.divider {
  border: none;
  border-top: 1px solid var(--clr-border);
  margin: 16px 0;
}

/* --- Section Headers --- */
.section-header {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--clr-text-muted);
  padding: 16px 0 8px;
}

/* --- Homepage --- */
.hero-tagline {
  font-size: 1.05rem;
  color: var(--clr-text-muted);
  margin-bottom: 28px;
  line-height: 1.5;
}

.features {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 28px 0;
}

.feature {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  text-align: left;
}

.feature-icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  background: var(--clr-primary-light);
  color: var(--clr-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  clip-path: polygon(
    20% 0%, 80% 0%, 100% 20%, 100% 80%,
    80% 100%, 20% 100%, 0% 80%, 0% 20%
  );
}

.feature-text h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 2px;
  color: var(--clr-text);
}

.feature-text p {
  font-size: 0.8125rem;
  margin-bottom: 0;
}

/* --- Dynamic contact form (register page) --- */
.contact-form-item {
  background: var(--clr-bg);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  position: relative;
  border: 1px solid var(--clr-border);
}

.contact-form-item .form-group {
  margin-bottom: 10px;
}

.contact-form-item .form-group:last-child {
  margin-bottom: 0;
}

.contact-form-row {
  display: flex;
  gap: 8px;
}

.contact-form-row .form-group {
  flex: 1;
}

.contact-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--clr-border);
  color: var(--clr-text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  line-height: 1;
}

.contact-remove:hover {
  background: var(--clr-danger);
  color: white;
}

.add-contact-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 12px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--clr-primary);
  background: var(--clr-primary-light);
  border: 1.5px dashed var(--clr-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.add-contact-btn:hover {
  background: var(--clr-primary);
  color: white;
}

/* --- Spinner --- */
.spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.btn .spinner { display: none; }
.btn.loading .spinner { display: block; }
.btn.loading .btn-text { opacity: 0.5; }

/* --- Footer --- */
.footer {
  margin-top: auto;
  padding: 24px 20px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--clr-text-muted);
}

/* --- Utility --- */
.hidden { display: none !important; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-muted { color: var(--clr-text-muted); }

/* --- Responsive --- */
@media (min-width: 480px) {
  .page {
    margin-top: 32px;
    margin-bottom: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-height: auto;
  }
}

@media (min-width: 768px) {
  .page {
    max-width: 580px;
    margin-top: 48px;
    margin-bottom: 48px;
  }
}

@media (min-width: 1024px) {
  .page {
    max-width: 640px;
    margin-top: 64px;
    margin-bottom: 64px;
  }

  .page-padded {
    padding-left: 40px;
    padding-right: 40px;
  }
}

@media (min-width: 1280px) {
  .page {
    max-width: 720px;
  }
}

/* Full-width pages (homepage) bypass the narrow app shell on desktop */
.page-wide {
  max-width: 100%;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  min-height: 100vh;
  min-height: 100dvh;
}

@media (min-width: 480px) {
  .page-wide {
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    min-height: 100vh;
    min-height: 100dvh;
  }
}

@media (min-width: 768px) {
  .page-wide {
    max-width: 100%;
  }
}
