/* Classifiche TML — viewer front-end (PDF.js) */

.tml-classifiche {
  --tml-accent: #ffc500;
  --tml-accent-text: #1c1c1c;
  --tml-accent-soft: #fff6d6;
  --tml-border: rgba(255, 255, 255, 0.35);
  --tml-text: #f2f2f2;
  --tml-muted: #b8b8b8;
  --tml-surface: #141414;
  --tml-control-bg: #1a1a1a;
  --tml-control-fg: #ffffff;
  --tml-viewer-height: 75vh;
  --tml-radius: 6px;
  box-sizing: border-box;
  color: var(--tml-text);
  margin: 1.25rem 0 2rem;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  color-scheme: dark;
}

.tml-classifiche *,
.tml-classifiche *::before,
.tml-classifiche *::after {
  box-sizing: border-box;
}

.tml-classifiche__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  width: 100%;
  max-width: 100%;
}

.tml-classifiche__select-wrap {
  display: none;
  position: relative;
  flex: 1 1 220px;
  min-width: 0;
  max-width: 100%;
}

/* Chevron sopra il select (non cancellabile da reset theme su background) */
.tml-classifiche__select-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0.95rem;
  width: 14px;
  height: 10px;
  margin-top: -5px;
  pointer-events: none;
  z-index: 2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 10' fill='none'%3E%3Cpath d='M1.2 1.4L7 7.2 12.8 1.4' stroke='%23ffc500' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 10px;
}

.tml-classifiche__select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 48px;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  padding: 0.75rem 2.75rem 0.75rem 0.9rem;
  border: 1.5px solid rgba(255, 255, 255, 0.55) !important;
  border-radius: var(--tml-radius);
  background-color: #1a1a1a !important;
  /* Fallback freccia se ::after non è visibile */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 10' fill='none'%3E%3Cpath d='M1.2 1.4L7 7.2 12.8 1.4' stroke='%23ffc500' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.95rem center !important;
  background-size: 14px 10px !important;
  color: #ffffff !important;
  color-scheme: dark;
  box-shadow: none;
  cursor: pointer;
}

.tml-classifiche__select::-ms-expand {
  display: none;
}

.tml-classifiche__select:focus,
.tml-classifiche__select:focus-visible {
  outline: 2px solid var(--tml-accent);
  outline-offset: 2px;
  border-color: #ffc500 !important;
}

.tml-classifiche__select option {
  background-color: #1a1a1a;
  color: #ffffff;
}

.tml-classifiche__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex: 1 1 auto;
  min-width: 0;
}

.tml-classifiche__tab {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: transparent;
  color: var(--tml-muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tml-classifiche__tab:hover,
.tml-classifiche__tab:focus-visible {
  border-color: var(--tml-accent);
  color: var(--tml-accent-text);
  background: var(--tml-accent-soft);
  outline: none;
}

.tml-classifiche__tab.is-active {
  background: var(--tml-accent);
  border-color: var(--tml-accent);
  color: var(--tml-accent-text);
}

.tml-classifiche__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  align-items: center;
}

.tml-classifiche__download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--tml-accent-text);
  background: var(--tml-accent);
  border: 1px solid var(--tml-accent);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  white-space: nowrap;
}

.tml-classifiche__download:hover,
.tml-classifiche__download:focus-visible {
  filter: brightness(0.95);
  text-decoration: none;
  outline: none;
}

.tml-classifiche__panel {
  border: 1px solid var(--tml-border);
  border-radius: var(--tml-radius);
  background: var(--tml-surface);
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}

.tml-classifiche__viewer-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: var(--tml-viewer-height);
  min-height: 420px;
  max-height: 92vh;
  background: #0e0e0e;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.tml-classifiche__status {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0;
  padding: 0.85rem 1rem;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1c1c1c;
  background: var(--tml-accent);
}

.tml-classifiche__status[hidden] {
  display: none !important;
}

.tml-classifiche__status.is-error {
  background: #3a1515;
  color: #ffb4b4;
}

.tml-classifiche__pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 100%;
  padding: 0.75rem 0.5rem 1.25rem;
}

.tml-classifiche__page {
  width: 100%;
  max-width: 100%;
  display: flex;
  justify-content: center;
  line-height: 0;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.tml-classifiche__canvas {
  display: block;
  width: 100% !important;
  height: auto !important;
  max-width: 100%;
}

.tml-classifiche-error {
  color: #ffb4b4;
  background: #3a1515;
  border: 1px solid #7a3030;
  padding: 0.75rem 1rem;
  border-radius: var(--tml-radius);
}

/* auto: tabs on wider screens, select on narrow */
@media (max-width: 720px) {
  .tml-classifiche.tml-ui-auto .tml-classifiche__tabs {
    display: none;
  }

  .tml-classifiche.tml-ui-auto .tml-classifiche__select-wrap,
  .tml-classifiche.tml-ui-select .tml-classifiche__select-wrap {
    display: block;
    flex: 1 1 auto;
    width: 100%;
  }

  .tml-classifiche.tml-ui-auto .tml-classifiche__toolbar,
  .tml-classifiche.tml-ui-select .tml-classifiche__toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .tml-classifiche__actions {
    width: 100%;
  }

  .tml-classifiche__download {
    width: 100%;
    min-height: 48px;
  }

  .tml-classifiche__viewer-wrap {
    min-height: 55vh;
    height: min(70vh, 640px);
  }

  .tml-classifiche__pages {
    padding: 0.5rem 0.25rem 1rem;
    gap: 0.5rem;
  }
}

.tml-classifiche.tml-ui-select .tml-classifiche__tabs {
  display: none;
}
.tml-classifiche.tml-ui-select .tml-classifiche__select-wrap {
  display: block;
}

.tml-classifiche.tml-ui-tabs .tml-classifiche__select-wrap {
  display: none;
}
.tml-classifiche.tml-ui-tabs .tml-classifiche__tabs {
  display: flex;
}

@media (prefers-reduced-motion: reduce) {
  .tml-classifiche__tab {
    transition: none;
  }
}
