/* Report Studio Redesign - Matching the provided image */

/* Main container */
.report-studio-container {
  /* background: #f8f9fa; */
  min-height: 100vh;
  padding: 0;
}

/* Header section */
.studio-header {
  background: white;
  color: #2c3e50;
  padding: 2rem;
  border-radius: 8px;
}

.studio-header h2 {
  margin-top: 0;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #2c3e50;
}

.studio-header p {
  color: #6c757d;
  margin-bottom: 0;
}

/* Template cards section */
.templates-section {
  background: #e9ecef;
  padding: 2rem;
  border-radius: 16px;
  margin-bottom: 2rem;
}

.templates-section h3 {
  margin-top: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 0.5rem;
}

.templates-section p {
  color: #6c757d;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ==========================================================================
   Radio cards (templates and formats)
   --------------------------------------------------------------------------
   Same pattern as the report modal's format picker
   (report-request-modal.css, .rr-format-section): Shiny renders
   radioButtons as .radio > label > input + span, so the <span> is the card,
   the wrapping label makes the whole card clickable, and the native radio
   keeps keyboard (Tab, arrow keys) and screen-reader semantics.

   Scoped to .studio-choice-group because the modal's rules are scoped to
   .report-request-modal. The format cards reuse the modal's markup
   (.rr-format-icon / .rr-format-name from report_format_card()), so those
   classes are styled here too. Accent colour comes from --rr-accent, set
   inline on .report-studio-container.
   ========================================================================== */

/* Prefixed with .report-studio-container so these beat the page's generic
   `.report-studio-container .form-group label` (weight/margin/colour) and
   `.form-group` margin, which also match Shiny's radio labels and group. */

/* Shiny caps .shiny-input-container at 300px. */
.report-studio-container .studio-choice-group .shiny-input-container {
  width: 100%;
  max-width: 100%;
  margin-bottom: 0;
}

.report-studio-container .studio-choice-group .control-label {
  display: block;
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: #1F2933;
}

.report-studio-container .studio-choice-group .shiny-options-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 480px) {
  .report-studio-container .format-choices .shiny-options-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 576px) {
  .report-studio-container .template-choices .shiny-options-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Six templates in one row on wide desktop; fewer columns below. */
@media (min-width: 1200px) {
  .report-studio-container .template-choices .shiny-options-group {
    grid-auto-flow: column;
    grid-template-columns: none;
    grid-auto-columns: minmax(0, 1fr);
  }
}

/* Formats: one row of equal-width cards, each as wide as the widest, instead of
   stretching across the panel. `1fr` tracks in a max-content grid all take the
   width of the largest card. */
@media (min-width: 992px) {
  .report-studio-container .format-choices .shiny-options-group {
    grid-auto-flow: column;
    grid-template-columns: none;
    grid-auto-columns: 1fr;
    width: max-content;
    max-width: 100%;
  }
}

.report-studio-container .studio-choice-group .radio {
  margin: 0;
  min-width: 0;
}

.report-studio-container .studio-choice-group .radio label {
  display: block;
  position: relative;
  height: 100%;
  margin: 0;
  padding: 0;
  font-weight: 400;
  cursor: pointer;
}

.report-studio-container .studio-choice-group .radio input[type="radio"] {
  position: absolute;
  top: 50%;
  left: 0.85rem;
  margin: 0;
  transform: translateY(-50%);
  accent-color: var(--rr-accent, #893448);
  cursor: pointer;
}

/* Bootstrap 5 redraws Shiny's radios with `appearance: none` and paints the dot
   as a background image over its own fill, so accent-color never applies and
   the checked/focus state has to be recoloured directly. */
.report-studio-container .studio-choice-group .radio input[type="radio"]:checked {
  background-color: var(--rr-accent, #893448);
  border-color: var(--rr-accent, #893448);
}

.report-studio-container .studio-choice-group .radio input[type="radio"]:focus {
  border-color: var(--rr-accent, #893448);
  box-shadow: 0 0 0 0.2rem var(--rr-accent-soft, rgba(0, 0, 0, 0.08));
}

/* The card: radio, icon, title. 56px so a wrapped template name still fits. */
.report-studio-container .studio-choice-group .radio label > span {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: 100%;
  min-height: 56px;
  padding: 0.5rem 0.75rem 0.5rem 2.5rem;
  border: 1px solid #ded9d1;
  border-radius: 8px;
  background: #fff;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.report-studio-container .studio-choice-group .radio label:hover > span {
  border-color: var(--rr-accent, #893448);
}

.report-studio-container .studio-choice-group .radio input:checked ~ span {
  border-color: var(--rr-accent, #893448);
  background: var(--rr-accent-soft, rgba(0, 0, 0, 0.04));
  box-shadow: inset 0 0 0 1px var(--rr-accent, #893448);
}

.report-studio-container .studio-choice-group .radio input:focus-visible ~ span {
  outline: 2px solid var(--rr-accent, #893448);
  outline-offset: 2px;
}

.studio-choice-icon,
.report-studio-container .studio-choice-group .rr-format-icon {
  flex: 0 0 auto;
  font-size: 1.2rem;
  line-height: 1;
}

.studio-choice-icon {
  color: #52606D;
}

.studio-choice-name,
.report-studio-container .studio-choice-group .rr-format-name {
  min-width: 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
  color: #1F2933;
}

/* File types keep their own recognisable colours; the accent is reserved for
   the selection state. */
.report-studio-container .studio-choice-group .rr-format-icon-pdf { color: #C8102E; }
.report-studio-container .studio-choice-group .rr-format-icon-word { color: #2B579A; }
.report-studio-container .studio-choice-group .rr-format-icon-powerpoint { color: #D24726; }
.report-studio-container .studio-choice-group .rr-format-icon-excel { color: #217346; }

/* Link to another page (Community Profile): looks like a card but has no
   radio, so it doesn't read as a selectable template. */
.studio-link-card,
.studio-link-card:visited {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 56px;
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  border: 1px solid #ded9d1;
  border-radius: 8px;
  background: #fff;
  color: #1F2933;
  text-decoration: none;
  transition: border-color 0.15s ease;
}

.studio-link-card:hover,
.studio-link-card:focus-visible {
  border-color: var(--rr-accent, #893448);
  color: #1F2933;
  text-decoration: none;
}

.studio-link-card:focus-visible {
  outline: 2px solid var(--rr-accent, #893448);
  outline-offset: 2px;
}

.studio-link-arrow {
  color: var(--rr-accent, #893448);
}

/* Datasets: always open. Three columns on desktop (two when a client has no
   Real Estate card), stacked below 992px. */
.datasets-section {
  background: #f2f2f2;
  border: 1px solid #cccccc;
  border-radius: 16px;
  margin-bottom: 1rem;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.datasets-section h3 {
  margin-top: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 0.5rem;
}

.dataset-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
}

@media (min-width: 992px) {
  .dataset-grid {
    grid-auto-flow: column;
    grid-template-columns: none;
    grid-auto-columns: minmax(0, 1fr);
  }
}

/* Collapsible sections */
.collapsible-section {
  background: #f2f2f2;
  border-radius: 16px;
  border: 1px solid #cccccc;
  margin-bottom: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  overflow: hidden;
}

.collapsible-header {
  background: #f2f2f2;
  padding: 1rem 1.5rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: none;
  width: 100%;
  text-align: left;
  transition: background-color 0.2s ease;
}

.collapsible-header:hover {
  background: #e9ecef;
}

.collapsible-title {
  font-weight: 600;
  color: #2c3e50;
  font-size: 1rem;
  display: flex;
  align-items: center;
}

.collapsible-title i {
  margin-right: 0.5rem;
}

.collapsible-arrow {
  transition: transform 0.2s ease;
  color: #6c757d;
}

.collapsible-arrow.expanded {
  transform: rotate(180deg);
}

.collapsible-content {
  padding: 1.5rem;
  display: none;
}

.collapsible-content.show {
  display: block;
}

/* Report details section */
.report-details {
  background: #f8f9fa;
  padding: 1.5rem;
  border-radius: 16px;
  margin-bottom: 2rem;
}

.report-details h4 {
  margin-top: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 1.5rem;
}

.report-studio-container .form-group {
  margin-bottom: 1.5rem;
}

.report-studio-container .form-group label {
  font-weight: 500;
  color: #495057;
  margin-bottom: 0.5rem;
  display: block;
}

.report-studio-container .form-control,
.report-studio-container .form-group input[type="text"] {
  border: 1px solid #ced4da;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  width: 100%;
}

.report-studio-container .form-control:focus,
.report-studio-container .form-group input[type="text"]:focus {
  border-color: #333333;
  box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
  outline: none;
}

/* Generate button */
.generate-section {
  text-align: left;
  margin-top: 2rem;
}

.generate-button {
  background: #000000;
  color: white;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
}

.generate-button:hover:not(:disabled) {
  background: #1a252f;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(44,62,80,0.3);
}

.generate-button:disabled {
  background: #6c757d;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Topic grid styling */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 33.333%));
  gap: 1.5rem;
  justify-content: start;
}

.topic-card {
  background: #cccccc;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.topic-card h4 {
  margin-top: 0;
  color: #2c3e50;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
}

.topic-card h4 i {
  margin-right: 0.5rem;
  color: #333333;
}

.topic-card p {
  color: #6c757d;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* Selectize input styling */
.report-studio-container .selectize-input {
  border: 1px solid #ced4da;
  border-radius: 8px;
  font-size: 0.9rem;
}

.report-studio-container .selectize-input.focus {
  border-color: #333333;
  box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

/* Maps section styling */
.maps-section {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-bottom: 1rem;
}

.selected-maps-list {
  margin-top: 1rem;
}

/* Selected maps container styling */
#selected_maps_container {
  max-width: 66.666%; /* Two-thirds width to match two topic cards */
}

#selected_maps_container h6 {
  margin-bottom: 0.75rem;
}

.selected-map-item {
  background: #f8f9fa;
  padding: 0.75rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.selected-map-item .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

/* Responsive design */
@media (max-width: 768px) {
  .topic-grid {
    grid-template-columns: 1fr;
  }

  .studio-header {
    padding: 1.5rem;
  }

  .templates-section {
    padding: 1.5rem;
  }
}

/* Selection buttons styling */
.selection-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-start;
  padding-top: 1rem;
  border-top: 1px solid #e9ecef;
}

.selection-buttons .btn {
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 500;
}

.report-studio-container .btn-outline-secondary {
  border-color: #6c757d;
  color: #6c757d;
}

.report-studio-container .btn-outline-secondary:hover {
  background-color: #6c757d;
  color: white;
}


/* Dynamic label count styling */
#edit-selection-label span,
#maps-section-label span {
  font-size: 0.875em;
  font-weight: normal;
}
