/* Chord Sheets page styles */

/* ——— Shared page box ——— */
.chords-page-box {
  padding: 2rem 2.5rem;
  max-width: 100%;
  box-sizing: border-box;
  /* Wider page shell for chord pages so grille can expand on desktop */
  width: min(1440px, calc(100vw - 80px));
  max-width: 1200px;
  margin: 24px auto;
}

/* ——— Library listing ——— */
.chords-wrap {
  width: 100%;
  /* allow a much wider content area on desktop (approx 1.6x the old default) */
  max-width: 1600px;
  margin: 0 auto;
}

.chords-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.chords-header h2 {
  margin: 0;
  color: #00ff9d;
  text-shadow: 0 0 15px rgba(0, 255, 157, 0.6);
}

/* ——— Filter bar ——— */
.chords-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.chords-filters input[type="text"] {
  flex: 1 1 200px;
  min-width: 140px;
  background: rgba(0, 255, 157, 0.1);
  border: 2px solid rgba(0, 255, 157, 0.4);
  color: white;
  padding: 0.6rem 1rem;
  border-radius: 50px;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.3s;
}

.chords-filters input[type="text"]:focus {
  border-color: #00ff9d;
  box-shadow: 0 0 16px rgba(0, 255, 157, 0.35);
}

.chords-filters select {
  background: rgba(0, 255, 157, 0.1);
  border: 2px solid rgba(0, 255, 157, 0.4);
  color: white;
  padding: 0.6rem 1rem;
  border-radius: 50px;
  font-size: 0.95rem;
  outline: none;
  cursor: pointer;
  min-width: 120px;
}

.chords-filters select option {
  background: #1a1a2e;
  color: white;
}

.chords-filters .bpm-input {
  width: 150px;
  background: rgba(0, 255, 157, 0.1);
  border: 2px solid rgba(0, 255, 157, 0.4);
  color: white;
  padding: 0.6rem 1rem;
  border-radius: 50px;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.3s;
}

.chords-filters .bpm-input:focus {
  border-color: #00ff9d;
  box-shadow: 0 0 16px rgba(0, 255, 157, 0.35);
}

.chords-filters button {
  background: #00ff9d;
  color: #000;
  padding: 0.6rem 1.2rem;
  border-radius: 50px;
  border: none;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.95rem;
}

.chords-filters button:hover {
  background: #00cc7a;
}

.filter-clear {
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.4rem 0.8rem;
  transition: color 0.2s;
}

.filter-clear:hover {
  color: #ff3366;
}

/* ——— Alphabetical letter sections ——— */
.chords-list {
  display: flex;
  flex-direction: column;
}

.letter-section {
  font-size: 1.3rem;
  font-weight: bold;
  color: #00ff9d;
  text-shadow: 0 0 12px rgba(0, 255, 157, 0.5);
  padding: 0.7rem 0.5rem 0.3rem;
  margin-top: 0.75rem;
  border-bottom: 1px solid rgba(0, 255, 157, 0.2);
  letter-spacing: 2px;
}

.letter-section:first-child {
  margin-top: 0;
}

/* ——— Row-based chord listing ——— */
.chord-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-decoration: none;
  transition: background 0.15s;
  border-radius: 6px;
}

.chord-row:hover {
  background: rgba(0, 255, 157, 0.08);
}

.chord-row-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}

.chord-row-details {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.chord-row-tag {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.85rem;
  white-space: nowrap;
}

.chord-card-key {
  display: inline-block;
  background: rgba(0, 255, 157, 0.15);
  border: 1px solid rgba(0, 255, 157, 0.45);
  color: #00ff9d;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: bold;
  white-space: nowrap;
}

.chord-card-style {
  display: inline-block;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.8);
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  padding: 3rem 1rem;
}

.empty-state i {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}

/* ——— Buttons ——— */
.btn-primary-glow {
  background: #00ff9d;
  color: #000;
  padding: 12px 24px;
  border-radius: 50px;
  font-weight: bold;
  text-decoration: none;
  display: inline-block;
  transition: all 0.2s;
  border: none;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(0, 255, 157, 0.45);
}

.btn-primary-glow:hover {
  background: #00cc7a;
  transform: translateY(-1px);
}

.btn-secondary-glow {
  background: transparent;
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.4);
  padding: 12px 24px;
  border-radius: 50px;
  font-weight: bold;
  text-decoration: none;
  display: inline-block;
  transition: all 0.2s;
  cursor: pointer;
}

.btn-secondary-glow:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: #00ff9d;
}

.btn-danger {
  background: transparent;
  color: #ff3366;
  border: 2px solid #ff3366;
  padding: 10px 20px;
  border-radius: 50px;
  font-weight: bold;
  text-decoration: none;
  display: inline-block;
  transition: all 0.2s;
  cursor: pointer;
}

.btn-danger:hover {
  background: #ff3366;
  color: #fff;
  box-shadow: 0 0 20px rgba(255, 51, 102, 0.5);
}

/* ——— Chord sheet view ——— */
.sheet-wrap {
  width: 100%;
  margin: 0 auto;
}

.sheet-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.sheet-title {
  font-size: 2rem;
  font-weight: bold;
  color: #fff;
  margin-bottom: 0.25rem;
  font-family: 'Georgia', serif;
}

.sheet-composer {
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.1rem;
  font-style: italic;
}

.sheet-meta {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin: 0.75rem 0;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.95rem;
}

.sheet-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 1rem 0 1.5rem;
}

.sheet-controls label {
  color: #fff;
  font-weight: bold;
  font-size: 1rem;
}

.sheet-controls select {
  background: rgba(0, 255, 157, 0.15);
  border: 2px solid #00ff9d;
  color: white;
  padding: 0.6rem 1rem;
  border-radius: 50px;
  font-size: 1rem;
  outline: none;
  cursor: pointer;
}

.sheet-controls select option {
  background: #1a1a2e;
  color: white;
}

.sheet-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

/* ——— Grille table ——— */
.grille-container {
  display: flex;
  align-items: flex-start;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 auto;
  width: 100%;
}

.grille-container .grille-table {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

#grilleOutput {
  background: #fff;
  border-radius: 4px;
  padding: 1.5rem 1rem;
}

/* Neutralise .transparent_box * overrides inside the grille */
#grilleOutput * {
  color: #000;
  text-shadow: none;
}

/* Section label must keep its white text despite the above rule */
#grilleOutput .grille-section-label,
.preview-container .grille-section-label {
  color: #fff;
}

.grille-table {
  border-collapse: collapse;
  margin: 0 auto;
  width: 100%;
  table-layout: fixed;
}

.grille-table td {
  border: 2px solid #000;
  padding: 6px 5px;
  text-align: center;
  vertical-align: middle;
  height: 90px;
  font-size: 2.5rem;
  font-weight: bold;
  color: #000;
  background: #fff;
  font-family: 'Georgia', serif;
  position: relative;
  word-break: break-word;
}

.grille-table td .chord-root {
  color: #000;
}

.grille-table td .chord-quality,
.grille-table td sup {
  font-size: 0.75em;
  color: #000;
}

.grille-table td.simile-cell {
  font-size: 2rem;
  color: #555;
}

/* Section label — vertical pill on the left of each section's first row */
.grille-section-label {
  flex-shrink: 0;
  align-self: flex-start;
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  background: #222;
  color: #fff;
  font-size: 0.65rem;
  font-weight: bold;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 10px 5px;
  border-radius: 4px;
  margin-right: 6px;
  margin-top: 2px;
  white-space: nowrap;
}

/* Repeat barline styles */
.grille-table td.repeat-begin {
  border-left: 5px double #000;
}
.grille-table td.repeat-end {
  border-right: 5px double #000;
}
.grille-table td.repeat-begin.repeat-end {
  border-left: 5px double #000;
  border-right: 5px double #000;
}

/* Diagonal split cell */
.split-cell {
  position: relative;
  overflow: hidden;
  padding: 0 !important;
}

.split-cell .split-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom right,
    transparent calc(50% - 1px),
    #000 calc(50% - 1px),
    #000 calc(50% + 1px),
    transparent calc(50% + 1px)
  );
  pointer-events: none;
}

.split-cell .split-top {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 1.6rem;
  font-weight: bold;
  color: #000;
  font-family: 'Georgia', serif;
}

.split-cell .split-top sup,
.split-cell .split-bottom sup {
  font-size: 0.7em;
}

.split-cell .split-bottom {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-size: 1.6rem;
  font-weight: bold;
  color: #000;
  font-family: 'Georgia', serif;
}

/* Segno / Coda symbols */
.symbol-segno,
.symbol-coda {
  color: #333;
  font-size: 1.3rem;
  margin: 0 0.25rem;
}

/* ——— Upload / edit form ——— */
.chord-form-wrap {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.chord-form-wrap h2 {
  text-align: center;
  color: #00ff9d;
  margin-bottom: 1.5rem;
}

.chord-form {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 2rem;
}

.chord-form .form-group {
  margin-bottom: 1.25rem;
}

.chord-form label {
  display: block;
  color: #fff;
  font-weight: bold;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

.chord-form input[type="text"],
.chord-form input[type="number"],
.chord-form select {
  width: 100%;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.chord-form input[type="text"]:focus,
.chord-form input[type="number"]:focus,
.chord-form select:focus,
.chord-form textarea:focus {
  border-color: #00ff9d;
  box-shadow: 0 0 12px rgba(0, 255, 157, 0.2);
}

.chord-form select option {
  background: #1a1a2e;
  color: white;
}

.chord-form textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.chord-form .form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.5rem;
}

/* Preview section */
.preview-section {
  margin-top: 2rem;
}

.preview-section h3 {
  color: #00ff9d;
  text-align: left;
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.preview-container {
  background: #fff;
  color: #000;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  padding: 1.5rem;
  min-height: 100px;
  overflow-x: auto;
}

.preview-container * {
  color: #000;
  text-shadow: none;
}

/* ——— Input legend (collapsible) ——— */
.input-legend {
  margin-bottom: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  overflow: hidden;
}

.input-legend summary {
  padding: 0.75rem 1rem;
  cursor: pointer;
  color: #00ff9d;
  font-weight: bold;
  font-size: 1rem;
  background: rgba(0, 255, 157, 0.06);
  list-style: none;
  user-select: none;
  transition: background 0.2s;
}

.input-legend summary::-webkit-details-marker { display: none; }
.input-legend summary::before {
  content: '▸ ';
  transition: transform 0.2s;
  display: inline-block;
}
.input-legend[open] summary::before {
  content: '▾ ';
}

.input-legend summary:hover {
  background: rgba(0, 255, 157, 0.12);
}

.legend-content {
  padding: 1rem 1.25rem;
  background: rgba(0, 0, 0, 0.2);
}

.legend-section {
  margin-bottom: 1rem;
}

.legend-section:last-child {
  margin-bottom: 0;
}

.legend-section h4 {
  color: #00ff9d;
  font-size: 0.9rem;
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.legend-table {
  width: 100%;
  border-collapse: collapse;
}

.legend-table td {
  padding: 0.35rem 0.6rem;
  vertical-align: top;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.88rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.legend-table td.legend-symbol {
  font-family: 'Courier New', monospace;
  color: #fff;
  font-weight: bold;
  white-space: nowrap;
  width: 120px;
}

.legend-example {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.82rem;
}

.legend-example-block {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.8);
  white-space: pre;
  overflow-x: auto;
  margin: 0.25rem 0 0;
}

/* ——— Print styles ——— */
@media print {
  /* Hide dark chrome */
  .navbar,
  .flash-container,
  .sheet-actions,
  .sheet-controls,
  .snow {
    display: none !important;
  }

  /* Strip dark backgrounds everywhere */
  body,
  .area,
  .main-content,
  .transparent_box,
  .chords-page-box,
  .sheet-wrap {
    background: #fff !important;
    color: #000 !important;
    padding: 0 !important;
    margin: 0 !important;
    min-height: auto !important;
    box-shadow: none !important;
    border: none !important;
  }

  /* Kill inherited shadow/colour from .transparent_box * */
  .transparent_box * {
    color: #000 !important;
    text-shadow: none !important;
  }

  #grilleOutput {
    background: #fff !important;
    padding: 0 !important;
    box-shadow: none !important;
  }

  .grille-container {
    overflow: visible !important;
  }

  .grille-table {
    width: 100% !important;
    min-width: 0 !important;
  }

  .grille-table td {
    color: #000 !important;
    background: #fff !important;
    border: 2px solid #000 !important;
    font-size: 1.5rem;
    padding: 4px 8px;
    height: 64px;
    min-width: 0;
  }

  .grille-table td.simile-cell {
    color: #555 !important;
  }

  .grille-section-label {
    color: #000 !important;
    background: #fff !important;
    text-shadow: none !important;
  }

  .split-cell .split-top,
  .split-cell .split-bottom {
    color: #000 !important;
    text-shadow: none !important;
    font-size: 1.1rem !important;
  }

  /* Force all split cells to the same fixed height as regular cells */
  .split-cell {
    height: 64px !important;
    min-height: unset !important;
  }

  /* Force browser to print the diagonal gradient */
  .split-cell .split-line {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    background: linear-gradient(
      to bottom right,
      transparent calc(50% - 1px),
      #000 calc(50% - 1px),
      #000 calc(50% + 1px),
      transparent calc(50% + 1px)
    ) !important;
  }
}

/* ——— Mobile ——— */
@media (max-width: 600px) {
  /* Override boilerplate.css .main-content 20px side padding — keep top/bottom */
  .main-content {
    padding: 100px 0 200px !important;
  }

  /* ── Override boilerplate.css transparent_box side padding (50px / 35px / 16px)
     so the chord grid can use full screen width.
     Keep top margin so there's breathing room between the navbar and the card. ── */
  .transparent_box.chords-page-box {
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  /* chords-page-box desktop padding also gone on sides */
  .chords-page-box {
    padding-left: 0;
    padding-right: 0;
  }

  /* #grilleOutput: strip side padding, keep tiny vertical breathing room */
  #grilleOutput {
    padding: 0.5rem 0;
    border-radius: 0;
  }

  /* grille-container: 96% of parent so it doesn't touch the card edge */
  .grille-container {
    width: 96%;
    margin: 0 auto;
    overflow-x: auto;
  }

  /* Sheet header/controls: restore readable side padding for text */
  .sheet-wrap {
    padding: 0 0.75rem;
  }

  .sheet-title {
    font-size: 1.4rem;
  }

  /* ── Library listing ── */
  .chords-header {
    flex-direction: column;
    text-align: center;
    padding: 0.75rem 0.75rem 0;
  }

  .chords-filters {
    flex-direction: column;
    padding: 0 0.75rem;
  }

  .chords-filters input[type="text"],
  .chords-filters select,
  .chords-filters .bpm-input {
    width: 100%;
    min-width: 0;
    flex: none;
  }

  .chord-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }

  .chord-row-details {
    flex-wrap: wrap;
  }

  .chord-form {
    padding: 1rem;
  }

  /* Compact section-label pill on mobile */
  .grille-section-label {
    font-size: 0.5rem;
    padding: 6px 3px;
    margin-right: 3px;
    letter-spacing: 1px;
  }

  .grille-table {
    width: 100%;
    table-layout: fixed;
  }

  /* Chord cells: larger font to fill the cell, equal for all types */
  .grille-table td {
    padding: 4px 2px;
    font-size: 1.3rem;
    height: 56px;
  }

  /* Fix: simile % was inheriting the 2rem base rule, appearing 2.7× larger */
  .grille-table td.simile-cell {
    font-size: 1.3rem;
    color: #888;
  }

  /* Split cells: slightly smaller to fit both chords in half the cell */
  .split-cell .split-top,
  .split-cell .split-bottom {
    font-size: 0.85rem;
  }
}

/* ——— Upload tabs ——— */
.chords-page-box .upload-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.chords-page-box .upload-tab {
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.7);
  padding: 0.7rem 1.5rem;
  border-radius: 50px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  font-size: 0.95rem;
}

.chords-page-box .upload-tab:hover {
  border-color: rgba(0, 255, 157, 0.5);
  color: #fff;
}

.chords-page-box .upload-tab.active {
  background: rgba(0, 255, 157, 0.15);
  border-color: #00ff9d;
  color: #00ff9d;
  box-shadow: 0 0 12px rgba(0, 255, 157, 0.25);
}

/* ——— OCR loading spinner ——— */
.chords-page-box .ocr-loading {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 1rem;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1rem;
}

.chords-page-box .ocr-loading.active {
  display: flex;
}

.chords-page-box .ocr-loading .spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(0, 255, 157, 0.2);
  border-top: 4px solid #00ff9d;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Reuse the spin animation if it exists, otherwise define */
.chords-page-box .ocr-loading .spinner {
  animation: spin 0.8s linear infinite;
}

/* ——— Validation banners ——— */
.chords-page-box .validation-ok {
  background: rgba(0, 255, 157, 0.1);
  border: 1px solid rgba(0, 255, 157, 0.4);
  color: #00ff9d;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.chords-page-box .validation-error {
  background: rgba(255, 51, 102, 0.1);
  border: 1px solid rgba(255, 51, 102, 0.4);
  color: #ff3366;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.chords-page-box .validation-warn {
  background: rgba(255, 200, 0, 0.1);
  border: 1px solid rgba(255, 200, 0, 0.4);
  color: #ffc800;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.chords-page-box .validation-error ul,
.chords-page-box .validation-warn ul {
  margin: 0.4rem 0 0 1.2rem;
  padding: 0;
}

.chords-page-box .validation-error li,
.chords-page-box .validation-warn li {
  margin-bottom: 0.2rem;
}
