/* HA-WA Portal — Brand Design */
:root {
  --blue:    #04519b;
  --blue-d:  #033d75;
  --blue-l:  #e8f0fa;
  --green:   #2b694d;
  --green-d: #1f4e39;
  --green-l: #e6f3ec;
  --gray-50: #f8f9fa;
  --gray-100:#f1f3f5;
  --gray-200:#e9ecef;
  --gray-300:#dee2e6;
  --gray-400:#ced4da;
  --gray-500:#adb5bd;
  --gray-600:#6c757d;
  --gray-700:#495057;
  --gray-800:#343a40;
  --gray-900:#212529;
  --red:     #dc3545;
  --orange:  #fd7e14;
  --yellow:  #ffc107;
  --shadow:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:0 4px 12px rgba(0,0,0,.1);
  --radius:  8px;
}

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

html { font-size: 15px; }
body {
  font-family: 'Nunito', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── NAVBAR ─────────────────────────────── */
.navbar {
  background: var(--blue);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  position: sticky; top: 0; z-index: 100;
}
.navbar-inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0 1.5rem; height: 60px;
}
.navbar-brand {
  display: flex; align-items: center; gap: .6rem;
  text-decoration: none; flex-shrink: 0;
}
.navbar-logo { height: 34px; }
.navbar-title {
  color: rgba(255,255,255,.7); font-size: .8rem;
  font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
}
.navbar-links {
  display: flex; align-items: center; gap: .25rem; flex: 1;
}
.nav-link {
  color: rgba(255,255,255,.85); font-size: .9rem; font-weight: 600;
  padding: .4rem .8rem; border-radius: 6px;
  transition: background .15s;
  text-decoration: none;
}
.nav-link:hover { background: rgba(255,255,255,.12); text-decoration: none; color: #fff; }
.nav-link-cta {
  background: var(--green); color: #fff !important;
  margin-left: .5rem;
}
.nav-link-cta:hover { background: var(--green-d); }
.navbar-user {
  display: flex; align-items: center; gap: .75rem; flex-shrink: 0;
}
.user-badge {
  color: rgba(255,255,255,.8); font-size: .85rem; font-weight: 600;
}
.btn-logout {
  background: rgba(255,255,255,.15); color: #fff;
  border-radius: 6px; padding: .3rem .75rem;
  font-size: .8rem; font-weight: 600;
  transition: background .15s; text-decoration: none;
}
.btn-logout:hover { background: rgba(255,255,255,.25); text-decoration: none; }

/* ── LOGIN PAGE ─────────────────────────── */
.login-page {
  flex: 1; display: flex; align-items: center;
  justify-content: center; padding: 2rem 1rem;
  background: linear-gradient(135deg, var(--blue) 0%, #0369c7 50%, var(--green) 100%);
}
.login-card {
  background: #fff; border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 2.5rem; width: 100%; max-width: 420px;
}
.login-card-wide { max-width: 640px; }
.login-logo { text-align: center; margin-bottom: 1.5rem; }
.login-logo-img { height: 48px; }
.login-portal-label {
  display: block; color: var(--gray-500);
  font-size: .8rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; margin-top: .25rem;
}
.login-title {
  text-align: center; font-size: 1.4rem;
  color: var(--gray-800); margin-bottom: 1.5rem;
}
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-register {
  text-align: center; margin-top: 1.25rem;
  font-size: .875rem; color: var(--gray-600);
}

/* ── PAGE CONTAINER ─────────────────────── */
.page-container {
  max-width: 1280px; margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem; flex: 1; width: 100%;
}
.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem;
}
.page-title {
  font-size: 1.6rem; font-weight: 800; color: var(--gray-900);
}
.back-link {
  display: block; color: var(--gray-500);
  font-size: .85rem; margin-bottom: .25rem;
}
.back-link:hover { color: var(--blue); }

/* ── CARDS ──────────────────────────────── */
.card {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--gray-200);
}
.card-centered { max-width: 720px; }
.card-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
}
.card-title { font-size: 1rem; font-weight: 700; color: var(--gray-800); }
.card-body { padding: 1.25rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }

/* ── STATS GRID ─────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.stats-small .stat-card { padding: 1rem; }
.stat-card {
  background: #fff; border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow); border: 1px solid var(--gray-200);
  border-left: 4px solid transparent;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-card .stat-label { font-size: .8rem; color: var(--gray-500); margin-top: .25rem; }
.stat-blue   { border-left-color: var(--blue); }
.stat-blue   .stat-value { color: var(--blue); }
.stat-green  { border-left-color: var(--green); }
.stat-green  .stat-value { color: var(--green); }
.stat-red    { border-left-color: var(--red); }
.stat-red    .stat-value { color: var(--red); }
.stat-orange { border-left-color: var(--orange); }
.stat-orange .stat-value { color: var(--orange); }
.stat-yellow { border-left-color: var(--yellow); }
.stat-yellow .stat-value { color: #856404; }
.stat-gray   { border-left-color: var(--gray-400); }
.stat-gray   .stat-value { color: var(--gray-700); }
.stat-teal   { border-left-color: #0d9488; }
.stat-teal   .stat-value { color: #0d9488; }

/* ── TABLE ──────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th {
  background: var(--gray-50); color: var(--gray-600);
  font-size: .75rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; padding: .6rem 1rem;
  border-bottom: 1px solid var(--gray-200); white-space: nowrap;
  text-align: left;
}
.table td {
  padding: .75rem 1rem; border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--blue-l); }
.row-inactive { opacity: .5; }
.link-mono { font-family: monospace; font-size: .85rem; font-weight: 700; color: var(--blue); }

/* ── BADGES ─────────────────────────────── */
.badge {
  display: inline-block; padding: .2rem .6rem;
  border-radius: 999px; font-size: .72rem; font-weight: 700;
  letter-spacing: .04em; white-space: nowrap;
}
.badge-lg { font-size: .85rem; padding: .35rem .9rem; }
.badge-new      { background: #dbeafe; color: #1e40af; }
.badge-review   { background: #fef9c3; color: #854d0e; }
.badge-assigned { background: #ede9fe; color: #5b21b6; }
.badge-progress { background: #ffedd5; color: #9a3412; }
.badge-question { background: #fce7f3; color: #9d174d; }
.badge-done     { background: #dcfce7; color: #14532d; }
.badge-closed   { background: var(--gray-200); color: var(--gray-700); }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-internal { background: #fef3c7; color: #92400e; font-size: .7rem; }
.badge-staff    { background: var(--blue-l); color: var(--blue); font-size: .7rem; }
.badge-count    { background: var(--gray-200); color: var(--gray-700); font-size: 1rem; }

.role-badge { display: inline-block; padding: .15rem .5rem; border-radius: 4px; font-size: .75rem; font-weight: 700; }
.role-admin      { background: #fee2e2; color: #991b1b; }
.role-technician { background: #dbeafe; color: #1e40af; }
.role-customer   { background: #dcfce7; color: #14532d; }

/* ── PRIORITY ───────────────────────────── */
.priority-low    { color: var(--gray-500); font-weight: 600; }
.priority-normal { color: var(--gray-700); font-weight: 600; }
.priority-high   { color: var(--orange); font-weight: 700; }
.priority-urgent { color: var(--red); font-weight: 800; }

/* ── BUTTONS ────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .5rem 1rem; border-radius: 6px;
  font-family: inherit; font-size: .875rem; font-weight: 700;
  cursor: pointer; border: none; transition: all .15s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-d); color: #fff; }
.btn-outline { background: transparent; color: var(--blue); border: 1.5px solid var(--blue); }
.btn-outline:hover { background: var(--blue-l); }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn-xs { padding: .2rem .5rem; font-size: .75rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-group { display: flex; gap: .35rem; flex-wrap: wrap; }

/* ── FORMS ──────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-group label {
  font-size: .8rem; font-weight: 700;
  color: var(--gray-700); letter-spacing: .03em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: .5rem .75rem;
  border: 1.5px solid var(--gray-300); border-radius: 6px;
  font-family: inherit; font-size: .9rem; color: var(--gray-800);
  background: #fff; transition: border .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(4,81,155,.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.form-divider { border: none; border-top: 1px solid var(--gray-200); margin: 1rem 0; }
.form-section-label { font-size: .8rem; font-weight: 700; color: var(--gray-500); margin-bottom: .5rem; }
.form-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1rem; }
.checkbox-label { display: flex; align-items: center; gap: .4rem; font-size: .875rem; cursor: pointer; }

/* ── FILTER BAR ─────────────────────────── */
.filter-bar {
  display: flex; align-items: center;
  gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.filter-input {
  flex: 1; min-width: 200px; padding: .45rem .75rem;
  border: 1.5px solid var(--gray-300); border-radius: 6px;
  font-family: inherit; font-size: .875rem;
}
.filter-input:focus { outline: none; border-color: var(--blue); }
.filter-select {
  padding: .45rem .7rem; border: 1.5px solid var(--gray-300);
  border-radius: 6px; font-family: inherit; font-size: .875rem;
  background: #fff; cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--blue); }

/* ── FLASH MESSAGES ─────────────────────── */
.flash {
  padding: .75rem 1rem; border-radius: 6px;
  margin-bottom: 1rem; font-weight: 600; font-size: .875rem;
}
.flash-success { background: var(--green-l); color: var(--green-d); border: 1px solid #86efac; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-info    { background: var(--blue-l); color: var(--blue-d); border: 1px solid #93c5fd; }

/* ── ORDER LAYOUT ───────────────────────── */
.order-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.25rem; align-items: start;
}
.order-main { display: flex; flex-direction: column; gap: 0; }
.order-sidebar { display: flex; flex-direction: column; gap: 1rem; }

/* ── INFO LIST ──────────────────────────── */
.info-list { display: flex; flex-direction: column; gap: .75rem; }
.info-row {
  display: flex; gap: 1rem; align-items: flex-start;
  padding-bottom: .75rem; border-bottom: 1px solid var(--gray-100);
}
.info-row:last-child { border-bottom: none; padding-bottom: 0; }
.info-row > span:first-child {
  min-width: 120px; font-size: .8rem;
  color: var(--gray-500); font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em; flex-shrink: 0;
}

/* ── COMMENTS ───────────────────────────── */
.comment {
  padding: .75rem; border-radius: 8px;
  background: var(--gray-50); margin-bottom: .75rem;
  border-left: 3px solid var(--gray-300);
}
.comment-staff { border-left-color: var(--blue); background: var(--blue-l); }
.comment-internal { border-left-color: var(--yellow); background: #fffbeb; }
.comment-header {
  display: flex; align-items: center;
  gap: .5rem; margin-bottom: .35rem;
  font-size: .8rem;
}
.comment-body { font-size: .875rem; line-height: 1.5; }
.comment-form { margin-top: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.comment-form textarea {
  width: 100%; padding: .5rem .75rem;
  border: 1.5px solid var(--gray-300); border-radius: 6px;
  font-family: inherit; font-size: .875rem; resize: vertical; min-height: 80px;
}
.comment-form textarea:focus { outline: none; border-color: var(--blue); }
.comment-actions { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }

/* ── HISTORY ────────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: .5rem; }
.history-item { display: flex; gap: .75rem; align-items: flex-start; font-size: .8rem; }
.history-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--blue); flex-shrink: 0; margin-top: .35rem;
}

/* ── MODALS ─────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem;
}
.modal {
  background: #fff; border-radius: 12px;
  box-shadow: var(--shadow-md); width: 100%; max-width: 600px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; color: var(--gray-500); padding: .25rem;
}
.modal-close:hover { color: var(--gray-800); }
.modal-body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.modal-footer {
  display: flex; gap: .75rem; justify-content: flex-end;
  padding-top: .5rem; margin-top: .5rem;
  border-top: 1px solid var(--gray-200);
}

/* ── STATUS FORM ────────────────────────── */
.status-form { }
.status-buttons { display: flex; gap: .75rem; flex-wrap: wrap; }

/* ── INFO BOX ───────────────────────────── */
.info-box {
  background: var(--blue-l); border: 1px solid #bfdbfe;
  border-radius: 8px; padding: .75rem 1rem;
  font-size: .85rem; color: var(--blue-d); margin: .75rem 0;
}

/* ── PAGINATION ─────────────────────────── */
.pagination {
  display: flex; gap: .35rem; padding: .75rem 1.25rem;
  border-top: 1px solid var(--gray-200);
}
.page-link {
  padding: .3rem .6rem; border-radius: 4px;
  font-size: .8rem; font-weight: 600; color: var(--gray-600);
  border: 1px solid var(--gray-300); text-decoration: none;
}
.page-link:hover { background: var(--blue-l); color: var(--blue); }
.page-link.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ── UTILS ──────────────────────────────── */
.text-muted  { color: var(--gray-500); }
.text-center { text-align: center; }
.text-sm     { font-size: .8rem; }
.py-4        { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-6        { padding-top: 2rem; padding-bottom: 2rem; }
.mt-2        { margin-top: .5rem; }
.mt-1        { margin-top: .25rem; }
.mb-2        { margin-bottom: .5rem; }
.mx-4        { margin-left: 1rem; margin-right: 1rem; }

/* ── FOOTER ─────────────────────────────── */
.portal-footer {
  text-align: center; padding: 1rem;
  color: var(--gray-500); font-size: .8rem;
  border-top: 1px solid var(--gray-200);
  background: #fff; margin-top: auto;
}
.portal-footer a { color: var(--gray-500); }
.portal-footer a:hover { color: var(--blue); }

/* ── RESPONSIVE ─────────────────────────── */
@media (max-width: 900px) {
  .order-layout { grid-template-columns: 1fr; }
  .order-sidebar { order: -1; }
}
@media (max-width: 640px) {
  .navbar-inner { padding: 0 1rem; }
  .navbar-links { display: none; }
  .page-container { padding: 1rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .filter-bar { flex-direction: column; align-items: stretch; }
}
