/* ═══════════════════════════════════════════════════════════════
   TF Calc — Admin UI
   Palette mirrors v2team.ru public site design language
   ═══════════════════════════════════════════════════════════════ */

/* ── Tokens ───────────────────────────────────────────────────── */
:root {
  /* Light surface — same as public site light variant */
  --bg:          #F5F4F2;
  --bg-2:        #EEECEA;
  --bg-3:        #E6E4E0;
  --surface:     #FFFFFF;
  --ink:         #1A1918;
  --ink-2:       #2E2C2A;
  --muted:       #7A7874;
  --border:      #D8D5D0;
  --border-2:    #C8C5C0;

  /* Brand accent (public site red) */
  --red:         #B6281E;
  --red-h:       #C72E24;
  --red-dim:     rgba(182, 40, 30, .08);
  --red-dim-2:   rgba(182, 40, 30, .15);

  /* Sidebar — same dark as public site dark variant */
  --sb-bg:       #0C0C0E;
  --sb-bg-2:     #131417;
  --sb-border:   #252529;
  --sb-text:     #9A9AA4;
  --sb-muted:    #4E4E58;
  --sb-width:    224px;

  /* Gold — active state in sidebar (public dark site accent) */
  --gold:        #C4963A;
  --gold-dim:    rgba(196, 150, 58, .12);

  /* Shape */
  --radius:      3px;
  --radius-md:   5px;
  --radius-lg:   8px;
  --t:           .18s ease;
}

/* ── Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body.tf-body {
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  margin: 0;
}

/* ── Shell ────────────────────────────────────────────────────── */
.tf-shell {
  display: flex;
  min-height: 100vh;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════ */

.tf-sidebar {
  width: var(--sb-width);
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.tf-sidebar::-webkit-scrollbar { display: none; }

/* Brand */
.tf-brand {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.tf-brand-link {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  text-decoration: none;
}
.tf-brand-name {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: .03em;
  color: #FFFFFF;
  line-height: 1.1;
}
.tf-brand-crm {
  font-family: 'JetBrains Mono', monospace;
  font-size: .62rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold);
}

/* CTA button */
.tf-sidebar-cta {
  padding: 14px 16px 6px;
  flex-shrink: 0;
}
.tf-btn-new {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  width: 100%;
  padding: .65em 1em;
  background: var(--red);
  color: #fff;
  border-radius: var(--radius);
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  font-size: .8rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background var(--t);
}
.tf-btn-new:hover { background: var(--red-h); color: #fff; }

/* Nav */
.tf-nav {
  flex: 1;
  padding: 10px 0 6px;
  display: flex;
  flex-direction: column;
}
.tf-nav-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: .58rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--sb-muted);
  padding: 14px 20px 5px;
  display: block;
  flex-shrink: 0;
}
.tf-nav-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .52em 20px;
  color: var(--sb-text);
  text-decoration: none;
  font-size: .82rem;
  font-weight: 500;
  border-left: 2px solid transparent;
  transition: color var(--t), background var(--t), border-color var(--t);
}
.tf-nav-link i {
  width: 15px;
  text-align: center;
  font-size: .82rem;
  color: var(--sb-muted);
  flex-shrink: 0;
  transition: color var(--t);
}
.tf-nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,.04);
}
.tf-nav-link:hover i { color: var(--sb-text); }
.tf-nav-link.active {
  color: #fff;
  background: var(--gold-dim);
  border-left-color: var(--gold);
}
.tf-nav-link.active i { color: var(--gold); }

/* Sidebar footer */
.tf-sidebar-foot {
  padding: 14px 16px;
  border-top: 1px solid var(--sb-border);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

/* Wheel decoration — concentric circles referencing the brand motif */
.tf-wheel-deco {
  position: absolute;
  right: -52px;
  bottom: -52px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 1px solid rgba(196,150,58,.07);
  pointer-events: none;
}
.tf-wheel-deco::before {
  content: '';
  position: absolute;
  inset: 15%;
  border-radius: 50%;
  border: 1px solid rgba(196,150,58,.05);
}
.tf-wheel-deco::after {
  content: '';
  position: absolute;
  inset: 34%;
  border-radius: 50%;
  border: 1px solid rgba(196,150,58,.04);
}

.tf-user-block {
  display: flex;
  align-items: center;
  gap: .6rem;
  position: relative;
  z-index: 1;
}
.tf-user-av {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(196,150,58,.18);
  border: 1px solid rgba(196,150,58,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Oswald', sans-serif;
  font-size: .82rem;
  font-weight: 700;
  color: var(--gold);
  flex-shrink: 0;
}
.tf-user-info { min-width: 0; flex: 1; }
.tf-user-name {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.tf-user-role {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: .58rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--sb-muted);
  margin-top: 2px;
}
.tf-logout-btn {
  color: var(--sb-muted);
  text-decoration: none;
  font-size: .85rem;
  padding: .3rem;
  border-radius: var(--radius);
  transition: color var(--t);
  flex-shrink: 0;
}
.tf-logout-btn:hover { color: var(--red); }

/* ═══════════════════════════════════════════════════════════════
   MAIN AREA
   ═══════════════════════════════════════════════════════════════ */

.tf-main {
  margin-left: var(--sb-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Mobile topbar (hidden on desktop) */
.tf-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 150;
  height: 50px;
  background: var(--sb-bg);
  border-bottom: 1px solid var(--sb-border);
  align-items: center;
  padding: 0 14px;
  gap: 12px;
  flex-shrink: 0;
}
.tf-topbar-brand {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: .07em;
  color: #fff;
  text-decoration: none;
  flex: 1;
}
.tf-topbar-brand em {
  font-family: 'JetBrains Mono', monospace;
  font-style: normal;
  font-size: .55rem;
  letter-spacing: .2em;
  color: var(--gold);
  vertical-align: middle;
  margin-left: 5px;
}
.tf-topbar-new {
  color: var(--gold);
  font-size: 1rem;
  padding: .3rem .5rem;
  text-decoration: none;
}

/* Burger */
.tf-burger {
  background: none;
  border: none;
  cursor: pointer;
  padding: .4rem;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tf-burger span {
  display: block;
  width: 20px;
  height: 1.5px;
  background: #fff;
  border-radius: 1px;
  transition: transform var(--t), opacity var(--t);
  transform-origin: center;
}
.tf-burger.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.tf-burger.open span:nth-child(2) { opacity: 0; }
.tf-burger.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* Content area */
.tf-content {
  padding: 22px 26px;
  flex: 1;
}

/* Overlay */
.tf-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 180;
  backdrop-filter: blur(2px);
}
.tf-overlay.show { display: block; }

/* ═══════════════════════════════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════════════════════════════ */

h4, h5 {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink);
}

/* ═══════════════════════════════════════════════════════════════
   BOOTSTRAP COMPONENT OVERRIDES
   ═══════════════════════════════════════════════════════════════ */

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.card-header {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: .62rem 1rem;
  font-size: .83rem;
  font-weight: 600;
}
.card-footer {
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  padding: .62rem 1rem;
  font-size: .8rem;
}
.card-body { padding: 1rem; }

/* ── Tables ─────────────────────────────────────────────────── */
.table {
  font-size: .82rem;
  color: var(--ink);
  margin-bottom: 0;
}
.table-responsive {
  max-height: 78vh;
  overflow-y: auto;
}

/* Dark branded header with gold underline */
.table thead th,
.table thead.table-dark th {
  background: var(--sb-bg) !important;
  color: rgba(255,255,255,.65) !important;
  border-color: var(--sb-border) !important;
  border-bottom: 2px solid var(--gold) !important;
  font-family: 'JetBrains Mono', monospace;
  font-size: .63rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 500;
  padding: .58rem .75rem;
  white-space: nowrap;
}

/* Sticky header */
.orders-table thead { position: sticky; top: 0; z-index: 2; }

.table tbody td {
  vertical-align: middle;
  border-bottom: 1px solid var(--bg-3);
  padding: .55rem .75rem;
}
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover td {
  background: var(--red-dim) !important;
}

/* Row status colors — warmer, on-brand */
.table-warning { --bs-table-bg: #FFF7E3; --bs-table-border-color: #F0E0B0; }
.table-success  { --bs-table-bg: #F0F8F3; --bs-table-border-color: #B8DEC8; }
.table-secondary { --bs-table-bg: var(--bg-2); --bs-table-border-color: var(--border); color: var(--muted) !important; }

/* Order number — mono */
.orders-table td:first-child .fw-bold,
.orders-table td:first-child a {
  font-family: 'JetBrains Mono', monospace;
  font-size: .84rem;
  color: var(--ink);
  text-decoration: none;
}
.orders-table td:first-child a:hover { color: var(--red); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  font-size: .8rem;
  border-radius: var(--radius);
  font-weight: 500;
  letter-spacing: .02em;
  transition: background var(--t), border-color var(--t), color var(--t), transform var(--t);
}

.btn-primary { background: var(--red); border-color: var(--red); }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  background: var(--red-h) !important; border-color: var(--red-h) !important;
}

.btn-outline-primary { color: var(--red); border-color: var(--red); }
.btn-outline-primary:hover, .btn-outline-primary:active {
  background: var(--red); border-color: var(--red); color: #fff;
}

.btn-success { background: #2D7A4F; border-color: #2D7A4F; }
.btn-success:hover { background: #246540; border-color: #246540; }
.btn-outline-success { color: #2D7A4F; border-color: #2D7A4F; }
.btn-outline-success:hover { background: #2D7A4F; border-color: #2D7A4F; color: #fff; }

.btn-danger { background: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red-h); border-color: var(--red-h); }
.btn-outline-danger { color: var(--red); border-color: var(--red); }
.btn-outline-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }

.btn-outline-secondary { color: var(--muted); border-color: var(--border-2); }
.btn-outline-secondary:hover { background: var(--bg-3); color: var(--ink); border-color: var(--border-2); }

/* Compact variant (icon actions in table) */
.btn-xs {
  padding: .18rem .48rem;
  font-size: .72rem;
  border-radius: var(--radius);
  line-height: 1.4;
}

/* ── Badges / Status ────────────────────────────────────────── */
.badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: .64rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  border-radius: 2px;
  font-weight: 500;
  padding: .3em .55em;
}
.badge.bg-secondary { background: var(--bg-3) !important; color: var(--muted) !important; }
.badge.bg-dark      { background: var(--ink)  !important; }
.badge.bg-danger    { background: var(--red)  !important; }
.badge.bg-success   { background: #2D7A4F     !important; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-label {
  font-size: .76rem;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: .02em;
  margin-bottom: .3rem;
}
.form-control, .form-select {
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  font-size: .83rem;
  color: var(--ink);
  background: var(--surface);
  padding: .4rem .65rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 .18rem var(--red-dim-2);
  outline: none;
}
.form-control-plaintext {
  font-size: .85rem;
  padding: .4rem 0;
}
.form-control-sm, .form-select-sm {
  font-size: .78rem;
  padding: .3rem .55rem;
}

/* ── Dropdowns ──────────────────────────────────────────────── */
.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 20px rgba(0,0,0,.1);
  font-size: .82rem;
  padding: .3rem;
}
.dropdown-item {
  border-radius: var(--radius);
  padding: .42rem .75rem;
  color: var(--ink-2);
  transition: background var(--t), color var(--t);
}
.dropdown-item:hover, .dropdown-item:focus {
  background: var(--red-dim);
  color: var(--red);
}
.dropdown-item.text-danger { color: var(--red) !important; }
.dropdown-divider { border-color: var(--border); margin: .3rem 0; }

/* ── Modals ─────────────────────────────────────────────────── */
.modal-content {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0,0,0,.15);
}
.modal-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: .85rem 1.1rem;
}
.modal-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: .75rem 1.1rem;
}
.modal-body { padding: 1.1rem; }

/* ── Alerts (flash messages) ────────────────────────────────── */
.alert {
  border-radius: var(--radius-md);
  font-size: .83rem;
  border-width: 1px;
  padding: .7rem 1rem;
}
.alert-success {
  background: #EEF8F2;
  border-color: #B0D8BF;
  color: #1C5E36;
}
.alert-danger {
  background: #FEF2F2;
  border-color: #F5C6C6;
  color: #8B1A1A;
}
.alert-warning {
  background: #FFFBEB;
  border-color: #F5E0A0;
  color: #7C5E10;
}
.alert-info {
  background: #EFF6FF;
  border-color: #BAD4F5;
  color: #1D4E8A;
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination { gap: 2px; }
.page-link {
  border: 1px solid var(--border);
  border-radius: var(--radius) !important;
  color: var(--muted);
  font-size: .75rem;
  padding: .28rem .58rem;
  background: var(--surface);
  transition: background var(--t), color var(--t), border-color var(--t);
}
.page-item.active .page-link {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.page-link:hover {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}
.page-item.disabled .page-link { opacity: .45; pointer-events: none; }

/* ── Nav tabs (clients page) ────────────────────────────────── */
.nav-tabs {
  border-bottom: 2px solid var(--border);
  gap: .15rem;
}
.nav-tabs .nav-link {
  color: var(--muted);
  border: none;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: .8rem;
  font-weight: 500;
  padding: .45rem .85rem;
  transition: color var(--t), background var(--t);
}
.nav-tabs .nav-link:hover { color: var(--ink); background: var(--bg-2); }
.nav-tabs .nav-link.active {
  color: var(--red);
  background: var(--surface);
  border-bottom: 2px solid var(--red);
  margin-bottom: -2px;
  font-weight: 600;
}

/* ── Progress bars ──────────────────────────────────────────── */
.progress {
  background: var(--bg-3);
  border-radius: var(--radius);
  height: 6px;
}
.progress-bar { border-radius: var(--radius); }

/* ── Tooltips ───────────────────────────────────────────────── */
.tooltip-inner {
  font-size: .75rem;
  font-family: 'JetBrains Mono', monospace;
  border-radius: var(--radius);
}

/* ── Collapse (accordion in order view) ────────────────────── */
.accordion-button {
  font-size: .83rem;
  font-weight: 600;
  background: var(--bg-2);
  color: var(--ink);
}
.accordion-button:not(.collapsed) {
  background: var(--bg-2);
  color: var(--red);
  box-shadow: inset 0 -1px 0 var(--border);
}
.accordion-button::after {
  filter: none;
}
.accordion-button:focus { box-shadow: 0 0 0 .18rem var(--red-dim-2); }
.accordion-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md) !important;
  overflow: hidden;
}
.accordion-body { font-size: .82rem; background: var(--surface); }

/* ═══════════════════════════════════════════════════════════════
   PAGE-SPECIFIC
   ═══════════════════════════════════════════════════════════════ */

/* ── Service blocks (order edit) ────────────────────────────── */
.svc-block {
  background: var(--bg-2);
  border-radius: var(--radius-md);
  transition: background var(--t), border-color var(--t);
}
.svc-block:has(.svc-toggle:checked) {
  background: var(--surface);
  border-color: var(--red) !important;
}

/* ── Price fields (order edit) ──────────────────────────────── */
#price_total, #price_final {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 1rem;
}
#price_final { color: var(--red); }

/* ── Client suggestions dropdown ────────────────────────────── */
#client-suggestions {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(0,0,0,.1);
  z-index: 1000;
}

/* ── Status badge colors (used in order view / list) ─────────── */

/* ── Order sidebar sticky (order view) ──────────────────────── */
@media (min-width: 992px) {
  .order-sidebar {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
  }
}

/* ── Mono data class (prices, numbers, dates) ───────────────── */
.text-mono { font-family: 'JetBrains Mono', monospace; }

/* Small secondary text */
.text-muted { color: var(--muted) !important; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE / MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 991px) {
  .tf-sidebar {
    transform: translateX(-100%);
    transition: transform .24s ease;
  }
  .tf-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.35);
  }
  .tf-topbar { display: flex; }
  .tf-main   { margin-left: 0; }
  .tf-content { padding: 14px 16px; }

  /* iOS/Android auto-zoom on focus when an input's font is under 16px — applies
     everywhere, including the login page (shares this stylesheet). Bootstrap's
     .form-control-sm/-lg set their own smaller/larger sizes, so this needs !important
     to win consistently across the whole app on mobile. */
  input, select, textarea,
  .form-control, .form-select {
    font-size: 16px !important;
  }
}

@media (max-width: 575px) {
  .tf-content { padding: 12px; }
}

/* ═══════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════ */

@media print {
  .tf-sidebar, .tf-topbar, .no-print, .btn, .pagination { display: none !important; }
  .tf-main { margin-left: 0; }
  .tf-content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ═══════════════════════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; }
}
