/* ==========================================================================
   components.css
   Details/summary collapsibles, dialogs, buttons, search, checkboxes,
   jQuery Mobile compatibility classes, and utility components.
   ========================================================================== */

/* Details / Summary (replaces jQuery Mobile collapsible)
   ========================================================================== */

details {
  margin-bottom: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

summary {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--color-accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

summary:active {
  filter: brightness(0.95);
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 0 6px 8px;
  border-color: transparent transparent transparent #fff;
  margin-right: 0.6rem;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

details[open] > summary::before {
  transform: rotate(90deg);
}

summary:hover {
  filter: brightness(1.05);
}

details .details-body {
  padding: 0.75rem 1rem;
}

/* Nested Details
   ========================================================================== */

details details {
  margin: 0.4rem 0;
  border-color: var(--color-border);
  border-left: 3px solid var(--color-primary);
}

details details summary {
  background: var(--color-accent-subtle);
  color: var(--color-text);
}

details details summary::before {
  border-color: transparent transparent transparent var(--color-primary);
}

/* Details Group (stacked collapsibles with shared borders)
   ========================================================================== */

.details-group > details {
  margin-bottom: 0;
  border-radius: 0;
  border-bottom-width: 0;
}

.details-group > details:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}

.details-group > details:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
  border-bottom-width: 1px;
}

/* jQuery Mobile Compatibility Classes
   ========================================================================== */

.ui-bar-a {
  background: var(--color-accent-subtle);
  color: var(--color-text);
  padding: 0.4rem 0.75rem;
  font-weight: 600;
  border-radius: var(--radius);
  margin: 0.5rem 0 0.25rem;
  border-left: 3px solid var(--color-primary);
}

.ui-body-a {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  background: var(--color-surface);
}

.ui-corner-all {
  border-radius: var(--radius);
}

/* Dialog
   ========================================================================== */

dialog {
  border: none;
  border-radius: 0.5rem;
  padding: 0;
  max-width: min(500px, 90vw);
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  background: var(--color-surface);
  color: var(--color-text);
}

dialog::backdrop {
  background: rgba(0,0,0,0.5);
}

dialog .dialog-header {
  background: var(--color-accent);
  color: #fff;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

dialog .dialog-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

dialog .dialog-header button {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}

dialog .dialog-body {
  padding: 1rem;
}

dialog .dialog-footer {
  padding: 0.75rem 1rem;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  border-top: 1px solid var(--color-border);
}

/* Buttons
   ========================================================================== */

.btn {
  display: inline-block;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: filter 0.15s;
}

.btn-primary {
  background: var(--color-accent);
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-secondary {
  background: var(--color-secondary);
  color: var(--color-secondary-text);
}

.btn-secondary:hover {
  filter: brightness(0.95);
}

/* Nav Buttons (full-width link buttons on the home page)
   ========================================================================== */

.btn-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  background: var(--color-accent);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 1rem;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease, filter 0.15s;
}

.btn-nav::after {
  content: '\203A';
  font-size: 1.4em;
  font-weight: 300;
}

.btn-nav:visited {
  color: #fff;
}

.btn-nav:hover {
  filter: brightness(1.05);
}

.btn-nav:active {
  transform: scale(0.98);
}

/* Link Buttons (external links styled as buttons)
   ========================================================================== */

.btn-link {
  display: block;
  padding: 0.75rem 1rem;
  margin: 0.4rem 0;
  background: var(--color-accent);
  color: #fff;
  text-decoration: none;
  text-align: center;
  border-radius: var(--radius);
  font-weight: 500;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease, filter 0.15s;
}

.btn-link:visited {
  color: #fff;
}

.btn-link:hover {
  filter: brightness(1.05);
}

.btn-link:active {
  transform: scale(0.98);
}

/* Search Input
   ========================================================================== */

.search-input {
  width: 100%;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  border: 1px solid var(--color-border);
  border-radius: 2rem;
  font-size: 0.95rem;
  color: var(--color-text);
  background: var(--color-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.156a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") no-repeat 0.75rem center;
  outline: none;
  margin-bottom: 1rem;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-light);
}

/* Checkbox Styling
   ========================================================================== */

fieldset {
  border: none;
  padding: 0;
  margin: 0.5rem 0;
}

legend {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--color-text);
  font-size: 0.95rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  cursor: pointer;
  font-size: 0.95rem;
}

.checkbox-label input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}

/* Button Group (check all / uncheck all)
   ========================================================================== */

.btn-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.btn-group button {
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-group button:hover {
  background: var(--color-hover);
}

/* Offline Toast
   ========================================================================== */

.offline-toast {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 9999;
  background: #333;
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9em;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.offline-toast.visible {
  opacity: 1;
}

