/* ── iOS-style Design System ── */

:root {
  /* точные iOS 17 dark mode системные цвета */
  --bg:           #000000;
  --bg-secondary: #1c1c1e;
  --bg-tertiary:  #2c2c2e;
  --bg-elevated:  #3a3a3c;

  --label:        #ffffff;
  --label-2:      rgba(235,235,245,0.60);
  --label-3:      rgba(235,235,245,0.30);
  --label-4:      rgba(235,235,245,0.18);

  --separator:    rgba(84,84,88,0.65);
  --fill:         rgba(120,120,128,0.20);
  --fill-2:       rgba(120,120,128,0.32);

  --accent:       #bf5af2;
  --accent-soft:  rgba(191,90,242,0.16);
  --blue:         #0a84ff;
  --green:        #30d158;
  --green-soft:   rgba(48,209,88,0.16);
  --orange:       #ff9f0a;
  --orange-soft:  rgba(255,159,10,0.16);
  --red:          #ff453a;
  --red-soft:     rgba(255,69,58,0.16);

  --radius-sm:    10px;
  --radius-md:    14px;
  --radius-lg:    20px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--label);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(0,0,0,0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
  padding: 0 20px;
  padding-top: env(safe-area-inset-top);
  height: calc(52px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo { height: 30px; width: auto; border-radius: 7px; }

.site-header h1 {
  font-size: 17px;
  font-weight: 600;
  color: var(--label);
  letter-spacing: -0.3px;
}

.header-actions { display: flex; gap: 8px; align-items: center; }

.header-btn {
  background: var(--fill);
  border: none;
  color: var(--accent);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 980px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.header-btn:hover  { background: var(--accent-soft); transform: none; }
.header-btn:active { opacity: 0.7; transform: none; }

.header-btn--logout { color: var(--label-2); }
.header-btn--logout:hover { background: var(--fill); color: var(--label); }

/* ── Container ── */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 100px;
}

/* ── Section titles ── */
h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--label);
  margin-bottom: 14px;
}

h3 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--label);
  margin-bottom: 14px;
}

h4 {
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--label-2);
  margin: 16px 0 8px;
}

/* ── Forms ── */
form { margin-top: 0; }

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--bg-tertiary);
  border: 0.5px solid var(--separator);
  border-radius: var(--radius-sm);
  color: var(--label);
  font-family: var(--font);
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder, textarea::placeholder { color: var(--label-3); }

select option { background: var(--bg-secondary); }

/* ── Buttons ── */
button {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  background: var(--accent);
  color: #fff;
}

button:hover  { opacity: 0.88; transform: none; }
button:active { opacity: 0.72; transform: scale(0.98); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Add Order card ── */
#new-order {
  background: var(--bg-secondary);
  border: 0.5px solid var(--separator);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 28px;
}

/* ── Order card ── */
.order {
  background: var(--bg-secondary);
  border: 0.5px solid var(--separator);
  border-radius: var(--radius-lg);
  padding: 16px 16px 16px 22px;
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
  transition: transform 0.12s;
}

.order:active { transform: scale(0.997); }

/* Статус — аккуратная полоска через псевдоэлемент */
.order::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.order--waiting::before { background: var(--orange); box-shadow: 0 0 8px var(--orange-soft); }
.order--done::before    { background: var(--green);  box-shadow: 0 0 8px var(--green-soft); }

/* Статус — через badge, без отдельной строки */
.order-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.order-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--label);
  line-height: 1.3;
  flex: 1;
}

.order-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.status-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 9px;
  border-radius: 980px;
  margin-top: 2px;
}

.status-badge--waiting {
  background: var(--orange-soft);
  color: var(--orange);
}

.status-badge--done {
  background: var(--green-soft);
  color: var(--green);
}

.order > p {
  font-size: 14px;
  color: var(--label-2);
  margin-bottom: 12px;
  line-height: 1.45;
}

.status-label {
  font-size: 13px;
  color: var(--label-2);
  margin-bottom: 10px;
}

/* Reply */
.reply {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  position: relative;
}

.reply__author {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}

.reply__text {
  font-size: 15px;
  color: var(--label);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

/* Add reply button */
.addReplyBtn {
  margin-top: 10px;
  background: var(--fill);
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 980px;
  border: 0.5px solid var(--accent-soft);
}

.addReplyBtn:hover { background: var(--accent-soft); opacity: 1; }

/* Delete buttons */
.order__delete {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--fill);
  color: var(--label-3);
  font-size: 16px;
  display: grid; place-items: center;
  padding: 0;
  border: none;
  flex-shrink: 0;
  line-height: 1;
}

.order__delete:hover { background: var(--red-soft); color: var(--red); opacity: 1; }

/* Status toggle — тапабельный badge */
.status-toggle {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 4px 10px;
  border-radius: 980px;
  border: none;
  cursor: pointer;
}

.status-toggle--waiting {
  background: var(--orange-soft);
  color: var(--orange);
}

.status-toggle--done {
  background: var(--green-soft);
  color: var(--green);
}

.status-toggle:hover { opacity: 0.8; transform: none; }
.status-toggle:active { transform: scale(0.95); opacity: 0.7; }

.reply__delete {
  position: absolute;
  top: 8px; right: 8px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: transparent;
  color: var(--label-3);
  font-size: 14px;
  display: grid; place-items: center;
  padding: 0;
  border: none;
  line-height: 1;
}

.reply__delete:hover { background: var(--red); color: #fff; opacity: 1; }

.order__customer {
  display: block;
  font-size: 12px;
  color: var(--label-secondary);
  margin: -6px 0 6px;
  padding-left: 2px;
}

.order__date {
  position: absolute;
  bottom: 12px;
  right: 16px;
  font-size: 11px;
  color: var(--label-3);
}

.reply__date {
  display: block;
  font-size: 11px;
  color: var(--label-3);
  margin-top: 4px;
}

/* ── Carousel ── */
.carousel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.carousel::-webkit-scrollbar { display: none; }

.carousel__img {
  height: 110px;
  width: auto;
  border-radius: var(--radius-sm);
  flex: 0 0 auto;
  cursor: zoom-in;
  opacity: 0.5;
  transition: opacity 0.2s;
  object-fit: cover;
}

.carousel__img.loaded { opacity: 1; }

/* ── Lightbox ── */
.lightbox {
  position: fixed; inset: 0;
  background: #000;
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 9999;
  touch-action: none;
  user-select: none;
}

.lightbox.is-open { display: flex; }

.lightbox__bar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: env(safe-area-inset-top, 12px) 8px 12px;
  padding-top: max(env(safe-area-inset-top, 0px), 12px);
  background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 100%);
  z-index: 1;
}

.lightbox__close {
  width: 40px; height: 40px;
  color: #fff; border-radius: 50%;
  font-size: 24px; display: grid; place-items: center; padding: 0;
  background: rgba(255,255,255,0.15);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.lightbox__counter {
  color: rgba(255,255,255,0.8);
  font-size: 14px; font-weight: 500;
}

.lightbox__save {
  width: 40px; height: 40px;
  color: #fff; border-radius: 50%;
  font-size: 20px; display: grid; place-items: center;
  background: rgba(255,255,255,0.15);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  text-decoration: none;
  cursor: pointer;
}

.lightbox__img {
  max-width: 90vw; max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}

@keyframes lb-in-right {
  from { opacity: 0; transform: translateX(48px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes lb-in-left {
  from { opacity: 0; transform: translateX(-48px); }
  to   { opacity: 1; transform: translateX(0); }
}
.lightbox__img.anim-next { animation: lb-in-right 0.22s ease; }
.lightbox__img.anim-prev { animation: lb-in-left  0.22s ease; }

@media (max-width: 768px) {
  .lightbox__img {
    max-width: 100vw; max-height: 100vh;
    border-radius: 0; box-shadow: none;
  }
}

.lightbox__prev,
.lightbox__next {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px;
  background: rgba(60,60,60,0.8);
  color: #fff; border-radius: 50%;
  font-size: 22px; display: grid; place-items: center; padding: 0;
}

.lightbox__prev { left: 16px; }
.lightbox__next { right: 16px; }

.lightbox__close:hover,
.lightbox__prev:hover,
.lightbox__next:hover { background: rgba(100,100,100,0.9); }

@media (max-width: 768px) {
  .lightbox__prev,
  .lightbox__next { display: none; }
}

/* ── Role picker ── */
.role-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.role-picker button {
  padding: 10px 0;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--label-secondary);
  font-size: 14px; font-weight: 500;
  border: 1.5px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  opacity: 1;
}
.role-picker button:hover { opacity: 1; background: var(--bg-tertiary); }
.role-picker button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.role-picker button.active:hover { opacity: 0.88; background: var(--accent); }

/* ── Modal base ── */
.replyModal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: none; align-items: flex-end; justify-content: center;
  z-index: 9999;
}

.replyModal.is-open { display: flex; }

.replyModal__content {
  background: var(--bg-secondary);
  border: 0.5px solid var(--separator);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 8px 20px 36px;
  width: 100%;
  max-width: 560px;
  position: relative;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.4);
  animation: slide-up 0.28s cubic-bezier(0.32,0.72,0,1);
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* Drag handle */
.replyModal__content::before {
  content: "";
  display: block;
  width: 36px; height: 5px;
  background: var(--bg-elevated);
  border-radius: 3px;
  margin: 10px auto 20px;
}

.replyModal__close {
  position: absolute; top: 18px; right: 16px;
  width: 30px; height: 30px;
  background: var(--fill);
  color: var(--label-2);
  border-radius: 50%; border: none;
  font-size: 16px; display: grid; place-items: center; padding: 0;
}

.replyModal__close:hover { background: var(--bg-elevated); color: var(--label); opacity: 1; }

/* ── Users modal ── */
.usersModal__content {
  max-width: 560px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-height: 85vh;
  overflow-y: auto;
}

.users-list { display: flex; flex-direction: column; gap: 2px; }

.user-row-wrap {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.user-row-wrap + .user-row-wrap { margin-top: 2px; }

.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
}

.user-row__name { flex: 1; font-size: 15px; font-weight: 500; }

.user-row__role {
  font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 980px;
  text-transform: uppercase; letter-spacing: 0.4px;
}

.role--admin    { background: rgba(191,90,242,0.2); color: var(--accent); }
.role--supplier { background: rgba(10,132,255,0.2); color: var(--blue); }
.role--customer { background: rgba(48,209,88,0.2);  color: var(--green); }

.user-row__edit {
  background: var(--fill); border: none;
  color: var(--label-2); font-size: 12px; font-weight: 500;
  padding: 5px 10px; border-radius: 980px;
}

.user-row__edit:hover { background: var(--bg-elevated); color: var(--label); opacity: 1; }

.user-row__delete {
  background: transparent; border: none;
  color: var(--label-3);
  width: 28px; height: 28px;
  border-radius: 50%; font-size: 18px;
  display: grid; place-items: center; padding: 0; flex-shrink: 0;
}

.user-row__delete:hover { background: rgba(255,69,58,0.15); color: var(--red); opacity: 1; }

.user-row__pwd-form {
  display: none; flex-direction: column; gap: 8px;
  padding: 0 14px 12px;
}

.user-row__pwd-form.visible { display: flex; }

.user-row__pwd-form input { margin: 0; font-size: 14px; padding: 9px 12px; }

.user-row__pwd-form button {
  align-self: flex-start; padding: 8px 16px;
  font-size: 13px; border-radius: 980px;
}

/* ── Login ── */
.login-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}

.login-overlay.hidden { display: none; }

.login-form {
  background: var(--bg-secondary);
  border: 0.5px solid var(--separator);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  width: 100%; max-width: 340px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}

.login-header { text-align: center; margin-bottom: 4px; }
.login-logo { width: 200px; max-width: 100%; height: auto; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

.login-form label {
  font-size: 13px; font-weight: 500;
  color: var(--label-2); margin-left: 2px;
}

.login-form input { margin-bottom: 0; }

.login-btn {
  margin-top: 4px;
  background: var(--accent); color: #fff;
  font-size: 16px; font-weight: 600;
  padding: 14px; border-radius: var(--radius-sm);
}

.login-error {
  color: var(--red); font-size: 13px;
  text-align: center; display: none;
}

/* ── Pagination ── */
.pagination {
  display: flex; justify-content: center; align-items: center;
  gap: 6px; padding: 20px 0; flex-wrap: wrap;
}

.pagination__btn {
  min-width: 36px; height: 36px; padding: 0 10px;
  background: var(--fill);
  color: var(--label-2);
  border: none; border-radius: 980px;
  font-size: 14px; font-weight: 500;
}

.pagination__btn:hover  { background: var(--bg-elevated); color: var(--label); opacity: 1; }
.pagination__btn--active { background: var(--accent); color: #fff; }
.pagination__btn--active:hover { background: var(--accent); }
.pagination__dots { color: var(--label-3); font-size: 14px; }

/* ── Mobile ── */
@media (max-width: 600px) {
  .site-header { padding: 0 16px; }
  .site-header h1 { font-size: 16px; }

  .container { padding: 16px 12px 100px; }

  .order { padding: 14px 14px 14px 20px; border-radius: var(--radius-md); }
  .order-title { font-size: 15px; }
  .order > p { font-size: 15px; }
  .reply__text { font-size: 15px; }

  #new-order { border-radius: var(--radius-md); }

  .carousel__img { height: 90px; }

  .replyModal__content { padding: 8px 16px 40px; }

  .login-form { padding: 28px 20px; margin: 0 12px; }

  .header-btn { font-size: 13px; padding: 5px 11px; }
}

/* ── Reply form ── */
.replyForm {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.replyForm textarea { margin-bottom: 0; }

/* Custom file upload zone */
.file-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 20px 16px;
  background: var(--fill);
  border: 1.5px dashed rgba(120,120,128,0.4);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--label-2);
  text-align: center;
}

.file-drop:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.file-drop.has-files { border-color: var(--accent); border-style: solid; background: var(--accent-soft); color: var(--accent); }
.file-drop.drag-over { border-color: var(--accent); border-style: solid; background: var(--accent-soft); color: var(--accent); transform: scale(1.01); }

.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  margin: 0; padding: 0;
  border: none; background: none; box-shadow: none;
}

.file-drop svg { color: inherit; margin-bottom: 2px; }
.file-drop__label { font-size: 15px; font-weight: 500; }
.file-drop__hint { font-size: 12px; color: var(--label-3); }
.file-drop.has-files .file-drop__hint { color: inherit; font-weight: 600; }

.reply-submit {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  border-radius: var(--radius-md);
}
