/* ============================================================
   HT Extensions – Shared Frontend CSS
   /media/ht_shared/css/frontend.css

   Loaded by: com_pacepal, com_htraininglogs, com_hworkouts, com_hshopitems
   Colour source: /media/templates/site/cassiopeia/css/user.css

   Sections:
     1.  CSS Variables
     2.  Typography & Links
     3.  Navbar
     4.  Tables
     5.  Forms
     6.  Utility Classes
     7.  Chart Widgets
     8.  Form Card / Downtime Layout
     9.  Row & Cell Color Coding
   ============================================================ */


/* ============================================================
   1. CSS VARIABLES
   ============================================================ */
:root {
  --cassiopeia-color-primary:   hsl(0, 0%, 20%);
  --cassiopeia-color-secondary: hsl(0, 0%, 40%);
  --cassiopeia-color-link:      hsl(0, 0%, 10%);
  --cassiopeia-color-hover:     hsl(0, 0%, 40%);
}


/* ============================================================
   2. TYPOGRAPHY & LINKS
   ============================================================ */
a[href*="index.php"],
a.hasTooltip,
th a {
  color: var(--cassiopeia-color-link);
  font-weight: bold !important;
  text-decoration: none !important;
}

a[href*="index.php"]:hover,
a.hasTooltip:hover,
th a:hover {
  color: var(--cassiopeia-color-hover);
  text-decoration: underline !important;
}

td a[href*="index.php"].btn-link {
  color: var(--cassiopeia-color-link);
  font-weight: bold !important;
  text-decoration: none !important;
}

td a[href*="index.php"].btn-link:hover {
  text-decoration: underline !important;
}


/* ============================================================
   3. NAVBAR
   ============================================================ */
.navbar {
  background-color: #2c2c2c;
  padding: 0.2rem 0.6rem;
}

.navbar .nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.1em;
  font-size: 0.85rem;
  padding: 0.3rem 0.4rem;
  color: #ccc;
}

.navbar .nav-link.active {
  color: #fff !important;
}

.navbar .nav-link:hover {
  color: #fff;
  text-decoration: none;
}

.navbar .nav-link i {
  font-size: 1.35rem;
  margin-bottom: 0.2em;
  color: inherit;
}

.navbar .dropdown-menu {
  background-color: #2c2c2c !important;
  border: none;
}

.navbar .dropdown-menu .dropdown-item {
  background-color: #2c2c2c !important;
  color: #ccc !important;
}

.navbar .dropdown-menu .dropdown-item:hover {
  background-color: #3a3a3a !important;
  color: #fff !important;
}

@media (max-width: 768px) {
  .navbar .navbar-brand {
    margin-right: 0.05rem;
    padding: 0;
    display: flex;
    align-items: center;
  }

  .navbar .navbar-brand img {
    max-height: 30px;
    width: auto;
    vertical-align: middle;
  }

  .navbar .navbar-nav {
    display: flex;
    gap: 0;
    padding: 0;
  }

  .navbar .nav-item {
    margin: 0;
  }

  .navbar .nav-link {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 0.65rem;
    padding: 0.30rem 0;
    line-height: 1;
    color: #ccc;
    gap: 0;
  }

  .navbar .nav-link i {
    font-size: 1.2rem;
    line-height: 1;
    color: inherit;
  }

  .navbar .dropdown-menu .dropdown-item {
    font-size: 0.70rem;
    padding: 0.5rem 1rem;
    line-height: 1.2;
  }
}


/* ============================================================
   4. TABLES
   ============================================================ */
/* Bootstrap 5 thead variable overrides */
.table > thead {
  --bs-table-bg: #343a40;
  --bs-table-color: #fff;
  --bs-table-border-color: #454d55;
  --bs-table-striped-bg: #343a40;
  --bs-table-accent-bg: #343a40;
}

th.tablehead,
.table > thead > tr > th,
.table > thead > tr > td {
  background-color: #343a40 !important;
  color: #fff !important;
  border-color: #454d55 !important;
  padding: 0.5rem;
  text-align: left;
  font-weight: normal;
}

.table > thead > tr > th a,
.table > thead > tr > th a:hover,
.table > thead > tr > th a:focus {
  color: #fff !important;
}

.table {
  font-size: 1.0rem;
  width: 100%;
  border-collapse: collapse;
}

@media (max-width: 992px) {
  .table { font-size: 0.9rem; }
}

@media (max-width: 768px) {
  .table { font-size: 0.8rem; overflow-x: auto; }
  td { padding: 0.1rem; }
}

/* Card headers matching the dark table-header style */
.ht-card-header {
  background-color: #343a40 !important;
  color: #fff !important;
  border-color: #454d55 !important;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ht-card-header a,
.ht-card-header a:hover {
  color: #fff !important;
}


/* ============================================================
   5. FORMS
   ============================================================ */
th.radio, td.radio {
  width: 50px;
  padding-left: 0.3rem;
  padding-right: 1.3rem;
  text-align: center;
}

/* Range slider */
input[type="range"].form-range {
  width: 100%;
  margin: 0.5em 0;
  accent-color: var(--cassiopeia-color-link);
}

input[type="range"]::-webkit-slider-thumb {
  background-color: var(--cassiopeia-color-link);
  border: none;
}

input[type="range"]::-moz-range-thumb {
  background-color: var(--cassiopeia-color-link);
  border: none;
}

input[type="range"]::-ms-thumb {
  background-color: var(--cassiopeia-color-link);
  border: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  background-color: #555;
}

@media (max-width: 768px) {
  input.form-control,
  select.form-select,
  select.form-control,
  textarea.form-control {
    height: auto !important;
    font-size: 0.8rem;
    padding: 0.3rem 0.4rem;
  }

  label {
    font-size: 0.8rem;
    line-height: 1.2;
  }

  #jform_cdate {
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
    height: auto !important;
    line-height: 1.2;
  }

  #jform_cdate_btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
    height: auto;
  }

  input[type="radio"]:checked {
    accent-color: var(--cassiopeia-color-link);
  }

  .btn.btn-link {
    font-size: 0.8rem;
  }

  .btn.btn-primary, .btn.btn-secondary {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    line-height: 2;
  }

  .js-editor-tinymce {
    font-size: 0.8rem;
    margin-bottom: 1rem;
  }

  .tox .tox-edit-area iframe body,
  .mce-content-body {
    font-size: 0.7rem;
  }
}


/* ============================================================
   6. UTILITY CLASSES
   ============================================================ */

/* btn-outline-primary: dark theme color instead of Bootstrap's default blue.
   Both --btn-* (Joomla/Cassiopeia compile) and --bs-btn-* (Bootstrap 5.3+)
   prefixes are set so the override works regardless of BS version. */
.btn-outline-primary {
  --btn-color:              var(--cassiopeia-color-primary, #2c2c2c);
  --btn-border-color:       var(--cassiopeia-color-primary, #2c2c2c);
  --btn-hover-bg:           var(--cassiopeia-color-primary, #2c2c2c);
  --btn-hover-border-color: var(--cassiopeia-color-primary, #2c2c2c);
  --btn-hover-color:        #fff;
  --btn-active-bg:          var(--cassiopeia-color-primary, #2c2c2c);
  --btn-active-border-color:var(--cassiopeia-color-primary, #2c2c2c);
  --btn-active-color:       #fff;
  --bs-btn-color:              var(--cassiopeia-color-primary, #2c2c2c);
  --bs-btn-border-color:       var(--cassiopeia-color-primary, #2c2c2c);
  --bs-btn-hover-bg:           var(--cassiopeia-color-primary, #2c2c2c);
  --bs-btn-hover-border-color: var(--cassiopeia-color-primary, #2c2c2c);
  --bs-btn-hover-color:        #fff;
  --bs-btn-active-bg:          var(--cassiopeia-color-primary, #2c2c2c);
  --bs-btn-active-border-color:var(--cassiopeia-color-primary, #2c2c2c);
  --bs-btn-active-color:       #fff;
}
.extra-small { font-size: 0.85em; }

.bi.bi-pencil { font-size: .66em; }

@media (max-width: 992px) {
  .extra-small { font-size: 0.80em; }
}

@media (max-width: 768px) {
  .extra-small { font-size: 0.7em; white-space: nowrap; }

  .btn-group .btn {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
  }

  .btn-group .btn i {
    font-size: 0.75em;
    margin-right: 0.2em;
  }
}

.row-background0 { background-color: #f8f9fa; border-radius: 4px; padding: 4px; }
.row-background1 { background-color: #e9ecef; border-radius: 4px; padding: 4px; }


/* ============================================================
   7. CHART WIDGETS
   ============================================================ */
.ht-chart-wrap { position: relative; }

.ht-legend-toggle {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 10;
  font-size: 0.78rem;
  padding: 1px 5px;
  border: 1px solid #ced4da;
  border-radius: 3px;
  background: rgba(248,249,250,0.92);
  cursor: pointer;
  line-height: 1.5;
  color: #495057;
}

.ht-legend-toggle:hover { background: #e9ecef; }


/* ============================================================
   8. FORM CARD / DOWNTIME LAYOUT
   ============================================================ */
.control-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.75rem;
  gap: 0.25rem;
}

.control-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: #495057;
  margin-bottom: 0;
  padding: 0;
  text-align: left;
  width: 100% !important;
  float: none !important;
}

.controls {
  width: 100% !important;
  float: none !important;
}

.controls input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.controls select,
.controls textarea,
.controls .form-control,
.control-group input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.control-group select,
.control-group textarea {
  width: 100%;
  min-height: 44px;
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  box-sizing: border-box;
}

.controls textarea,
.control-group textarea {
  min-height: 80px;
}

.sessionform-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.sessionform-buttons .btn,
form > .btn,
.form-validate > .btn {
  width: 100%;
  min-height: 48px;
  font-size: 1rem;
  border-radius: 0.375rem;
}

form .btn-primary,
form .btn-danger,
form .btn-secondary {
  min-height: 48px;
  font-size: 1rem;
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
}

.alert-info {
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
}

@media (min-width: 768px) {
  .form-horizontal .control-group {
    flex-direction: row;
    align-items: flex-start;
    gap: 0;
  }

  .form-horizontal .control-label {
    width: 28% !important;
    text-align: right;
    padding-right: 1rem;
    padding-top: 0.5rem;
    font-size: 0.9rem;
  }

  .form-horizontal .controls {
    width: 72% !important;
  }

  .sessionform-buttons {
    flex-direction: row;
  }

  .sessionform-buttons .btn {
    width: auto;
    flex: 0 1 auto;
  }

  form .btn-primary,
  form .btn-danger,
  form .btn-secondary {
    margin-right: 0.5rem;
    margin-bottom: 0;
  }
}

/* Downtime / plan card */
.ht-form-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0.75rem 0 1rem;
}

.ht-downtime-card {
  position: relative;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.ht-downtime-new {
  border-color: #adb5bd;
  border-left: 4px solid #6c757d;
  background: #f8f9fa;
}

.ht-field-group {
  margin-bottom: 0.75rem;
}

.ht-field-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #495057;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ht-field-group input,
.ht-field-group select,
.ht-field-group textarea {
  width: 100%;
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  min-height: 44px;
  box-sizing: border-box;
  background-color: #fff;
}

.ht-field-group textarea {
  min-height: 80px;
  resize: vertical;
}

.ht-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 400px) {
  .ht-field-row { grid-template-columns: 1fr; }
}

.ht-form-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding-bottom: 1.5rem;
}

.ht-form-buttons .btn {
  flex: 1;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 0.375rem;
}

@media (min-width: 600px) {
  .ht-form-buttons .btn {
    flex: 0 1 auto;
    min-width: 130px;
  }
}


/* ============================================================
   9. LIST TOOLBAR
   ============================================================ */
.ht-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  width: 100%;
}

.ht-toolbar select,
.ht-toolbar .form-select,
.ht-toolbar input[type="range"] {
  width: 100%;
}

.ht-toolbar .input-group {
  flex-direction: row;
}

.ht-toolbar label.form-label {
  margin-bottom: 0;
}

.ht-toolbar-btn {
  display: flex;
  justify-content: flex-end;
  width: 100%;
}


/* ============================================================
   10. ROW & CELL COLOR CODING
   ============================================================ */
/* Shop items */
tr.order   { background-color: #F7F8E0; }
tr.retired { background-color: #999999; }
tr.in      { background-color: #E6F8E0; }
tr.out     { background-color: #F8E0E0; }

td.icon {
  min-width: 40px;
  max-width: 70px;
}

td.money,
th.money {
  text-align: right;
}
