/* Shared by popup.html (data-mode="popup") and options.html (data-mode="page"). */

body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: #1a1a1a;
  background: white;
}
body[data-mode="popup"] { width: 320px; padding: 0 15px 15px; }
body[data-mode="page"]   { padding: 0 20px 40px; background: #f5f6f8; }
body[data-mode="page"] #app { max-width: 640px; margin: 0 auto; }

button { font-family: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid #2f80ed; outline-offset: 1px; }

/* Top bar - stays put while the rule list scrolls */
.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  background: white;
  margin: 0 -15px;
  padding: 12px 15px 10px;
  border-bottom: 1px solid #e0e0e0;
}
body[data-mode="page"] .topbar { margin: 0 -20px; padding: 16px 20px 12px; }
body[data-mode="page"] .topbar > * { max-width: 640px; margin-left: auto; margin-right: auto; }

.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand img { width: 20px; height: 20px; flex-shrink: 0; }
body[data-mode="page"] .brand img { width: 28px; height: 28px; }
h3 { margin: 0; font-size: 16px; }
body[data-mode="page"] h3 { font-size: 20px; }

.backup-actions { display: flex; gap: 6px; }
.secondary-btn {
  padding: 5px 10px;
  background: white;
  color: #2f80ed;
  border: 1px solid #2f80ed;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.secondary-btn:hover { background: #eaf2fd; }

/* Import confirmation */
#importConfirm {
  display: none;
  margin-top: 10px;
  padding: 10px;
  background: #eaf2fd;
  border: 1px solid #cfe0f8;
  border-radius: 4px;
}
#importSummary { margin: 0 0 8px 0; font-size: 12px; line-height: 1.4; }
.confirm-actions { display: flex; gap: 6px; }
.confirm-actions button {
  flex: 1;
  padding: 6px;
  font-size: 12px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  color: white;
}
#mergeBtn { background: #2f80ed; }
#mergeBtn:hover { background: #1c65c9; }
#replaceBtn { background: #eb5757; }
#replaceBtn:hover { background: #c94040; }
#cancelImportBtn { background: #828282; }
#cancelImportBtn:hover { background: #4f4f4f; }

.status { display: none; margin: 8px 0 0 0; font-size: 12px; color: #27ae60; }
.status.show { display: block; }
.status.error { color: #c94040; }

/* Rule form */
.rule-form { margin-top: 15px; }
body[data-mode="page"] .rule-form,
body[data-mode="page"] .rules-section,
body[data-mode="page"] .log-section {
  background: white;
  border: 1px solid #e4e6ea;
  border-radius: 6px;
  padding: 16px;
  margin-top: 16px;
}
.input-group { margin-bottom: 10px; display: flex; flex-direction: column; }
.input-group label { font-size: 13px; }
input[type="text"] {
  padding: 6px;
  margin-top: 4px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
}
.hint { display: block; color: #828282; font-size: 11px; margin-top: 2px; }
.form-note { margin: 0 0 12px 0; color: #828282; font-size: 11px; }

.checkbox-group { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.checkbox-group input { margin: 2px 0 0 0; flex-shrink: 0; }
.checkbox-group label { font-size: 13px; cursor: pointer; }

.form-actions { display: flex; flex-direction: column; }
#addBtn {
  padding: 8px;
  background: #2f80ed;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}
#addBtn:hover { background: #1c65c9; }
#addBtn.editing { background: #27ae60; }
#addBtn.editing:hover { background: #219653; }
#cancelBtn {
  padding: 8px;
  background: #828282;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: none;
  margin-top: 5px;
}
#cancelBtn:hover { background: #4f4f4f; }

/* Section headings */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 15px 0 6px;
}
body[data-mode="page"] .section-head { margin-top: 0; }
.section-head h4 { margin: 0; font-size: 13px; color: #4f4f4f; }
.link-btn {
  padding: 0;
  background: none;
  border: none;
  color: #828282;
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
}
.link-btn:hover { color: #4f4f4f; }
.empty { margin: 6px 0; color: #828282; font-size: 12px; }

/* Rule list */
ul { list-style-type: none; padding: 0; margin: 0; }
#rulesList li {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f9f9f9;
  padding: 8px;
  border-bottom: 1px solid #eee;
  font-size: 13px;
}
#rulesList li.disabled { opacity: 0.55; }
.enable-box { margin: 0; flex-shrink: 0; }
.rule-text { word-break: break-all; flex-grow: 1; }
.rule-mode { display: block; color: #828282; font-size: 11px; margin-top: 2px; }
.rule-mode.overwrite { color: #c94040; }
.rule-types { color: #4f4f4f; }

.btn-group { display: flex; gap: 5px; flex-shrink: 0; }
.action-btn {
  padding: 4px 8px;
  font-size: 12px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  color: white;
}
.edit-btn { background: #f2994a; }
.edit-btn:hover { background: #e28028; }
.delete-btn { background: #eb5757; }
.delete-btn:hover { background: #c94040; }

/* Activity log */
.log-section { margin-top: 15px; }
.log-controls { display: flex; align-items: center; gap: 10px; }
.log-controls label { font-size: 11px; color: #828282; display: flex; align-items: center; gap: 4px; cursor: pointer; }
.log-controls input { margin: 0; }
#logList li {
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 12px;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.log-time { color: #828282; font-size: 11px; flex-shrink: 0; width: 42px; }
.log-body { min-width: 0; flex-grow: 1; }
.log-file { word-break: break-all; }
.log-detail { display: block; color: #828282; font-size: 11px; margin-top: 1px; word-break: break-all; }
.log-rule { color: #2f80ed; }
.log-rule.none { color: #a0a0a0; }
.log-rule.overwrote { color: #c94040; }

/* Popup-only footer */
.page-link { margin-top: 12px; width: 100%; }
body[data-mode="page"] .page-link { display: none; }
