/* =========================================================================
   HK Tenancy Agreement Form System — stylesheet
   ========================================================================= */

:root {
  --primary: #1a5fb4;
  --primary-dark: #144a8c;
  --success: #2e9e5b;
  --danger: #c0392b;
  --warning: #b7791f;
  --info: #2b6cb0;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }
main.container { flex: 1; padding-top: 1.75rem; padding-bottom: 3rem; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); font-size: 0.9rem; }
.text-right { text-align: right; }
.hint { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 0.25rem; }

/* ------------------------------------------------------------------ Nav */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 1rem; font-size: 0.95rem; }
.nav-user { color: var(--muted); font-weight: 600; }

/* -------------------------------------------------------------- Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #247b49; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-block { display: block; width: 100%; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1.05rem; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.85rem; }

/* ---------------------------------------------------------------- Flash */
.flash-area { margin-bottom: 1.25rem; }
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  border: 1px solid transparent;
}
.alert-success { background: #e6f6ec; border-color: #bfe6cd; color: #1d6b3c; }
.alert-danger { background: #fdecea; border-color: #f5c6c0; color: #a93226; }
.alert-warning { background: #fdf3e2; border-color: #f2d9ac; color: #8a5a15; }
.alert-info { background: #e8f1fb; border-color: #c3dcf5; color: #1d4f91; }

/* ---------------------------------------------------------------- Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  overflow-x: auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.page-header h1 { margin: 0; font-size: 1.6rem; }

/* ---------------------------------------------------------------- Hero */
.hero {
  text-align: center;
  padding: 3.5rem 1rem;
  background: linear-gradient(135deg, #1a5fb4, #2b6cb0);
  color: #fff;
  border-radius: var(--radius);
  margin-bottom: 2rem;
}
.hero h1 { font-size: 2.2rem; margin: 0 0 0.75rem; }
.hero p { max-width: 640px; margin: 0 auto 1.5rem; font-size: 1.05rem; opacity: 0.95; }
.hero-actions { display: flex; gap: 0.75rem; justify-content: center; }
.hero .btn-outline { color: #fff; border-color: rgba(255, 255, 255, 0.6); background: transparent; }
.hero .btn-outline:hover { background: rgba(255, 255, 255, 0.12); }

/* ------------------------------------------------------------- Features */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.25rem;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.feature-card h3 { margin-top: 0; margin-bottom: 0.5rem; }

/* --------------------------------------------------------------- Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  text-align: center;
}
.stat-number { display: block; font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--muted); }

/* --------------------------------------------------------------- Table */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; }
.table tr:last-child td { border-bottom: none; }
.inline-form { display: inline-block; margin-left: 0.35rem; }

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
}

/* ------------------------------------------------------------- Auth card */
.auth-card {
  max-width: 440px;
  margin: 2rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}
.auth-card h2 { margin-top: 0; }

/* ---------------------------------------------------------------- Forms */
label { display: block; margin-bottom: 0.35rem; font-weight: 600; font-size: 0.95rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  margin-bottom: 1rem;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 95, 180, 0.15);
}
input.input-error, select.input-error, textarea.input-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.15);
}
.field-error {
  display: block;
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}
.wizard-errors ul { margin: 0.35rem 0 0; padding-left: 1.2rem; }
label.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
  margin-bottom: 0.75rem;
}
label.checkbox input { width: auto; margin: 0; }
.checkbox-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.4rem 1rem; }
.checkbox-group label { font-weight: 400; display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.2rem; }
.checkbox-group input { width: auto; }

/* ----------------------------------------------------------- Search bar */
.search-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}
.search-bar input { margin-bottom: 0; flex: 1; min-width: 160px; }
.search-bar .inline-label { display: flex; flex-direction: column; font-size: 0.85rem; color: var(--muted); gap: 0.3rem; }

/* ---------------------------------------------------------------- Wizard */
.wizard { max-width: 860px; margin: 0 auto; }
.steps {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0 0 1.75rem;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.steps .step {
  flex: 1;
  min-width: 96px;
  text-align: center;
  padding: 0.6rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: default;
}
.steps .step.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.steps .step.done { background: #e6f6ec; border-color: #bfe6cd; color: #1d6b3c; }

.form-step { display: none; }
.form-step.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.form-step h2 {
  border-bottom: 2px solid var(--primary);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
.field.full { grid-column: 1 / -1; }

.wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.wizard-nav #submit-btn { margin-left: auto; }

.review-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.review-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.review-section h4 { margin: 0 0 0.75rem; color: var(--primary); }
.review-section dl { margin: 0; display: grid; grid-template-columns: 40% 60%; gap: 0.35rem 0.5rem; }
.review-section dt { color: var(--muted); font-size: 0.85rem; }
.review-section dd { margin: 0; font-size: 0.9rem; word-break: break-word; }
.confirm-box { margin-top: 1rem; font-weight: 600 !important; }

/* -------------------------------------------------------- Agreement doc */
.agreement-toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.agreement-document {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 3rem 3.5rem;
  max-width: 900px;
  margin: 0 auto;
}
.agreement-header { text-align: center; margin-bottom: 2rem; }
.agreement-header h1 { margin: 0; font-size: 1.8rem; }
.agreement-header h2 { margin: 0.25rem 0; font-size: 1.05rem; letter-spacing: 0.06em; color: var(--muted); }
.agreement-date { color: var(--muted); font-size: 0.9rem; }
.clauses { list-style: none; padding: 0; margin: 0; }
.clauses li { margin-bottom: 1.1rem; }
.clauses h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.clauses p { margin: 0; text-align: justify; }

.signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  margin-top: 2.5rem;
}
.signature { text-align: center; }
.sign-line { border-top: 1px solid var(--text); margin-bottom: 0.5rem; padding-top: 1.5rem; }
.sign-name { font-weight: 700; margin: 0; }

/* ---------------------------------------------------------------- Footer */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* -------------------------------------------------------------- Responsive */
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .agreement-document { padding: 1.5rem 1.25rem; }
  .signatures { grid-template-columns: 1fr; gap: 1.5rem; }
  .nav-links { gap: 0.6rem; font-size: 0.85rem; }
  .hero h1 { font-size: 1.6rem; }
}

/* ---------------------------------------------------------------- Print */
@media print {
  .navbar, .footer, .flash-area, .no-print, .agreement-toolbar { display: none !important; }
  body { background: #fff; }
  .agreement-document { box-shadow: none; border: none; padding: 0; max-width: none; }
  main.container { padding: 0; max-width: none; }
}
