/* ─────────────────────────────────────────────
   ILANZ AMC Portal — Main Stylesheet
   ───────────────────────────────────────────── */

:root {
  --primary:      #1a4f8a;
  --primary-dark: #123a66;
  --primary-light:#e8f0fb;
  --accent:       #e87722;
  --success:      #198754;
  --warning:      #e6a817;
  --danger:       #c0392b;
  --info:         #0d6efd;
  --gray-50:      #f8f9fa;
  --gray-100:     #f1f3f5;
  --gray-200:     #e9ecef;
  --gray-400:     #ced4da;
  --gray-600:     #6c757d;
  --gray-800:     #343a40;
  --text:         #212529;
  --radius:       6px;
  --shadow:       0 1px 4px rgba(0,0,0,.10);
  --shadow-md:    0 4px 16px rgba(0,0,0,.12);
  --sidebar-w:    240px;
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--gray-100);
  min-height: 100vh;
}

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

/* ── Layout ─────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--primary-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-logo .app-name {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  display: block;
}
.sidebar-logo .app-sub {
  font-size: 11px;
  color: rgba(255,255,255,.55);
  margin-top: 2px;
  display: block;
}

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.4);
  padding: 14px 18px 4px;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: rgba(255,255,255,.82);
  font-size: 13.5px;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,.10);
  color: #fff;
  border-left-color: var(--accent);
  text-decoration: none;
}
.sidebar-nav a .icon { font-size: 16px; width: 18px; text-align: center; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: 12px;
  color: rgba(255,255,255,.5);
}
.sidebar-footer .user-name { color: #fff; font-weight: 600; font-size: 13px; }

.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-title { font-size: 17px; font-weight: 600; color: var(--primary); }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.content { padding: 28px; flex: 1; }

/* ── Cards ──────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  margin-bottom: 24px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h2 { font-size: 15px; font-weight: 600; color: var(--primary); margin: 0; }
.card-body { padding: 20px; }

/* ── Stat cards (dashboard) ─────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.stat-card.green  { border-left-color: var(--success); }
.stat-card.amber  { border-left-color: var(--warning); }
.stat-card.red    { border-left-color: var(--danger); }
.stat-card.blue   { border-left-color: var(--info); }
.stat-card.orange { border-left-color: var(--accent); }
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card.green  .stat-value { color: var(--success); }
.stat-card.amber  .stat-value { color: var(--warning); }
.stat-card.red    .stat-value { color: var(--danger); }
.stat-card.blue   .stat-value { color: var(--info); }
.stat-card.orange .stat-value { color: var(--accent); }
.stat-label { font-size: 12px; color: var(--gray-600); margin-top: 4px; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover  { background: #146c43; text-decoration: none; color: #fff; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-warning:hover  { background: #c58a00; text-decoration: none; color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover   { background: #a93226; text-decoration: none; color: #fff; }
.btn-outline  { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover  { background: var(--primary-light); text-decoration: none; }
.btn-gray     { background: var(--gray-200); color: var(--gray-800); border-color: var(--gray-400); }
.btn-gray:hover     { background: var(--gray-400); text-decoration: none; color: var(--gray-800); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Forms ──────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--gray-600); text-transform: uppercase; letter-spacing: .04em; }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 10px;
  border: 1px solid var(--gray-400);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,79,138,.12);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11px; color: var(--gray-600); }

/* ── Radio/toggle groups ─────────────────────── */
.radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-btn input[type=radio] { display: none; }
.radio-btn label {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border: 1px solid var(--gray-400);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
  color: var(--gray-800);
}
.radio-btn input[type=radio]:checked + label {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── Tables ──────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--gray-50);
  padding: 10px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-600);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13.5px;
  vertical-align: middle;
}
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges / Status ─────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-open        { background: #dbeafe; color: #1e40af; }
.badge-in-progress { background: #fef3c7; color: #92400e; }
.badge-pending     { background: #ffe4e6; color: #9f1239; }
.badge-completed   { background: #dcfce7; color: #166534; }
.badge-amc         { background: #e0f2fe; color: #0369a1; }
.badge-project     { background: #f3e8ff; color: #7c3aed; }
.badge-noncontract { background: var(--gray-200); color: var(--gray-600); }
.badge-chargeable  { background: #fde68a; color: #92400e; }
.badge-noncharge   { background: #d1fae5; color: #065f46; }
.badge-onsite      { background: #dbeafe; color: #1e40af; }
.badge-remote      { background: #e0e7ff; color: #3730a3; }

/* ── Alerts / Flash ──────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* ── Search / Filter bar ─────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 14px 20px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
.filter-bar .form-group { gap: 3px; }
.filter-bar input,
.filter-bar select { padding: 7px 9px; font-size: 13px; }

/* ── Pagination ──────────────────────────────── */
.pagination { display: flex; gap: 6px; align-items: center; margin-top: 16px; }
.pagination a,
.pagination span {
  padding: 5px 11px;
  border: 1px solid var(--gray-400);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--primary);
}
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination a:hover  { background: var(--primary-light); text-decoration: none; }

/* ── Version history ─────────────────────────── */
.version-timeline { list-style: none; padding: 0; }
.version-timeline li {
  display: flex;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--gray-100);
}
.version-badge {
  min-width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.version-badge.current { background: var(--accent); }
.version-info { flex: 1; }
.version-info strong { font-size: 14px; }
.version-info .meta { font-size: 12px; color: var(--gray-600); margin-top: 2px; }

/* ── Report detail view ──────────────────────── */
.report-section {
  margin-bottom: 18px;
}
.report-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-600);
  font-weight: 700;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--gray-200);
}
.report-field { display: flex; gap: 8px; margin-bottom: 8px; }
.report-field-label { font-size: 12px; color: var(--gray-600); min-width: 150px; font-weight: 600; }
.report-field-value { font-size: 13.5px; }
.report-text-block {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  min-height: 48px;
}

/* ── Login page ──────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}
.login-box {
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 40px 44px;
  width: 100%;
  max-width: 420px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-text { font-size: 26px; font-weight: 800; color: var(--primary); }
.login-logo .logo-sub  { font-size: 12px; color: var(--gray-600); margin-top: 4px; }

/* ── Misc ────────────────────────────────────── */
.text-muted  { color: var(--gray-600); }
.text-small  { font-size: 12px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16{ margin-top: 16px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.ml-auto { margin-left: auto; }
hr { border: none; border-top: 1px solid var(--gray-200); margin: 20px 0; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}

/* ── Attachment grid ─────────────────────────────────────────── */
.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.att-thumb {
  position: relative;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--gray-50);
}

.att-thumb img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

.att-name {
  font-size: 10px;
  padding: 4px 6px;
  color: var(--gray-600);
  background: #fafafa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top: 1px solid var(--gray-200);
}

.att-caption {
  font-size: 10px;
  padding: 2px 6px 4px;
  color: var(--primary);
  font-style: italic;
}

.att-del {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(192,57,43,.85);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background .15s;
}

.att-del:hover { background: var(--danger); }

/* ── Customer search dropdown ─────────────────────────────────── */
.dd-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--gray-100);
  transition: background .1s;
}
.dd-item:hover { background: var(--primary-light); }
.dd-item:last-child { border-bottom: none; }

/* ── Acknowledged / locked badge ─────────────────────────────── */
.badge-locked { background: #fde68a; color: #92400e; }

/* ── Report index ack column ─────────────────────────────────── */
.ack-dot { display:inline-block; width:8px; height:8px; border-radius:50%; background:var(--success); margin-right:4px; }
