/* ─────────────────────────────────────────────────────────────────────────────
   styles.css — SEC-IMS Data Catalog
   Matches the metadata-editor aesthetic
───────────────────────────────────────────────────────────────────────────── */

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

:root {
  --blue:        #0057a8;
  --blue-dark:   #003f7a;
  --blue-light:  #e8f0f9;
  --grey-100:    #f5f5f5;
  --grey-200:    #e0e0e0;
  --grey-500:    #9e9e9e;
  --grey-800:    #424242;
  --text:        #212121;
  --border:      #bdbdbd;
  --radius:      4px;
  --shadow:      0 2px 6px rgba(0,0,0,.12);
  --font:        'Segoe UI', Arial, sans-serif;
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--grey-100);
  line-height: 1.5;
  /* Reserve space for the fixed compact footer (33 px, see
     secims_view/css/footer.css) so bottom-scrolled content isn't hidden. */
  padding-bottom: 33px;
}

a { color: var(--blue); }
a:hover { color: var(--blue-dark); }

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--blue);
  color: #fff;
  height: 60px;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.site-header .logo { height: 44px; width: auto; }

.site-header h1 {
  font-size: 20px;
  font-weight: 600;
  flex: 1;
}

.site-header .header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
main { max-width: 960px; margin: 2rem auto; padding: 0 1rem 4rem; }

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  box-shadow: var(--shadow);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  /* explicit line-height so <button> (UA default `normal`) matches <a>
     which inherits 1.5 from body — without this, button-tagged buttons
     render shorter than anchor-tagged ones with identical padding. */
  line-height: 1.5;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  text-decoration: none;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary   { background: var(--blue);   color: #fff; }
.btn-primary:hover:not(:disabled)   { background: var(--blue-dark); }

.btn-secondary { background: var(--grey-200); color: var(--grey-800); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.85rem; }

/* ── Search bar ───────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-bar input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: var(--font);
}

/* ── Banner ───────────────────────────────────────────────────────────────── */
.banner {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.banner-error { background: #fdecea; border-left: 4px solid #c62828; color: #c62828; }
.banner button.close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: inherit;
  opacity: 0.6;
}
.banner button.close:hover { opacity: 1; }

/* ── Table ────────────────────────────────────────────────────────────────── */
.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.records-table th {
  background: var(--blue);
  color: #fff;
  padding: 0.6rem 0.85rem;
  text-align: left;
  font-weight: 600;
}

.records-table td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--grey-200);
  vertical-align: top;
}

.records-table tr:hover td { background: var(--blue-light); }

/* ── Empty / loading states ───────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--grey-500);
}

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

.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0,87,168,.3);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 1rem;
}

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  gap: 1rem;
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
[x-cloak] { display: none !important; }

/* ── Metadata modal ───────────────────────────────────────────────────────────
   Ported from map viewer LegendControl to support catalog metadata buttons  */

#metadata-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.metadata-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.metadata-modal-content {
  position: relative;
  background: #fff;
  border-radius: 8px;
  width: 90%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.metadata-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--blue-dark);
  color: #fff;
  border-radius: 8px 8px 0 0;
  flex-shrink: 0;
}

.metadata-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.metadata-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.metadata-modal-pdf {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
  white-space: nowrap;
}

.metadata-modal-pdf:hover {
  background: rgba(255, 255, 255, 0.25);
}

.metadata-modal-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.7;
}

.metadata-modal-close:hover {
  opacity: 1;
}

.metadata-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.metadata-modal-loading {
  text-align: center;
  color: #666;
  padding: 40px 0;
}

.metadata-modal-error {
  color: #c62828;
  padding: 20px;
  text-align: center;
}

/* Metadata sections */

.metadata-sections {
  font-family: var(--font);
  font-size: 14px;
  color: #333;
}

.metadata-section {
  margin-bottom: 16px;
}

.metadata-section h4 {
  margin: 0 0 8px 0;
  padding: 6px 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--blue-dark);
  border-bottom: 2px solid var(--blue);
}

.metadata-section-body {
  padding-left: 2px;
}

.metadata-row {
  display: flex;
  padding: 4px 0;
  border-bottom: 1px solid #f0f0f0;
}

.metadata-label {
  flex: 0 0 140px;
  font-weight: 600;
  color: #555;
  font-size: 13px;
}

.metadata-value {
  flex: 1;
  word-break: break-word;
}

.metadata-badge {
  display: inline-block;
  background: var(--blue-light);
  color: var(--blue-dark);
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 12px;
  margin: 2px 2px;
}

.metadata-contact {
  padding: 8px 0;
  border-bottom: 1px solid var(--grey-200);
  line-height: 1.6;
}

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

.metadata-contact-type {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--blue-dark, #003f7a);
  margin-bottom: 3px;
}

.metadata-bbox-map {
  width: 100%;
  height: 220px;
  margin-top: 8px;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  overflow: hidden;
}

.metadata-contact a {
  color: var(--blue);
  text-decoration: none;
}

.metadata-contact a:hover {
  text-decoration: underline;
}

.metadata-links a {
  display: inline-block;
  background: var(--blue);
  color: #fff;
  padding: 4px 10px;
  border-radius: 3px;
  font-size: 12px;
  text-decoration: none;
  margin: 2px;
}

.metadata-links a:hover {
  background: var(--blue-dark);
}
