/* certificates.css — Certificate tracker page styles */

:root {
  --amber: #F59E0B;
  --amber-dim: #D97706;
  --green: #10B981;
  --red: #EF4444;
  --off-white: #FAFAF8;
  --light-gray: #F3F2EE;
  --mid-gray: #6B7280;
  --dark-gray: #374151;
  --navy: #0D1F3C;
  --navy-mid: #1A3A5C;
  --white: #FFFFFF;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--off-white);
  color: var(--navy);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ─── Page shell ─── */
.cert-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.cert-main {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 2rem 5rem;
  width: 100%;
}
.cert-header { margin-bottom: 2.5rem; }
.cert-header h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 2.2rem;
  color: var(--navy);
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}
.cert-header p { font-size: 1rem; color: var(--dark-gray); }

/* ─── Tabs ─── */
.cert-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--light-gray);
}
.cert-tab {
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--mid-gray);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: color 0.15s;
}
.cert-tab:hover { color: var(--navy); }
.cert-tab.active {
  color: var(--navy);
  border-bottom-color: var(--amber);
}

/* ─── Forms ─── */
.cert-panel { display: none; }
.cert-panel.active { display: block; }

.form-section {
  background: var(--white);
  border: 1px solid var(--light-gray);
  border-radius: 12px;
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}
.form-section h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--light-gray);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-grid--single { grid-template-columns: 1fr; }
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--dark-gray);
  margin-bottom: 0.35rem;
}
.form-label--sub {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--mid-gray);
  margin-top: 0.2rem;
}
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  font-family: inherit;
  border: 1.5px solid #D1D5DB;
  border-radius: 8px;
  background: var(--white);
  color: var(--navy);
  transition: border-color 0.15s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.12);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.85rem center; padding-right: 2.2rem; }
.btn-row { display: flex; gap: 0.75rem; margin-top: 1.25rem; }
.btn {
  padding: 0.65rem 1.4rem;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--amber);
  color: var(--navy);
}
.btn-primary:hover { background: var(--amber-dim); }
.btn-secondary {
  background: var(--light-gray);
  color: var(--dark-gray);
}
.btn-secondary:hover { background: #E5E4E0; }
.btn-danger {
  background: #FEE2E2;
  color: var(--red);
}
.btn-danger:hover { background: #FECACA; }

/* ─── Certificates table ─── */
.cert-table-wrap {
  background: var(--white);
  border: 1px solid var(--light-gray);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.cert-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.cert-table th {
  background: var(--light-gray);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mid-gray);
  white-space: nowrap;
}
.cert-table td {
  padding: 0.85rem 1rem;
  border-top: 1px solid #F3F2EE;
  vertical-align: middle;
}
.cert-table tr:hover td { background: #FAFAF8; }
.cert-table .col-property { min-width: 160px; }
.cert-table .col-type { min-width: 140px; }
.cert-table .col-expiry { min-width: 110px; }
.cert-table .col-days { min-width: 90px; }
.cert-table .col-status { min-width: 110px; }
.cert-table .col-actions { min-width: 100px; text-align: right; }

.prop-label { font-weight: 600; color: var(--navy); display: block; }
.prop-postcode { font-size: 0.78rem; color: var(--mid-gray); margin-top: 0.1rem; }
.cert-type-label { font-weight: 500; color: var(--dark-gray); }
.expiry-date { font-weight: 500; color: var(--navy); }
.days-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
}
.days-badge--current { background: rgba(16,185,105,0.1); color: var(--green); }
.days-badge--warning  { background: rgba(245,158,11,0.12); color: var(--amber-dim); }
.days-badge--expired  { background: rgba(239,68,68,0.1); color: var(--red); }
.status-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 5px;
  letter-spacing: 0.02em;
}
.status-badge--current { background: rgba(16,185,105,0.12); color: var(--green); }
.status-badge--expiring_soon { background: rgba(245,158,11,0.12); color: var(--amber-dim); }
.status-badge--expired { background: rgba(239,68,68,0.12); color: var(--red); }
.status-badge--unknown { background: var(--light-gray); color: var(--mid-gray); }
.action-btns { display: flex; gap: 0.5rem; justify-content: flex-end; }
.btn-icon {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  background: var(--light-gray);
  color: var(--dark-gray);
  transition: background 0.12s;
  text-decoration: none;
  display: inline-block;
}
.btn-icon:hover { background: #E5E4E0; }
.btn-icon--delete { background: #FEE2E2; color: var(--red); }
.btn-icon--delete:hover { background: #FECACA; }

/* ─── Empty state ─── */
.cert-empty {
  background: var(--white);
  border: 1px solid var(--light-gray);
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
}
.cert-empty-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  display: block;
}
.cert-empty h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.5rem;
}
.cert-empty p { font-size: 0.9rem; color: var(--mid-gray); }

/* ─── Compliance window ─── */
.compliance-table th { background: #FFF7ED; }
.compliance-table tr td { background: #FFFBF7; }
.compliance-table tr:hover td { background: #FFF9F2; }
.compliance-label {
  font-size: 0.78rem;
  color: var(--mid-gray);
  margin-top: 0.2rem;
}
.compliance-deadline {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--navy);
}
.compliance-deadline--cert { color: var(--red); }
.compliance-deadline--scheme { color: var(--amber-dim); }
.deadline-note {
  font-size: 0.75rem;
  color: var(--mid-gray);
  margin-top: 0.2rem;
}
.scheme-link {
  font-size: 0.8rem;
  color: var(--navy);
  font-weight: 500;
}
.scheme-link:hover { color: var(--amber-dim); }

/* ─── Modals ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13,31,60,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: 14px;
  width: 100%;
  max-width: 540px;
  padding: 1.75rem;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--light-gray);
}
.modal-close {
  float: right;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--mid-gray);
  line-height: 1;
}
.modal-close:hover { color: var(--navy); }
.modal .form-grid { grid-template-columns: 1fr; }

/* ─── Filter bar ─── */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  align-items: center;
  flex-wrap: wrap;
}
.filter-select {
  padding: 0.45rem 2rem 0.45rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  border: 1.5px solid #D1D5DB;
  border-radius: 7px;
  background: var(--white);
  color: var(--dark-gray);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
}
.filter-count {
  font-size: 0.82rem;
  color: var(--mid-gray);
  margin-left: auto;
}

/* ─── Toasts ─── */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 300;
  display: none;
  animation: toastIn 0.2s ease;
}
.toast--success { background: var(--green); color: var(--white); }
.toast--error   { background: var(--red);   color: var(--white); }
@keyframes toastIn { from { transform: translateY(0.5rem); opacity: 0; } to { transform: none; opacity: 1; } }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .cert-main { padding: 2rem 1.25rem 4rem; }
  .form-grid { grid-template-columns: 1fr; }
  .cert-table { font-size: 0.82rem; }
  .cert-table th, .cert-table td { padding: 0.65rem 0.75rem; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-count { margin-left: 0; }
}