/* static/css/pages/kp.css */

/* ================================================================
   KP EXAMPLES PAGE  (.kp_examples.html)
   ================================================================ */

/* Generic section wrapper used in kp_examples */
.home-section {
  padding: 0.5%;
}

.home-section-head {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.home-section-title {
  font-size: clamp(26px, 4vw, 38px);
  font-weight: 800;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}

.home-section-title1 {
  background: linear-gradient(135deg, var(--purple-2), var(--color-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Utility */
.center { text-align: center; }

/* KP Examples grid */
.kp-examples-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
@media (max-width: 900px) { .kp-examples-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .kp-examples-grid { grid-template-columns: 1fr; } }

.kp-example-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  padding: 20px;
  transition: transform var(--transition-base), box-shadow var(--transition-base),
              border-color var(--transition-base);
}
.kp-example-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--color-accent);
}
.kp-example-card.featured {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent);
}
.kp-example-card.premium {
  border-color: rgba(124, 58, 237, 0.55);
}

.kp-example-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  width: fit-content;
}
.kp-example-badge.basic   { background: rgba(100, 116, 139, 0.14); color: #64748b; }
.kp-example-badge.pro     { background: rgba(124, 58, 237, 0.14); color: var(--color-accent); }
.kp-example-badge.vip     { background: rgba(234, 179, 8, 0.14); color: #ca8a04; }

.kp-example-media {
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--tile-media-bg);
}
.kp-example-media img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--transition-slow);
}
.kp-example-card:hover .kp-example-media img { transform: scale(1.05); }

.kp-example-title {
  font-size: 18px;
  font-weight: 800;
  margin: 0;
}
.kp-example-sub {
  font-size: 15px;
  color: var(--muted);
  margin: 0;
}

.kp-example-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}
.kp-example-list li {
  padding: 6px 10px;
  background: var(--hover);
  border-radius: var(--radius-sm);
}

.kp-example-price {
  font-size: 22px;
  font-weight: 900;
  color: var(--color-accent);
  margin-top: auto;
  padding-top: 8px;
}

.kp-example-note {
  font-size: 12px;
  line-height: 1.5;
}

/* CTA block at bottom of kp_examples */
.home-cta {
  text-align: center;
  padding: 50px 30px;
}
.home-cta-title {
  font-size: clamp(20px, 3vw, 30px);
  font-weight: 800;
  margin: 0 0 10px;
}
.home-cta-sub {
  font-size: 15px;
  margin: 0 0 30px;
}
.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn-primary {
  background: linear-gradient(180deg, var(--purple-2), var(--purple));
  border-color: var(--purple-border);
  color: #fff;
  box-shadow: 0 10px 26px var(--purple-glow);
}

/* ===== KP tabs + list ===== */
.kp-tabs-wrap{
  margin-top: 12px;
  display:flex;
  justify-content:center;
}

.kp-tabs{
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px;
  display:flex;
  gap: 6px;
  backdrop-filter: blur(10px);
}

.kp-tab{
  flex:1;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 12px;
  background: transparent;
  color: var(--text);
  cursor:pointer;
  font-weight: 800;

  display:flex;
  align-items:center;
  justify-content:center;
  text-decoration:none;
}

.kp-tab:hover{
  background: var(--hover);
  border-color: var(--border);
}

.kp-tab.is-active{
  background: linear-gradient(180deg, var(--tile-hover), var(--tile-bg));
  border-color: var(--focus-border);
  box-shadow: var(--shadow);
}

.kp-tab:active{ transform: scale(0.99); }

.kp-center{
  margin-top: 12px;
  display:flex;
  justify-content:center;
}

.kp-center-card{
  width: 100%;
  max-width: 720px;
}

@media (max-width: 520px){
  .kp-center-card{ max-width: 100%; }
}

.kp-item{
  display:block;
  text-decoration:none;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 35px;
  transition: background .12s ease, border-color .12s ease, transform .12s ease, box-shadow .12s ease;
}

.kp-item:active{ transform: scale(0.99); }

@media (hover:hover){
  .kp-item:hover{
    background: var(--hover);
    border-color: var(--focus-border);
    box-shadow: var(--shadow);
  }
}

.kp-item-title{
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kp-item-sub{
  font-size: 12px;
  margin-top: 2px;
}

/* ===== KP admin home (compact layout) ===== */
.kp-admin-home .page-head{
  margin-bottom: 8px;
}

.kp-admin-home .kp-admin-note{
  margin-top: 4px;
  font-size: 12px;
}

.kp-admin-home .kp-tabs-wrap{
  margin-top: 8px;
}

.kp-admin-home .kp-tabs{
  max-width: 560px;
  padding: 5px;
  gap: 5px;
}

.kp-admin-home .kp-tab{
  padding: 8px 10px;
}

.kp-admin-home .kp-center{
  margin-top: 10px;
}

.kp-admin-home .kp-center-card{
  max-width: 980px;
}

.kp-admin-home .kp-admin-search{
  margin: 0 0 10px;
}

.kp-admin-home .kp-admin-search-field{
  position: relative;
}

.kp-admin-home .kp-admin-search-input{
  width: 100%;
  height: 58px;
  padding-right: 74px;
  border-radius: 16px;
}

.kp-admin-home .kp-admin-search-submit{
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border: 1px solid var(--purple-border);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--purple-2), var(--purple));
  color: #fff;
  box-shadow: 0 8px 18px rgba(109, 40, 217, 0.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.kp-admin-home .kp-admin-search-submit svg{
  width: 20px;
  height: 20px;
}

.kp-admin-home .kp-admin-search-submit:hover{
  filter: brightness(1.04);
}

.kp-admin-home .kp-admin-search-submit:active{
  transform: translateY(-50%) scale(0.98);
}

.kp-admin-home .kp-admin-search-submit:focus-visible{
  outline: 3px solid rgba(109, 40, 217, 0.25);
  outline-offset: 2px;
}

.kp-admin-home .kp-admin-list-hint{
  margin: 0 0 8px;
  font-size: 15px;
}

.kp-admin-home .kp-list{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.kp-admin-home .kp-item{
  padding: 14px;
  border-radius: 16px;
}

.kp-admin-home .kp-row{
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

.kp-admin-home .kp-item-title{
  font-size: 17px;
  line-height: 1.24;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.kp-admin-home .kp-item-sub{
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.35;
}

.kp-admin-home .kp-item-actions{
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.kp-admin-home .kp-item-actions > a.btn,
.kp-admin-home .kp-item-actions > form{
  width: 100%;
  min-width: 0;
  margin: 0;
}

.kp-admin-home .kp-item-actions > a.btn,
.kp-admin-home .kp-item-actions > form > button.btn{
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
}

.kp-admin-home .kp-admin-search-empty{
  margin-top: 8px;
}

@media (max-width: 1100px){
  .kp-admin-home .kp-center-card{
    max-width: 900px;
  }
}

@media (max-width: 900px){
  .kp-admin-home .kp-list{
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px){
  .kp-admin-home .kp-item-actions{
    width: 100%;
  }
}

@media (max-width: 560px){
  .kp-admin-home .kp-tabs-wrap{
    justify-content: flex-start;
  }

  .kp-admin-home .kp-tabs{
    max-width: 100%;
    overflow-x: auto;
    border-radius: 14px;
    scrollbar-width: thin;
  }

  .kp-admin-home .kp-tab{
    flex: 0 0 auto;
    white-space: nowrap;
    min-width: 112px;
  }

  .kp-admin-home .kp-item-actions{ width: 100%; }

  .kp-admin-home .kp-admin-search-input{
    height: 54px;
    padding-right: 66px;
  }

  .kp-admin-home .kp-admin-search-submit{
    width: 40px;
    height: 40px;
    right: 7px;
  }
}

/* кнопки выбора клиента */
.kp-modal-search{
  margin: 0 0 10px;
}

.kp-pick-form{
  margin: 0;
}

.kp-pick{
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
}

.kp-pick:active{ transform: scale(0.99); }

@media (hover:hover){
  .kp-pick:hover{
    background: var(--hover);
    border-color: var(--focus-border);
  }
}

.kp-pick-title{
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kp-pick-sub{ font-size: 12px; margin-top: 2px; }

.kp-modal-search-empty{
  margin-top: 10px;
}

/* ===== subcategory_services: scrollable modal ===== */
.modal--scroll{
  display: flex;
  flex-direction: column;
  max-height: 82vh;
  overflow: hidden;
}

.modal-header--sticky{
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.modal-body{
  padding: 12px 0;
  overflow: hidden;
}

.modal-scroll{
  max-height: 52vh;
  overflow: auto;
  padding-right: 6px;
}

.modal-actions--sticky{
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* карточка выбора КП в модалке */
.kp-choice-card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kp-choice-title{
  font-weight: 900;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kp-choice-actions{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.kp-choice-actions form{ margin: 0; }

@media (max-width: 640px){
  .modal--scroll{ max-height: 90vh; }
  .modal-scroll{ max-height: 60vh; }
  .kp-choice-actions{ grid-template-columns: 1fr; }
}

/* =========================
   KP BUILDER
========================= */

.kp-builder-title{
  text-align:center;
  font-weight: 950;
  font-size: 22px;
  line-height: 1.15;
  word-break: break-word;
  margin: 2px 0 0;
}

.kp-section-title{
  font-weight: 900;
  text-align: center;
}

.kp-section-subtitle{
  margin-top: 6px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.kp-actions{
  margin-top: 8px;
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
}

.kp-actions .btn{
  width: auto;
  flex: 1 1 0;
  min-width: 0;
}

.kp-center-actions{
  display:flex;
  justify-content:center;
  gap:8px;
  flex-wrap:wrap;
  margin-top:8px;
}

.kp-center-actions .btn{
  min-width: 160px;
}

.kp-cover-wrap{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:flex-start;
}

.kp-cover-preview{
  width:240px;
  max-width:240px;
  height:150px;
  border-radius:14px;
  overflow:hidden;
  border:1px solid var(--border);
  background:var(--hover);
  display:flex;
  align-items:center;
  justify-content:center;
}

.kp-upload-form{
  flex:1;
  min-width:260px;
}

.kp-upload-actions{
  display:flex;
  justify-content:center;
  gap:8px;
  flex-wrap:wrap;
  margin-top:8px;
}

.kp-upload-actions .btn{
  min-width: 140px;
}

.kp-meta-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
  width:100%;
  min-width:0;
}

.kp-meta-grid--full{
  grid-template-columns: 1fr;
}

.kp-field{
  display:flex;
  flex-direction:column;
  gap:4px;
  min-width:0;
}

.kp-field-full{ grid-column: 1 / -1; }

.kp-label{
  font-size:12px;
  color: var(--muted);
  line-height: 1.2;
  font-weight: 700;
}

.kp-help{
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* datetime: нормальная тап-зона */
.kp-datetime-wrap{
  width:100%;
  cursor:pointer;
}

.kp-datetime{
  cursor:pointer;
  max-width:100%;
}

/* ===== Услуги в смете ===== */
.kp-services-head{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.kp-services-title{
  font-size: 18px;
  line-height: 1.15;
  font-weight: 900;
}

.kp-services-sub{
  margin-top: 2px;
  font-size: 15px;
}

.kp-clear-form{
  margin: 0;
}

.kp-services-head .kp-clear-btn{
  width: auto;
  min-width: 180px;
}

.kp-services-list{
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 12px;
}

.kp-service-row{
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: rgba(120, 128, 145, 0.14);
  border: 1px solid rgba(120, 128, 145, 0.28);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(2px);
}

.kp-service-row:hover{
  background: rgba(120, 128, 145, 0.2);
}

.kp-service-title{
  font-size: clamp(20px, 2.2vw, 26px);
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: -0.01em;
  word-break: break-word;
  padding-right: 96px;
}

.kp-service-row .kp-item-photo{
  width: 100%;
  height: 260px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--tile-media-bg);
}

.kp-service-row .kp-item-photo img{
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center;
  display: block;
}

.kp-service-description{
  font-size: 15px;
  line-height: 1.35;
  color: var(--muted);
  min-height: 34px;
  overflow-wrap: anywhere;
}

.kp-row-field{
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--input-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
}

.kp-row-label{
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text);
}

.kp-row-controls{
  margin-left: auto;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.kp-row-value{
  margin-left: auto;
  white-space: nowrap;
  font-size: clamp(20px, 1.85vw, 28px);
  line-height: 1;
  font-weight: 900;
}

.kp-row-field-sum{
  border-color: rgba(124, 58, 237, 0.42);
  box-shadow: inset 0 0 0 2px rgba(124, 58, 237, 0.08);
}

.kp-stepper-inline{
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.kp-stepper-inline .qty-btn{
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 19px;
  line-height: 1;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.kp-stepper-inline .qty-btn:disabled{
  opacity: 0.5;
  cursor: not-allowed;
}

.kp-stepper-inline .qty-value{
  min-width: 20px;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
}

.kp-remove-corner-form{
  position: absolute;
  top: 8px;
  right: 8px;
  margin: 0;
  z-index: 2;
}

.kp-remove-cross{
  width: auto;
  min-width: 0;
  height: 32px;
  border-radius: 10px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.06);
  color: #ef4444;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0 9px;
  white-space: nowrap;
}

.kp-remove-cross:hover{
  background: rgba(239, 68, 68, 0.14);
}

.kp-remove-cross:active{
  transform: scale(0.98);
}

.kp-services-list .kp-price-wrap-inline{
  width: 188px;
  max-width: 100%;
  margin-left: 0;
  display: block;
  position: relative;
}

.kp-services-list .kp-price-wrap-inline .kp-price-input{
  width: 100%;
  height: 34px;
  border-radius: 10px;
  font-size: 16px;
  text-align: right;
  padding-right: 24px;
}

.kp-services-list .kp-price-wrap-inline .kp-currency{
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  line-height: 1;
  pointer-events: none;
}

.kp-services-list .kp-price-readonly{
  width: 188px;
  max-width: 100%;
  margin-left: 0;
  min-height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 10px;
  font-size: 16px;
  font-weight: 900;
}

.kp-total-card .kp-total-row .muted,
.kp-total-card .kp-total-row b,
.kp-total-card .kp-total-row > span{
}

.kp-total-card .kp-total-final{
  color: var(--purple);
}

.kp-total-card .kp-total-final span:last-child{
  color: var(--purple);
  background: none;
  -webkit-text-fill-color: var(--purple);
}

.kp-total-card{
  margin-top: 10px;
  padding: 12px;
  gap: 8px;
}

.kp-total-row{
  gap: 8px;
}

.kp-total-final{
  margin-top: 4px;
  padding-top: 8px;
}

/* Fix overflow for inputs */
.kp-field .search-input,
.kp-field select.search-input,
.kp-field textarea.search-input{
  width:100%;
  max-width:100%;
  box-sizing:border-box;
}

@media (max-width: 980px){
  .kp-services-list{
    grid-template-columns: 1fr;
  }
}

/* ===== Mobile builder ===== */
@media (max-width: 640px){
  .kp-actions{
    flex-wrap: wrap;
  }

  .kp-actions .btn{
    width: 100%;
    flex: 1 1 100%;
  }

  .kp-meta-grid{ grid-template-columns: 1fr; }

  .kp-cover-wrap{
    flex-direction:column;
    align-items:stretch;
  }

  .kp-cover-preview{
    width:100%;
    max-width:100%;
    height:180px;
  }

  .kp-upload-form{
    min-width:0;
    width:100%;
  }

  .kp-upload-actions .btn,
  .kp-center-actions .btn{
    width:100%;
    min-width:0;
  }

  .search-input{
    width:100%;
    min-width:0;
  }

  input[type="datetime-local"].search-input{
    min-height: 48px;
    font-size: 16px;
  }

  .kp-services-head{
    gap: 8px;
  }

  .kp-services-head .kp-clear-btn{
    width: 100%;
    min-width: 0;
  }

  .kp-service-row{
    gap: 6px;
    padding: 10px;
  }

  .kp-service-row .kp-item-photo{
    height: 236px;
    border-radius: 14px;
  }

  .kp-service-title{
    font-size: clamp(24px, 7vw, 32px);
    padding-right: 86px;
  }

  .kp-service-description{
    min-height: 0;
    font-size: 15px;
  }

  .kp-row-field{
    min-height: 40px;
    padding: 6px 8px;
  }

  .kp-row-label{
    font-size: 15px;
  }

  .kp-row-controls{
    gap: 4px;
  }

  .kp-stepper-inline{
    gap: 4px;
  }

  .kp-stepper-inline .qty-btn{
    width: 32px;
    height: 32px;
  }

  .kp-row-value{
    font-size: clamp(19px, 5.4vw, 26px);
  }

  .kp-services-list .kp-price-wrap-inline,
  .kp-services-list .kp-price-readonly{
    width: 146px;
  }

  .kp-services-list .kp-price-wrap-inline .kp-price-input{
    height: 34px;
    font-size: 15px;
  }

  .kp-remove-corner-form{
    top: 6px;
    right: 6px;
  }

  .kp-remove-cross{
    height: 32px;
    font-size: 15px;
    padding: 0 9px;
  }
}
