/* admin/public/style.css */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-sunken: #fafbfc;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #1a1d24;
  --text-muted: #667085;
  --primary: #2f6f5e;
  --primary-hover: #255a4c;
  --primary-soft: #eef5f2;
  --primary-soft-border: #cfe3db;
  --danger: #c0342a;
  --danger-hover: #9c2a21;
  --danger-soft: #fbeceb;
  --danger-soft-border: #f0c9c6;
  --warning-soft: #fef3c7;
  --warning-text: #92400e;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.07), 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, 0.12);
  --focus-ring: 0 0 0 3px rgba(47, 111, 94, 0.25);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* Top navigation bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  white-space: nowrap;
}

.brand__logo { height: 28px; width: auto; display: block; }

.brand__label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tabs {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.tab {
  position: relative;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.tab:hover { color: var(--text); background: var(--bg); }

.tab.is-active {
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.avatar-menu { position: relative; }

.avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.avatar-btn:hover { background: var(--border); color: var(--text); }

.avatar-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 140px;
  padding: 0.35rem;
  animation: dropdown-in 0.12s var(--ease);
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.55rem 0.6rem;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
}
.dropdown-item:hover { background: var(--bg); }

/* Page content */

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 1.25rem;
  letter-spacing: -0.02em;
}

.list-card { padding: 0; overflow: hidden; }

.list-search {
  display: block;
  width: 100%;
  margin: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 0.9rem 1.35rem;
  background: var(--surface-sunken);
}
.list-search:focus { box-shadow: none; border-bottom-color: var(--primary); }

.list-card #member-list,
.list-card #document-list {
  padding: 0.4rem 1.35rem 1.1rem;
}

/* Compact team stats dashboard */

.team-stats h2 { margin-bottom: 1rem; }

.team-stats-grid {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.team-stats-donut {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.team-stats-legend {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.team-stats-legend span { display: flex; align-items: center; gap: 0.4rem; }

.team-stats-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.team-stats-bars {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.stat-bar-row {
  display: grid;
  grid-template-columns: 9rem 1fr 1.5rem;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
}

.stat-bar-label {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-bar-track {
  background: var(--bg);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.stat-bar-fill {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
}

.stat-bar-count {
  text-align: right;
  font-weight: 700;
  color: var(--text);
}

.team-stats-footnote {
  margin: 0.9rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.team-stats-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.8;
}

@media (max-width: 560px) {
  .stat-bar-row { grid-template-columns: 6rem 1fr 1.5rem; }
}

h1 {
  font-size: 1.6rem;
  margin: 0;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 1rem;
  letter-spacing: -0.01em;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.35rem;
  margin: 1rem 0;
}

.empty {
  color: var(--text-muted);
  margin: 0;
  padding: 0.5rem 0;
  font-size: 0.92rem;
}

/* Member list */

.member-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.5rem;
  margin: 0 -0.5rem;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.15s var(--ease);
}

.member-row:hover { background: var(--surface-sunken); }
.member-row:last-child { border-bottom: none; }

.thumb-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.thumb {
  position: absolute;
  top: 0;
  left: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 22%;
  background: #eceff2;
  cursor: pointer;
  transition:
    width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    height 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    border-radius 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.4s ease;
  z-index: 1;
}

.thumb.is-expanded {
  width: 160px;
  height: 200px;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 5;
}

.thumb-empty { visibility: hidden; }

.member-info {
  flex: 1;
  min-width: 0;
  font-size: 0.95rem;
}

.badge-pending {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning-text);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

.badge-hidden {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

/* Unified iOS-style toggle switch — the one on/off control used everywhere
   in the admin (visibility flags, editor preview toggles). Native checkbox
   underneath for accessibility (keyboard, screen readers); everything visual
   is the two spans next to it. */

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
  cursor: pointer;
  user-select: none;
}

.access-control .switch { margin-bottom: 0; margin-left: auto; }

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.switch-track {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 24px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background-color 0.2s var(--ease);
}

.switch-track::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.25);
  transition: transform 0.2s var(--ease);
}

.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::before { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.5; }

.access-control[hidden] { display: none; }

.access-control {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.9rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.access-control-label { font-weight: 600; font-size: 0.88rem; }
.access-control button { margin-left: auto; }
.access-control select {
  font: inherit;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.access-status { font-size: 0.85rem; font-weight: 700; }
.access-status.is-on { color: var(--primary-hover); }
.access-status.is-off { color: var(--text-muted); }

/* Employee contacts / social fields */

.section-divider {
  margin-top: 1.5rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--border);
}
.section-divider h2 { margin-bottom: 0.9rem; }

.contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.contact-field {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.contact-field input { margin: 0; }

.contact-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.contact-icon svg { width: 16px; height: 16px; }

.contact-icon--yandex { background: #fc3f1d; }
.contact-icon--telegram { background: #229ed9; }
.contact-icon--vk { background: #0077ff; font-size: 0.62rem; }
.contact-icon--google { background: #4285f4; }
.contact-icon--linkedin { background: #0a66c2; font-size: 0.68rem; }
.contact-icon--phone { background: var(--primary); }
.contact-icon--email { background: var(--text-muted); }

@media (max-width: 480px) {
  .contacts-grid { grid-template-columns: 1fr; }
}

.member-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Buttons */

button {
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 0.6rem 1.05rem;
  cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.1s var(--ease);
}

button:active { transform: translateY(1px); }

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg); }

.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--border-strong);
}
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger-soft-border); }

/* Form */

textarea, input[type="file"], input[type="text"], input[type="password"], input[type="email"] {
  font: inherit;
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  margin: 0.4rem 0 0.9rem;
  box-sizing: border-box;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

textarea:focus, input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

textarea { resize: vertical; }

.field-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.field { display: flex; flex-direction: column; }

.field__label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.field input[type="text"] { margin: 0; }

.input-with-action { position: relative; display: block; }
.input-with-action input[type="text"] { padding-right: 2.4rem; }
.input-with-action .icon-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
}

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

/* Small icon buttons (e.g. AI-translate trigger next to a field label) */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-hover);
  border: 1px solid var(--primary-soft-border);
}
.icon-btn:hover:not(:disabled) { background: var(--primary-soft-border); }
.icon-btn svg { width: 18px; height: 18px; display: block; }

.translate-btn.is-busy svg { visibility: hidden; }
.translate-btn.is-busy {
  position: relative;
}
.translate-btn.is-busy::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(47, 111, 94, 0.3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.photo-field {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.photo-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 22%;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: outline-color 0.15s var(--ease);
}
.photo-preview:hover { outline: 2px solid var(--primary); outline-offset: 2px; }

.photo-dropzone {
  flex: 1;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.photo-dropzone:hover,
.photo-dropzone:focus-visible {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.photo-dropzone.is-dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.dropzone-link {
  color: var(--primary-hover);
  font-weight: 600;
  text-decoration: underline;
}

/* Full-resolution photo editor modal */

.editor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 20, 24, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  animation: overlay-in 0.15s var(--ease);
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.editor-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  gap: 1.25rem;
  padding: 1.25rem;
  max-width: 920px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  animation: modal-in 0.18s var(--ease);
}

.creds-modal, .profile-modal {
  display: block;
  max-width: 380px;
}
.creds-modal input[readonly] { font-family: ui-monospace, monospace; background: var(--surface-sunken); }

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.97) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.editor-canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: var(--radius-sm);
  min-height: 320px;
}

.editor-canvas { max-width: 100%; max-height: 640px; border-radius: 4px; }

.editor-controls {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.editor-controls label {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.editor-row { display: flex; gap: 0.5rem; }
.editor-row button { flex: 1; }

.editor-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0.25rem 0;
}

.editor-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.5rem;
}
.editor-actions .btn-primary { flex: 1; }

.form-actions {
  display: flex;
  gap: 0.5rem;
}

.form-actions button { flex: 0 0 auto; }
.form-actions .btn-primary { flex: 1; }

/* Status banner (sits between the member list and the form) */

.status-banner {
  border-left: 3px solid var(--border);
  animation: banner-in 0.18s var(--ease);
}

@keyframes banner-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.status-progress {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--primary-soft);
  border-color: var(--border);
  border-left-color: var(--primary);
  color: var(--primary-hover);
  font-weight: 500;
}

.status-error { background: var(--danger-soft); border-left-color: var(--danger); color: var(--danger-hover); }

.status-ready { border-left-color: var(--primary); }
.status-ready h3 { margin-top: 0; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(47, 111, 94, 0.25);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error { color: var(--danger-hover); margin: 0; font-size: 0.92rem; }

/* Preview */

img.preview {
  max-width: 220px;
  border-radius: var(--radius);
  display: block;
  margin: 0.75rem 0;
  box-shadow: var(--shadow);
}

.preview-name { font-size: 1.05rem; }

.translation-block {
  border-left: 3px solid var(--border);
  padding-left: 0.75rem;
  margin: 0.75rem 0;
  color: var(--text-muted);
}

.translation-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 0.25rem;
  color: var(--text-muted);
}

.preview-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* Live site preview (real page, real styles, in an iframe) */

.site-preview {
  margin-top: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.site-preview-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.lang-tab {
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.lang-tab.is-active {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.site-preview-frame {
  width: 100%;
  height: 560px;
  border: none;
  display: block;
}

.preview-modal {
  display: block;
  max-width: 720px;
  padding: 0;
  overflow: hidden;
}
.preview-modal .site-preview { margin: 0; border: none; border-radius: 0; }
.preview-modal .site-preview-tabs { align-items: center; }
.preview-modal .preview-close { margin-left: auto; padding: 0.3rem 0.8rem; }
.preview-frame { height: 78vh; }

/* Login */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 340px;
  margin: 1.25rem;
  padding: 2rem 1.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-logo { height: 40px; width: auto; margin-bottom: 1rem; }

.login-title {
  font-size: 1.2rem;
  margin: 0 0 1.25rem;
  align-self: center;
}

.login-card .field { width: 100%; }
.login-card .btn-primary { width: 100%; margin-top: 0.4rem; }
.login-card .error:not(:empty) { margin-top: 0.75rem; }
