/* ═══════════════════════════════════════════════════════════════════════
   RCS Working-Test Admin – Responsive Stylesheet
   Breakpoints:
     Desktop      ≥ 992 px
     Tablet 11"   768 px – 991 px
     iPhone       < 768 px  (refined < 576 px)
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Base ────────────────────────────────────────────────────────────── */
:root {
  --rcs-max-width: 1400px;
  --rcs-header-bg: #fff;
  --rcs-border: #dee2e6;
  --rcs-text-muted: #6c757d;
}

html, body {
  height: 100%;
}

body {
  background-color: #f5f6f8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 0.95rem;
}

/* ── Outer wrapper ───────────────────────────────────────────────────── */
.container-fluid {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0;
}

/* ── Header ──────────────────────────────────────────────────────────── */
.container-fluid .header {
  background-color: var(--rcs-header-bg);
  border-bottom: 1px solid var(--rcs-border);
  width: 100%;
  margin-bottom: 0;
  float: none;
}

/* The inner title container: logo left, title text right */
.header .container.title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.25rem;
  max-width: var(--rcs-max-width);
  width: 100%;
  margin: 0 auto;
  float: none;
}

.header .container.title .img-fluid.logo {
  width: auto;
  max-height: 56px;
  float: none;
  padding: 0;
}

/* h1.title inside the header div */
.container .title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #212529;
  text-align: right;
  padding: 0;
  width: auto;
  float: none;
  line-height: 1.2;
}

/* ── Navbar ──────────────────────────────────────────────────────────── */
.navbar.navbar-dark.bg-dark {
  padding: 0.4rem 1rem;
  background-color: #455a6e !important;
}

.navbar.navbar-dark.bg-dark .navbar-brand {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.navbar.navbar-dark.bg-dark .nav-item.active > .nav-link {
  color: #fff;
  font-weight: 500;
}

.navbar.navbar-dark.bg-dark .dropdown-menu {
  min-width: 210px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.navbar.navbar-dark.bg-dark .dropdown-item {
  font-size: 0.875rem;
  padding: 0.45rem 1.2rem;
}

.navbar.navbar-dark.bg-dark .dropdown-item.active,
.navbar.navbar-dark.bg-dark .dropdown-item:active {
  background-color: #378add;
  color: #fff;
}

.navbar.navbar-dark.bg-dark .dropdown-item i {
  margin-right: 6px;
  opacity: 0.7;
  font-size: 0.9em;
}

/* ── Dashboard tiles ─────────────────────────────────────────────────────
   Home/Übersicht cards fully wrapped in <a class="text-decoration-none">:
   title + icon inherit Bootstrap's default link blue otherwise. Use the
   navbar's dark tone instead so the tiles read as neutral cards. */
a.text-decoration-none {
  color: #455a6e;
}

a.text-decoration-none:hover {
  color: #2f3d49;
}

/* ── Breadcrumb ──────────────────────────────────────────────────────── */
.admin-breadcrumb {
  margin-bottom: 1rem;
}

.admin-breadcrumb .breadcrumb {
  background: transparent;
  padding: 0;
  margin: 0;
  font-size: 0.83rem;
}

.admin-breadcrumb .breadcrumb-item a {
  color: #555;
  text-decoration: none;
}

.admin-breadcrumb .breadcrumb-item a:hover {
  text-decoration: underline;
}

.admin-breadcrumb .breadcrumb-item.active {
  color: #333;
  font-weight: 500;
}

/* ── Content ─────────────────────────────────────────────────────────── */
.container-fluid .container.content {
  flex: 1 0 auto;
  max-width: var(--rcs-max-width);
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
}

.container-fluid .container.content h3 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.container-fluid .container.content h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.container-fluid .container.content .btn.btn-lg {
  border-radius: 10px;
  border: 1px solid #000;
  margin: 4px;
  background-color: #ebebeb;
  font-size: 0.9rem;
  min-height: 44px;
  min-width: 210px;
  padding: 0.4rem 1rem;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.container-fluid .container.content .btn.btn-lg:hover {
  background-color: #d8d8d8;
}

.btn-section,
.button-section {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 1rem;
}

/* ── Forms ───────────────────────────────────────────────────────────── */
.form-control {
  font-size: 0.9rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #495057;
  margin-bottom: 0.25rem;
}

.form-inline label {
  font-size: 0.9rem;
}

/* ── Alerts ──────────────────────────────────────────────────────────── */
.alert {
  border-radius: 8px;
  font-size: 0.9rem;
}

/* ── Tables ──────────────────────────────────────────────────────────── */
.table-responsive {
  border-radius: 6px;
  border: 1px solid var(--rcs-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.table {
  font-size: 0.875rem;
  margin-bottom: 0;
}

table.table thead.thead-light th {
  background-color: #f1f3f5;
  font-weight: 600;
  white-space: nowrap;
  font-size: 0.85rem;
  vertical-align: bottom;
  border-bottom: 2px solid var(--rcs-border);
}

table.table td {
  vertical-align: middle;
}

table.table td.td-actions {
  white-space: nowrap;
}

/* ── Zebra striping ──────────────────────────────────────────────────── */
table.table tbody tr:nth-child(odd) {
  background-color: #fafbfc;
}

table.table tbody tr:hover {
  background-color: #f0f4ff;
}

/* ── Card table (mobile): .table-card turns rows into cards < 576px ── */
@media (max-width: 575.98px) {
  .table-responsive:has(.table-card) {
    border: none;
    border-radius: 0;
    box-shadow: none;
  }

  table.table-card {
    border: none;
  }

  table.table-card thead {
    display: none;
  }

  table.table-card tbody tr {
    display: block;
    border: 1px solid var(--rcs-border);
    border-radius: 10px;
    margin-bottom: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
  }

  table.table-card tbody tr:nth-child(odd) {
    background-color: #fff;
  }

  table.table-card tbody tr:hover {
    background-color: #f8f9ff;
  }

  table.table-card tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0.25rem;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.875rem;
  }

  table.table-card tbody td:last-child {
    border-bottom: none;
  }

  table.table-card tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--rcs-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    margin-right: 1rem;
  }

  table.table-card tbody td[data-label=""]::before,
  table.table-card tbody td.td-actions::before {
    display: none;
  }

  table.table-card tbody td.td-actions {
    justify-content: flex-end;
    padding-top: 0.5rem;
  }

  /* Nebenangaben (Rasse, Geschlecht, Wurfdatum) machen die Karte ein Drittel
     länger, ohne auf dem Handy gebraucht zu werden – sie stehen weiterhin im
     Excel-Export und in den Stammdaten. */
  table.table-card tbody td.cell-aux {
    display: none;
  }
}

/* ── Footer ──────────────────────────────────────────────────────────── */
.container-fluid .container.footer {
  flex-shrink: 0;
  width: 100%;
  max-width: var(--rcs-max-width);
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--rcs-border);
  background: #fff;
  font-size: 0.83rem;
  color: var(--rcs-text-muted);
}

.container.content .alert.alert-primary.d-flex.align-items-center.infobox .infoboxtext {
  margin-left: 5px;
}

/* ═══════════════════════════════════════════════════════════════════════
   Tablet 11"  – 768 px to 991 px
   ═══════════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) and (max-width: 991.98px) {
  .header .container.title .img-fluid.logo {
    max-height: 46px;
  }

  .container .title {
    font-size: 1.1rem;
  }

  .container-fluid .container.content {
    padding: 1.25rem 1rem 2rem;
  }

  .container-fluid .container.content .btn.btn-lg {
    min-width: 180px;
    font-size: 0.875rem;
  }

  table.table {
    font-size: 0.85rem;
  }

  /* Dropdown opens correctly on tablet without hover */
  .navbar.navbar-dark.bg-dark .dropdown-menu {
    position: absolute;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   Mobile  – below 768 px  (covers iPhone and small tablets)
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 767.98px) {
  .header .container.title {
    padding: 0.45rem 0.75rem;
  }

  .header .container.title .img-fluid.logo {
    max-height: 38px;
  }

  .container .title {
    font-size: 0.95rem;
  }

  .container-fluid .container.content {
    padding: 1rem 0.75rem 2rem;
  }

  .container-fluid .container.content h3 {
    font-size: 1.15rem;
  }

  .container-fluid .container.content h4 {
    font-size: 1rem;
  }

  /* Full-width buttons on mobile */
  .container-fluid .container.content .btn.btn-lg {
    min-width: 0;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  .btn-section,
  .button-section {
    flex-direction: column;
    gap: 6px;
  }

  /* Forms */
  .form-row > .col,
  .form-row > [class*="col-"] {
    padding-left: 6px;
    padding-right: 6px;
  }

  .form-inline {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .form-inline .form-control {
    width: 100%;
  }

  /* Tables */
  table.table {
    font-size: 0.78rem;
  }

  table.table th,
  table.table td {
    padding: 0.35rem 0.45rem;
  }

  /* Small action buttons */
  .btn.btn-sm {
    font-size: 0.72rem;
    padding: 0.2rem 0.35rem;
  }

  /* Breadcrumb */
  .admin-breadcrumb .breadcrumb {
    font-size: 0.78rem;
  }

  /* Dropdown in collapsed nav: no box shadow */
  .navbar.navbar-dark.bg-dark .dropdown-menu {
    box-shadow: none;
    border: 0;
    background-color: rgba(255, 255, 255, 0.05);
    padding-left: 1rem;
  }

  .navbar.navbar-dark.bg-dark .dropdown-item {
    color: rgba(255, 255, 255, 0.75);
  }

  .navbar.navbar-dark.bg-dark .dropdown-item:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   iPhone refined  – below 576 px
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 575.98px) {
  .header .container.title .img-fluid.logo {
    max-height: 32px;
  }

  .container .title {
    font-size: 0.85rem;
  }

  .container-fluid .container.content {
    padding: 0.75rem 0.6rem 1.5rem;
  }

  table.table {
    font-size: 0.72rem;
  }

  table.table th,
  table.table td {
    padding: 0.3rem 0.35rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   Ein-Bildschirm-Layout  (opt-in via <body class="page-compact">)
   Für Seiten, die während einer Veranstaltung ohne Scrollen ablesbar sein
   müssen – aktuell die Rangliste. Das Gerüst wird auf Viewport-Höhe fixiert:
   die Seite selbst scrollt nie. Zeilen bleiben einzeilig, sonst wird aus
   einer 30-px-Zeile durch einen Umbruch im Hundenamen sofort eine 89-px-
   Zeile. Passen mehr Starter nicht auf den Schirm, scrollt nur der
   Tabellenkörper unter dem stehenbleibenden Spaltenkopf.

   Kopfbereich, Navigation, Brotkrumen und Fusszeile bleiben BEWUSST
   unverändert: sie sind auf jeder Seite gleich, und wenn sie sich hier
   verkleinern, springt das Menü beim Seitenwechsel. Der Platz wird
   ausschliesslich innerhalb des Inhaltsbereichs geholt.

   Gilt erst ab Desktop-Breite; auf Tablet und Handy greift das normale
   responsive Layout.
   ═══════════════════════════════════════════════════════════════════════ */
@media (min-width: 992px) {
  body.page-compact {
    height: 100vh;
    /* dvh berücksichtigt die ein- und ausfahrende Browserleiste auf iPad
       und iPhone; vh bleibt als Rückfallwert für ältere Browser stehen. */
    height: 100dvh;
    overflow: hidden;
  }

  body.page-compact .container-fluid {
    height: 100vh;
    height: 100dvh;
  }

  body.page-compact .container-fluid .header {
    flex-shrink: 0;
  }

  body.page-compact .container-fluid .container.content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    /* Oben und seitlich exakt wie auf allen anderen Seiten (1.5rem/1.25rem) –
       das Menü steckt in diesem Container, jede Abweichung lässt es beim
       Seitenwechsel springen. Gespart wird nur unten. */
    padding: 1.5rem 1.25rem 0.75rem;
  }

  body.page-compact .container.content > .table-responsive {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }

  body.page-compact .ranking-legend {
    margin-top: 0.4rem !important;
    margin-bottom: 0 !important;
  }

  body.page-compact .alert {
    margin-bottom: 0.5rem;
  }

  /* Werkzeugleiste: Titel, WT-Auswahl und Aktionen teilen sich eine Zeile */
  body.page-compact .page-toolbar h3 {
    margin-bottom: 0;
  }

  body.page-compact .page-toolbar .form-control {
    height: auto;
    padding: 0.2rem 0.5rem;
  }

  /* Der WT-Name kann sehr lang werden und würde die Leiste umbrechen. */
  body.page-compact .page-toolbar select.form-control {
    max-width: 300px;
  }

  body.page-compact .page-toolbar .btn {
    padding: 0.2rem 0.55rem;
  }

  body.page-compact .page-toolbar label {
    margin-bottom: 0;
  }

  /* ── Datentabelle: normale Schriftgrösse, nur flachere Zeilen ── */
  table.table-compact thead.thead-light th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 0.3rem 0.4rem;
    line-height: 1.25;
  }

  /* Bezeichnung und Richter umbrechen statt abschneiden: die Breitengrenze
     bleibt, damit sechs Aufgaben nicht breiter werden als ein Laptop-
     Bildschirm — der Text läuft nun aber mehrzeilig weiter, statt hinter
     drei Punkten zu verschwinden. Betrifft nur den Kopf, die Datenzeilen
     bleiben einzeilig. */
  table.table-compact thead.thead-light th small {
    display: block;
    max-width: 100px;
    white-space: normal;
    overflow-wrap: break-word;
    line-height: 1.25;
  }

  /* Zeilenhöhe rund 30 px: dicht genug für viele Starter, aber hoch genug,
     dass man mit dem Auge sauber der Zeile entlang lesen kann. */
  table.table-compact td {
    padding: 0.3rem 0.4rem;
    line-height: 1.3;
    white-space: nowrap;
  }

  /* Lange Hundenamen kürzen statt umbrechen – voller Name im Tooltip. */
  table.table-compact td.cell-clip {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Der Bearbeiten-Knopf gibt sonst die Zeilenhöhe vor: er muss flacher
     bleiben als die Textzeile, sonst zieht er jede Zeile auseinander. */
  table.table-compact .btn-sm {
    padding: 0 0.35rem;
    font-size: 0.8rem;
    line-height: 1.2;
  }

  table.table-compact .form-control-sm {
    height: auto;
    padding: 0.05rem 0.3rem;
    line-height: 1.2;
  }
}

/* ── Tablet-Hochformat (iPad 10", 576–991 px) ────────────────────────────
   Zu schmal für die ganze Rangliste, zu gross für Karten. Die Tabelle
   bleibt eine Tabelle und scrollt seitwärts – aber die Zeilen bleiben
   einzeilig, sonst wird jede Zeile durch den Hundenamen dreimal so hoch.
   Bedienelemente behalten Fingergrösse. */
@media (min-width: 576px) and (max-width: 991.98px) {
  table.table-compact td {
    padding: 0.35rem 0.4rem;
    white-space: nowrap;
  }

  table.table-compact td.cell-clip {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  table.table-compact thead.thead-light th small {
    display: block;
    max-width: 120px;
    white-space: normal;
    overflow-wrap: break-word;
  }
}
