/* ===========================
   Homlify — Common Styles
   =========================== */

/* Base */
body {
  font-family: "Montserrat", sans-serif;
  font-style: normal;
  padding-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
}

/* Telegram Mini App — sidebar safe area */
.layout-menu {
  padding-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
}

/* Telegram Mini App — hide elements marked for TG mode */
.tg-miniapp .tg-hide {
  display: none !important;
}

/* Telegram Mini App — hide in-app back buttons (Telegram provides its own) */
.tg-miniapp [title="Назад"] {
  display: none !important;
}

h1 {
  color: #ebc03f;
  font-family: "Montserrat", sans-serif;
  font-weight: 600;
  font-size: 33px;
}

/* Layout */
.app-narrow {
  width: 100%;
  max-width: 760px;
}

.app-contact-form {
  width: 100%;
  max-width: 576px;
}

.app-brand .app-brand-text {
  margin-inline-start: 0rem;
}

/* Navbar nav links — override VUEXY nav-link color */
.app-brand .navbar-nav > li > a.text-muted {
  color: #6e6b7b !important;
}
.app-brand .navbar-nav > li > a.text-dark {
  color: var(--bs-dark) !important;
}

@media (min-width: 992px) {
  #layout-menu {
    display: none !important;
  }
  .layout-page {
    padding-left: 0 !important;
  }
}

/* Utilities */
.fs-8 {
  font-size: 8px;
}

.fs-11 {
  font-size: 11px;
}

.line-clamp-1 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.clamp-open {
  -webkit-line-clamp: unset;
}

.icon-home {
  color: #ababab;
}

/* Property photo placeholder */
.photo-placeholder {
  background: rgba(115, 103, 240, 0.1);
  color: rgba(115, 103, 240, 0.32);
}

/* ===========================
   Rounded corners (16px)
   =========================== */
.card { border-radius: 1rem !important; }
.dropdown-menu { border-radius: 1rem !important; }
.card .list-group { border-radius: 1rem !important; }
.card .list-group-item:first-child { border-top-left-radius: 1rem !important; border-top-right-radius: 1rem !important; }
.card .list-group-item:last-child { border-bottom-left-radius: 1rem !important; border-bottom-right-radius: 1rem !important; }

/* Overlay (locked state) */
.locked-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
  z-index: 2;
  backdrop-filter: blur(2px);
}

/* Hover for clickable cards */
a.text-decoration-none:hover .bg-light-subtle {
  background-color: rgba(0, 0, 0, 0.06) !important;
  transition: background-color 0.2s ease;
}

a.text-decoration-none .text-muted {
  color: #6c757d !important;
}

a.text-decoration-none .text-primary {
  color: var(--bs-primary) !important;
}

a.text-decoration-none .text-dark {
  color: var(--bs-dark) !important;
}

/* Quick filters — small pills */
.quick-filters .nav-link {
  font-size: 11px;
  padding: 4px 10px;
}

/* Accordion rounded */
.accordion-item {
  overflow: hidden;
  border: none !important;
}

/* Glass UI */
.glass-ui {
  background: rgba(20, 20, 20, 0.45);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: #fff;
  transition:
    background-color .25s ease,
    box-shadow .25s ease,
    transform .2s ease,
    opacity .2s ease;
}

.glass-ui:hover {
  background: rgba(30, 30, 30, 0.65);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

.glass-ui:active {
  transform: scale(0.96);
}

.glass-ui:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.25),
    0 8px 24px rgba(0, 0, 0, 0.35);
}

/* Gallery navigation buttons */
.gallery-nav-btn {
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.2s ease;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(10px);
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  color: #fff;
}

/* Responsive clamp override */
@media (max-width: 576px) {
  .line-clamp-2-mobile {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
}

/* ===========================
   Settings page — Color picker
   =========================== */
.color-picker input {
  display: none;
}

.color-box {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid #e4e6ef;
  display: block;
}

.color-picker input:checked + .color-box {
  border: 3px solid #7367f0;
}

/* ===========================
   Settings page — maxlength counter
   =========================== */
.maxlength-counter {
  display: block;
  margin-top: 0.35rem;
  font-size: 12px;
  text-align: right;
}

/* ===========================
   Validation — field error states
   =========================== */
.form-control.is-invalid,
.form-select.is-invalid {
  border-color: var(--bs-danger) !important;
}

.invalid-feedback {
  font-size: 12px;
  color: var(--bs-danger);
  margin-top: 0.25rem;
}

/* Error text: full width by default */
.invalid-feedback:not(:empty) {
  display: inline-block !important;
  vertical-align: top;
}
/* Shrink only when char counter follows */
.invalid-feedback:not(:empty):has(+ .maxlength-counter) {
  max-width: calc(100% - 62px);
}
.invalid-feedback:not(:empty) + .maxlength-counter {
  display: inline-block;
  margin-top: 0.25rem;
  vertical-align: top;
  float: right;
  text-align: right;
}

/* ===========================
   Settings — tighter form-label spacing
   =========================== */
.card-body .form-label {
  margin-bottom: 0.25rem;
}

/* ===========================
   Settings — schedule time bold
   =========================== */
.schedule-status {
  font-weight: 600;
}

/* Select2 — match form-control-lg height */
select.form-control-lg + .select2-container .select2-selection--single {
  block-size: calc(1.625em + 1.15rem + calc(var(--bs-border-width) * 2));
}
select.form-control-lg + .select2-container .select2-selection--single .select2-selection__rendered {
  line-height: calc(1.625em + 1.15rem);
}

/* Input-group — full validation highlight (uniform border) */
.input-group.is-invalid > .input-group-text,
.input-group.is-invalid > .form-control {
  border-color: var(--bs-danger) !important;
  border-width: 1px !important;
}
.input-group.is-valid > .input-group-text,
.input-group.is-valid > .form-control {
  border-color: var(--bs-success) !important;
  border-width: 1px !important;
}

/* Select2 inside .is-invalid parent */
.is-invalid + .select2-container .select2-selection {
  border-color: var(--bs-danger) !important;
}

/* Bootstrap-select inside .is-invalid parent */
.is-invalid + .bootstrap-select .dropdown-toggle {
  border-color: var(--bs-danger) !important;
}

/* Bootstrap-select — fix flicker on select (active→selected gap) */
.bootstrap-select .dropdown-menu .dropdown-item {
  transition: background-color 0.12s ease, color 0.12s ease;
}

/* Smooth scroll offset for invalid fields */
.is-invalid {
  scroll-margin-top: 100px;
}

/* Compact badge for nav-tabs */
.badge-xs {
  font-size: .625rem;
  padding: .1rem .35rem;
  line-height: 1.2;
}

/* ===========================
   Photo Grid (Catalog edit)
   =========================== */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.photo-item {
  aspect-ratio: 1;
  position: relative;
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--bs-gray-100);
  cursor: grab;
  user-select: none;
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.photo-item.sortable-ghost { opacity: 0.35; }
.photo-item.sortable-chosen { cursor: grabbing; box-shadow: 0 4px 16px rgba(0,0,0,0.18); }
.photo-item.sortable-drag   { opacity: 0; }

/* X delete button */
.photo-delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
  padding: 0;
  line-height: 1;
  font-size: 12px;
}
.photo-delete-btn:hover { background: rgba(220, 53, 69, 0.85); }

/* Cover badge */
.photo-cover-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 2;
}

/* Upload progress overlay */
.photo-upload-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  display: flex;
  align-items: flex-end;
  z-index: 2;
}

.photo-upload-progress {
  height: 3px;
  background: var(--bs-primary);
  transition: width 0.1s linear;
  min-width: 4px;
}

/* Error state */
.photo-item.photo-error { outline: 2px solid var(--bs-danger); }

.photo-error-msg {
  position: absolute;
  inset: 0;
  background: rgba(220, 53, 69, 0.72);
  color: #fff;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px;
  z-index: 2;
}

/* Add (+) button */
.photo-add-btn {
  aspect-ratio: 1;
  border-radius: 0.5rem;
  border: 2px dashed var(--bs-border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--bs-secondary-color);
  transition: border-color 0.15s, color 0.15s;
  font-size: 1.5rem;
}
.photo-add-btn:hover { border-color: var(--bs-primary); color: var(--bs-primary); }
.photo-add-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===========================
   Scroll reveal — subtle shadow on viewport enter
   =========================== */
.card-reveal {
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  transition: box-shadow 0.6s ease;
}

.card-reveal.in-view {
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.04);
}

/* ===========================
   Bottom Bar (Telegram Mini App)
   =========================== */

/* Hide sidebar & burger in Mini App */
.tg-miniapp #layout-menu {
  display: none !important;
}
.tg-miniapp .layout-menu-toggle {
  display: none !important;
}
.tg-miniapp .layout-overlay {
  display: none !important;
}

/* Bottom bar container */
.tg-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1080;
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-bottom: max(22px, env(safe-area-inset-bottom, 22px));
}

.tg-miniapp .tg-bottom-bar {
  display: block;
}

/* Content padding when bottom bar is visible */
.tg-miniapp .content-wrapper {
  padding-bottom: calc(3.5rem + max(22px, env(safe-area-inset-bottom, 22px)) + 16px) !important;
}

.tg-bottom-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 3.5rem;
  max-width: 480px;
  margin: 0 auto;
}

.tg-bottom-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  text-decoration: none;
  color: #a1a0ae;
  font-size: 9px;
  font-weight: 500;
  line-height: 1;
  padding: 4px 0;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease;
}

.tg-bottom-bar-item .tg-bar-icon {
  --bs-icon-size: 28px;
  font-size: 28px !important;
  block-size: 28px;
  inline-size: 28px;
  line-height: 1;
  transition: color 0.15s ease;
}

.tg-bottom-bar-item.active {
  color: var(--bs-primary);
}

.tg-bottom-bar-item .tg-bar-badge {
  position: absolute;
  top: 2px;
  left: 50%;
  margin-left: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bs-success);
  border: 2px solid #fff;
  box-sizing: content-box;
}

/* Bottom sheet (More menu) */
.tg-more-sheet {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1090;
}

.tg-more-sheet.show {
  display: block;
}

.tg-more-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  animation: tgFadeIn 0.2s ease;
}

.tg-more-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 1rem 1rem 0 0;
  padding: 8px 0;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  padding-bottom: calc(8px + var(--tg-safe-area-inset-bottom, 0px));
  animation: tgSlideUp 0.25s ease;
}

.tg-more-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #d9d9d9;
  margin: 4px auto 12px;
}

.tg-more-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: #5d596c;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease;
}

.tg-more-item:hover,
.tg-more-item:active {
  background: rgba(0, 0, 0, 0.04);
  color: #5d596c;
}

.tg-more-item .ti {
  font-size: 22px;
  color: #a1a0ae;
}

.tg-more-item.active .ti {
  color: var(--bs-primary);
}

.tg-more-item .badge {
  font-size: 10px;
}

@keyframes tgSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes tgFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
