/* registry/static/registry/css/customer.css
   =====================================================
   Asiakasrekisteri (Bootstrap 5.3 color modes)
   ===================================================== */

/* =====================================================
   1) Teematokenit ja värit
   ===================================================== */

:root {
  /* Kevyt admin-henkinen sininen */
  --bs-primary: #417690;

  /* Linkit (käytetään rgba(var(--bs-link-color-rgb), 1)) */
  --bs-link-color-rgb: 65, 118, 144;
  --bs-link-hover-color-rgb: 30, 70, 95;

  /* Registry-omaa */
  --registry-hairline: var(--bs-border-color);
  --registry-quiet: var(--bs-secondary-color);
  --registry-hover-bg: rgba(0, 0, 0, 0.03);

  --registry-surface: #ecf1f4;
  --registry-surface-soft: #f7f9fb;
  --registry-filter-header-bg: #ecf1f4;

  --registry-primary-hover-bg: color-mix(in srgb, var(--bs-primary) 70%, #000);
  --registry-tabs-border: var(--bs-border-color);
}

html[data-bs-theme="dark"] {
  --bs-primary: #6aa6c8;
  --bs-link-color-rgb: 170, 200, 220;
  --bs-link-hover-color-rgb: 230, 245, 255;

  --registry-hairline: var(--bs-border-color);
  --registry-quiet: var(--bs-secondary-color);
  --registry-hover-bg: rgba(255, 255, 255, 0.06);

  --registry-surface: rgba(255, 255, 255, 0.06);
  --registry-surface-soft: rgba(255, 255, 255, 0.04);
  --registry-filter-header-bg: rgba(255, 255, 255, 0.06);
  --registry-tabs-border: var(--bs-border-color);

  /* Checkbox (dark) */
  --registry-check-checked-bg: #99c6ff;
  --registry-check-mark: #2b2f33;
  --registry-check-border-hover: color-mix(in srgb, var(--registry-tabs-border) 60%, #fff);
}

/* =====================================================
   2) Perustyylit ja utilit
   ===================================================== */

a {
  color: rgba(var(--bs-link-color-rgb), 1);
  text-decoration: none;
}

a:not(.btn):hover,
a:not(.btn):focus {
  color: rgba(var(--bs-link-hover-color-rgb), 1);
}

.my-4-3 {
  margin-top: 2rem;
  margin-bottom: 2rem;
}

/* Huom: mb-4-3 nimenä harhaanjohtava (sisältää myös margin-top). */
.mb-4-3 {
  margin-top: 2rem;
  margin-bottom: 2rem;
}

/* =====================================================
   3) Ylänavi (registry)
   ===================================================== */

.registry-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  min-height: 44px;
  background: var(--registry-surface-soft);
  border-bottom: 1px solid var(--registry-hairline);
  padding: 0;
}

html[data-bs-theme="dark"] .registry-nav {
  background: var(--bs-body-bg);
}

.registry-nav .container-fluid {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.registry-nav .nav-link,
.registry-nav button.nav-link,
.registry-nav .btn.btn-link.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 0.5rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--bs-body-color);
  text-decoration: none;
  opacity: 0.92;
  background: transparent;
  border: 0;
  box-sizing: border-box;
}

.registry-nav .nav-link:hover,
.registry-nav .nav-link:focus,
.registry-nav button.nav-link:hover,
.registry-nav button.nav-link:focus,
.registry-nav .btn.btn-link.nav-link:hover,
.registry-nav .btn.btn-link.nav-link:focus {
  opacity: 1;
  background: rgba(var(--bs-link-color-rgb), 0.10);
  text-decoration: none;
  outline: none;
}

.registry-nav .nav-link:focus-visible,
.registry-nav button.nav-link:focus-visible,
.registry-nav .btn.btn-link.nav-link:focus-visible {
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-link-color-rgb), 0.20);
}

.registry-nav .nav-link.active,
.registry-nav button.nav-link.active,
.registry-nav .btn.btn-link.nav-link.active {
  opacity: 1;
  font-weight: 600;
  background: rgba(var(--bs-link-color-rgb), 0.14);
}

.registry-nav .navbar-nav {
  gap: 0.4rem;
}

/* =====================================================
   4) Ilmoitukset (messages)
   ===================================================== */

.registry-messages-inner {
  width: 100%;
  margin: 0 auto;
}

body.page-customer-list .registry-messages-inner {
  max-width: 1100px; /* sama kuin .list-page */
}

body.page-customer-detail .registry-messages-inner {
  max-width: 60rem; /* sama kuin .customer-detail-card */
}

/* =====================================================
   5) Lomakkeet ja validointi
   ===================================================== */

.form-control.is-invalid,
.form-control.is-invalid:focus,
form input[type="file"].is-invalid {
  border-color: #dc3545 !important;
  box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25) !important;
}

/* Checkbox (yleinen) */
.form-check-input[type="checkbox"] {
  margin-top: 0;
  border: 1px solid var(--bs-body-color);
  background-color: var(--bs-form-check-bg);
}

.form-check-input[type="checkbox"]:checked {
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
}

.form-check-input[type="checkbox"]:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Checkbox (dark) */
html[data-bs-theme="dark"] .form-check-input[type="checkbox"] {
  background-color: var(--registry-surface);
  border: 2px solid var(--registry-tabs-border);
}

html[data-bs-theme="dark"] .form-check-input[type="checkbox"]:not(:checked):hover {
  background-color: var(--registry-surface);
  border-color: var(--registry-check-border-hover);
}

html[data-bs-theme="dark"] .form-check-input[type="checkbox"]:checked {
  background-color: var(--registry-check-checked-bg);
  border-color: var(--registry-check-checked-bg);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-7'/%3e%3c/svg%3e");
}

html[data-bs-theme="dark"] .form-check-input[type="checkbox"]:checked:hover {
  background-color: #e0eeff;
}

html[data-bs-theme="dark"] .form-check-input[type="checkbox"]:focus {
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
}

/* =====================================================
   6) Napit (registry primary)
   ===================================================== */

.btn-primary {
  --bs-btn-bg: var(--bs-primary);
  --bs-btn-border-color: var(--bs-primary);

  --bs-btn-hover-bg: color-mix(in srgb, var(--bs-primary) 70%, #000);
  --bs-btn-hover-border-color: color-mix(in srgb, var(--bs-primary) 65%, #000);

  --bs-btn-active-bg: color-mix(in srgb, var(--bs-primary) 60%, #000);
  --bs-btn-active-border-color: color-mix(in srgb, var(--bs-primary) 55%, #000);

  --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}

.btn-outline-primary {
  --bs-btn-color: var(--bs-primary);
  --bs-btn-border-color: var(--bs-primary);

  --bs-btn-hover-bg: var(--bs-primary);
  --bs-btn-hover-border-color: var(--bs-primary);
  --bs-btn-hover-color: #fff;

  --bs-btn-active-bg: color-mix(in srgb, var(--bs-primary) 82%, #000);
  --bs-btn-active-border-color: color-mix(in srgb, var(--bs-primary) 76%, #000);
  --bs-btn-active-color: #fff;

  --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}

/* =====================================================
   7) Paginointi
   ===================================================== */

.page-link {
  color: var(--registry-quiet);
}

.page-link:hover {
  color: var(--bs-body-color);
}

.page-item.active .page-link {
  --bs-pagination-active-bg: var(--bs-primary);
  --bs-pagination-active-border-color: var(--bs-primary);
  --bs-pagination-active-color: #fff;
}

/* =====================================================
   8) Asiakaslista
   ===================================================== */

.list-page {
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}

.list-page table .btn {
  min-width: 5rem;
}

.list-page .btn-primary.add-new {
  width: 11rem;
}

.list-page .input-group button.btn.btn-primary {
  min-width: 5rem;
  text-align: center;
}

#customer-search-form .form-control,
#customer-search-form .form-control:focus {
  background-color: var(--registry-filter-header-bg);
}

.filter-list a,
.filter-list a:hover,
.filter-list a:focus {
  text-decoration: none;
}

/* Customer list: vasen suodatinpaneeli */
.col-12.col-md-4.col-lg-3 > .card > .card-body {
  background-color: var(--registry-surface-soft);
}

.col-12.col-md-4.col-lg-3 > .card > .card-header {
  background-color: var(--registry-filter-header-bg);
  border-bottom: 1px solid var(--registry-hairline);
}

/* Taulukon sarakkeet: estä leviämistä */
.customer-table td,
.customer-table th {
  max-width: 0;
}

.customer-table .truncate {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Listasivu: vaakascroll ok, mutta älä leikkaa pystysuunnassa */
body.page-customer-list .table-responsive {
  overflow-x: auto;
  overflow-y: visible;
}

/* =====================================================
   9) Asiakaskortti (detail)
   ===================================================== */

.customer-detail-wrapper {
  display: flex;
  justify-content: center;
}

.customer-detail-card {
  background: var(--registry-surface-soft);
  border: 1px solid var(--registry-hairline);
  border-radius: 0.75rem;
  padding: 1.5rem;
  width: 100%;
  max-width: 60rem;
}

html[data-bs-theme="dark"] .customer-detail-card {
  border-color: rgba(255, 255, 255, 0.12);
}

/* Tabs */
.registry-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--bs-primary);
  margin-left: -1.5rem;
  margin-right: -1.5rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.registry-tabs .nav-item {
  flex: 1 1 0;
}

.registry-tabs .registry-tab-btn {
  background: #fff;
  border: 1px solid var(--bs-primary);
  color: var(--bs-primary);
  padding: 0.375rem 0.75rem;
  text-align: center;
}

.registry-tabs .registry-tab-btn:hover {
  background: var(--bs-primary);
  border-color: var(--bs-primary);
  color: #fff;
}

.registry-tabs .registry-tab-btn.active {
  background: var(--bs-primary);
  border-color: var(--bs-primary);
  color: #fff;
}

.registry-tabs .registry-tab-btn.active:hover {
  background-color: var(--registry-primary-hover-bg);
  border-color: var(--registry-primary-hover-bg);
}

html[data-bs-theme="dark"] .registry-tabs .registry-tab-btn {
  background: transparent;
}

html[data-bs-theme="dark"] .registry-tabs .registry-tab-btn.active {
  background: var(--bs-primary);
}

html[data-bs-theme="dark"] .registry-tabs .registry-tab-btn.active:hover {
  background: var(--registry-primary-hover-bg);
}

hr.full {
  color: var(--bs-primary);
  opacity: 1;
  margin-left: -1.5rem;
  margin-right: -1.5rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

/* Header: ellipsis */
.customer-header-left {
  flex: 1 1 auto;
  min-width: 0;
}

.customer-header-right {
  flex: 0 0 auto;
  white-space: nowrap;
}

.customer-name {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Kirjausten scrollaus (desktop) */
.actions-scrollbox {
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 0.25rem;
}

/* Touch / pienemmät näytöt: ei sisäkkäistä scrollia kirjauksille */
@media (max-width: 1024px) {
  .actions-scrollbox {
    max-height: none;
    overflow: visible;
    padding-right: 0;

    -webkit-mask-image: none;
    mask-image: none;
  }
}

@media (max-width: 767px) {
  .customer-name {
    white-space: normal;
  }
}

/* Attachments */
.attachment-meta {
  min-width: 0;
  flex: 1 1 auto;
}

.attachment-link {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-actions {
  flex: 0 0 auto;
}

/* Sticky tallennuspalkki */
#customer-save-bar {
  position: sticky;
  bottom: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
  will-change: transform;
}

#customer-save-bar button {
  padding: 0.75rem 1.75rem;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

@media (max-width: 576px) {
  #customer-save-bar {
    padding: 0.75rem;
  }
  #customer-save-bar .btn {
    width: 100%;
  }
}

@media (max-width: 768px) {
  #customer-save-bar {
    justify-content: center;
  }
}

/* Tallenna-napin muutosmerkki */
#customer-save-btn {
  position: relative;
}

#customer-save-btn .save-indicator {
  display: none;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background-color: var(--bs-warning);
  position: absolute;
  top: -0.3rem;
  right: -0.3rem;
}

#customer-save-btn.is-dirty .save-indicator {
  display: block;
}

/* Tablet: pieni tiivistys */
@media (min-width: 768px) and (max-width: 991px) {
  .list-page .btn-primary.add-new {
    width: 10.4rem;
  }
  .card-body {
    padding: 0.7rem;
  }
}

/* Detail mobile (<= 512px) */
@media (max-width: 512px) {
  .registry-tabs {
    border-bottom: 0;
    gap: 0.75rem;
  }
  .registry-tabs .nav-item {
    flex: 1 1 calc(50% - 0.375rem);
  }
  .registry-tabs .registry-tab-btn {
    width: 100%;
    border-radius: var(--bs-border-radius);
  }
  .sform-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* =====================================================
   10) Meta-rivit (Luotu / Muokattu)
   ===================================================== */

.customer-meta .meta-row {
  display: grid;
  grid-template-columns: 90px 9ch auto; /* label | pvm | klo */
  column-gap: 0.75rem;
  align-items: baseline;
}

.customer-meta .customer-meta-label {
  font-weight: 500;
  min-width: 0;
}

.customer-meta .meta-date {
  text-align: right;
}

.customer-meta .meta-time {
  white-space: nowrap;
}

/* =====================================================
   11) Tooltipit
   ===================================================== */

.tooltip .tooltip-inner {
  background-color: rgb(216, 232, 255);
  color: #555;
  max-width: 260px;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  line-height: 1.4;
  border-radius: 0.4rem;
}

.help-tooltip .tooltip-arrow,
.help-tooltip .tooltip-arrow::before {
  display: none !important;
}

.customer-detail-card label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  line-height: 1.5rem;
  padding-left: 0.8rem;
  margin-bottom: 0.3rem;
}

.customer-detail-card label.help-label {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  gap: 0.35rem;
  flex: 0 0 auto;
  margin-bottom: -3px;
  padding-left: 0.8rem;
}

.help-label > .bi {
  flex: 0 0 auto;
}

.help-label .bi::before {
  vertical-align: 1rem;
}

.help-tooltip {
  opacity: 1 !important;
}

/* =====================================================
   12) Entry (aloitussivu)
   ===================================================== */

.entry-container {
  max-width: 720px;
}

@media (min-width: 992px) {
  .entry-container {
    margin-top: 100px;
  }
}

.entry-container .entry-navi {
  padding: 10px 0;
}

.entry-container h1 {
  letter-spacing: 0.025em;
}

.recent-customers {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.recent-customer-card {
  display: grid;
  grid-template-columns: 3.8rem 1fr 6.5rem 6.5rem;
  align-items: center;
  column-gap: 0.75rem;
  padding: 0.5rem;
  overflow: hidden;
  background: var(--registry-surface);
  border: 1px solid var(--registry-hairline);
  border-radius: 0.375rem;
  text-decoration: none;
  color: inherit;
  width: 100%;
}

.recent-customer-card:hover {
  background-color: color-mix(in srgb, var(--registry-surface) 88%, #000);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.recent-id {
  justify-self: start;
  color: var(--registry-quiet);
  font-size: 0.85rem;
}

.recent-name {
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-date {
  color: var(--registry-quiet);
  justify-self: end;
  font-variant-numeric: tabular-nums;
}

.recent-action {
  color: var(--registry-quiet);
  justify-self: end;
}

.recent-date,
.recent-action,
.recent-id,
.recent-name {
  min-width: 0;
}

@media (max-width: 576px) {
  .recent-date {
    justify-self: start;
  }
}

@media (max-width: 576px) {
  .recent-customer-card {
    grid-template-columns: 3.8rem 1fr;
    grid-template-areas:
      "id   name"
      "date action";
    row-gap: 0.25rem;
  }
  .recent-id {
    grid-area: id;
  }
  .recent-name {
    grid-area: name;
  }
  .recent-date {
    grid-area: date;
    margin-left: 0 !important;
  }
  .recent-action {
    grid-area: action;
    justify-self: end;
    margin-left: 0 !important;
  }
}

/* =====================================================
   13) Login / logged-out
   ===================================================== */

.container.login,
.container.logged-out {
  max-width: 450px;
  margin-top: 3rem;
  margin-bottom: 3rem;
  padding: 1.5rem 1rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  background-color: var(--bs-body-bg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.login form {
  padding: 1rem 2.5rem;
}

.login p,
.login h1 {
  text-align: center;
}

/* =====================================================
   14) Admin-demogalleria
   ===================================================== */

.card {
    border: 1px solid #dee2e6;
    transition: all 0.2s ease;
}
.card:hover {
    border-color: #adb5bd;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.hover-zoom {
    width: 90%;
    margin: 0 auto;
    display: block;
    transition: all 0.25s ease;
}
.hover-zoom:hover {
    width: 100%;
}
#galleryModalImage {
    max-height: 90vh;
    max-width: 90%;
    width: auto;
    height: auto;
    object-fit: contain;
}
.gallery-image-wrap {
    width: 100%;
    overflow: hidden;
    border-radius: 0.375rem;
}
.hover-zoom {
    width: 100%;
    display: block;
    transform: scale(0.9);
    transform-origin: center center;
    transition: transform 0.25s ease;
}
.hover-zoom:hover {
    transform: scale(1);
}