/* Общие стили UIService (без сборщика) */

:root {
  --primary-color:  #222D52;
  --success-color:  #10b981;
  --danger-color:   #ef4444;
  --warning-color:  #D2B68A;
  --info-color:     #222D52;
  --dark-color:     #000000;
  --light-color:    #EEE5D9;
  --border-color:   #EEE5D9;
  /* Variant-B aliases */
  --navy:  #222D52;
  --gold:  #D2B68A;
  --cream: #EEE5D9;
  --white: #FDFFFF;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background-color: var(--white);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--dark-color);
}

/* Скрываем страницу до инициализации Keycloak */
body:not(.keycloak-initialized) {
  visibility: hidden;
  opacity: 0;
}
body.keycloak-initialized {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.3s ease-in;
}

/* ── TOPBAR / HEADER ─────────────────────────────── */
.main-header {
  background: var(--navy);
  color: var(--white);
  padding: 0;
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 12px rgba(34, 45, 82, .3);
}

.main-header > .container-fluid {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  padding: 0 1.5rem;
}

/* Brand */
.main-header .header-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1rem 0.75rem 0;
  border-right: 1px solid rgba(255, 255, 255, .1);
  margin-right: 0.5rem;
  text-decoration: none;
  flex-shrink: 0;
}
.main-header .brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
}
.main-header .brand-text {
  color: var(--white);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: .01em;
}

/* Nav */
.main-header .flex-grow-1 {
  display: flex;
  align-items: stretch;
}

.main-header .nav-tabs {
  border-bottom: none;
  display: flex;
  align-items: stretch;
  flex: 1;
  flex-wrap: nowrap;
}

.main-header .nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
  color: rgba(255, 255, 255, .65) !important;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  border: none !important;
  border-bottom: 3px solid transparent !important;
  border-radius: 0 !important;
  transition: all .15s;
  white-space: nowrap;
  background: transparent;
}
.main-header .nav-link:hover {
  color: var(--white) !important;
  background: rgba(255, 255, 255, .06);
}
.main-header .nav-link.active {
  color: var(--white) !important;
  background: transparent;
  border-bottom-color: var(--gold) !important;
  font-weight: 700;
  opacity: 1;
}
.main-header .nav-link i {
  font-size: 0.8rem;
}

/* Issue button in topbar */
.btn-header-issue {
  background: transparent;
  color: rgba(255, 255, 255, .7);
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 8px;
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-header-issue:hover {
  color: var(--white);
  border-color: rgba(255, 255, 255, .6);
  background: rgba(255, 255, 255, .06);
}

/* User info dropdown injected by keycloak-init.js */
#user-info {
  flex-shrink: 0;
  padding: 0.5rem 0;
}
#user-info .btn-outline-primary {
  background: transparent !important;
  color: rgba(255, 255, 255, .75) !important;
  border-color: rgba(255, 255, 255, .3) !important;
  border-radius: 8px !important;
  font-size: 0.82rem !important;
  padding: 0.35rem 0.8rem !important;
}
#user-info .btn-outline-primary:hover,
#user-info .btn-outline-primary:focus,
#user-info .btn-outline-primary.show {
  background: rgba(255, 255, 255, .1) !important;
  color: var(--white) !important;
  border-color: rgba(255, 255, 255, .5) !important;
  box-shadow: none !important;
}

/* ── PAGE BODY PADDING ────────────────────────────── */
.container-fluid {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

/* ── FILTERS SECTION ─────────────────────────────── */
.filters-section {
  background: var(--cream);
  border-radius: 10px;
  border-left: 4px solid var(--gold);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  box-shadow: none;
  border-top: none;
  border-right: none;
  border-bottom: none;
}

.filters-header {
  background: transparent;
  color: var(--dark-color);
  border-radius: 0;
  padding: 0;
  margin: 0 0 0.5rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.filters-header::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--gold);
  flex-shrink: 0;
}

.filter-row { margin-bottom: 0.125rem; }

.filters-section .form-label {
  font-weight: 600;
  color: #555;
  font-size: 0.78rem;
  margin-bottom: 0.125rem;
}

.filters-section .form-select,
.filters-section .form-control {
  border-color: rgba(0, 0, 0, .12);
  padding: .3rem .6rem;
  font-size: 0.82rem;
  height: auto;
  background: var(--white);
  border-radius: 6px;
}

.filters-section .form-select:focus,
.filters-section .form-control:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(34, 45, 82, .1);
}

/* ── CARD/TABLE CONTAINERS ────────────────────────── */
.table-container,
.accounts-container,
.handbooks-container,
.users-container,
.admin-container {
  background: var(--white);
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 1px 6px rgba(34, 45, 82, .07);
  border: 1px solid var(--cream);
  overflow: hidden;
}

/* Container header bar */
.accounts-header,
.handbooks-header,
.users-header {
  padding: 0.9rem 1.25rem;
  border-bottom: 2px solid var(--cream);
  margin-bottom: 0;
}

/* Inner padding for containers */
.accounts-container > *:not(.accounts-header):not(table):not(.table-responsive),
.handbooks-container > *:not(.handbooks-header):not(table):not(.table-responsive):not(.nav-tabs),
.users-container > *:not(.users-header):not(table):not(.table-responsive),
.admin-container > * {
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.accounts-container > .table-responsive,
.handbooks-container > .table-responsive,
.users-container > .table-responsive {
  margin: 0;
  border-radius: 0;
  border: none;
}

/* table-container keeps its internal padding for backward compat */
.table-container {
  padding: 1.25rem;
}

/* ── TABLE STYLES ────────────────────────────────── */
.table thead th {
  background: #f8f7f5;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #666;
  border-bottom: 2px solid var(--cream) !important;
  border-top: none;
  white-space: nowrap;
  padding: 0.6rem 0.85rem;
}

.table tbody tr {
  border-bottom: 1px solid #f0ece6;
  transition: background .1s;
}
.table tbody tr:hover {
  background: #faf8f5;
}
.table tbody td {
  vertical-align: middle;
  padding: 0.55rem 0.85rem;
}

/* Master row highlight (accounts) */
.table tbody tr.fw-bold td:first-child {
  border-left: 3px solid var(--gold);
}

/* Table-controls bar */
.table-controls {
  background: #f8f7f5;
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid var(--cream);
}

/* ── BUTTON OVERRIDES ────────────────────────────── */
.btn-primary {
  background-color: var(--navy);
  border-color: var(--navy);
}
.btn-primary:hover,
.btn-primary:focus {
  background-color: #1a2340;
  border-color: #1a2340;
}

.btn-outline-primary {
  color: var(--navy);
  border-color: var(--navy);
}
.btn-outline-primary:hover,
.btn-outline-primary:focus {
  background-color: var(--navy);
  border-color: var(--navy);
  color: var(--white);
}

/* Gold action button */
.btn-gold {
  background: var(--gold);
  color: var(--navy);
  border: none;
  border-radius: 8px;
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background .15s;
}
.btn-gold:hover { background: #c4a678; }

/* Navy outline button */
.btn-outline-navy {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--navy);
  border-radius: 8px;
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn-outline-navy:hover {
  background: var(--cream);
}

/* ── STATUS DOTS ─────────────────────────────────── */
.status-dot,
.status-dot-on,
.status-dot-off,
.status-dot-enabled,
.status-dot-disabled {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot-on,
.status-dot-enabled  { background: #10b981; }
.status-dot-off,
.status-dot-disabled { background: #d1d5db; }

/* ── MISC ────────────────────────────────────────── */
.form-check-input:checked {
  background-color: var(--navy);
  border-color: var(--navy);
}
.progress-bar { background-color: var(--navy); }

/* Scrollbar styling */
.table-container { scrollbar-width: thin; scrollbar-color: var(--border-color) transparent; }
.table-container::-webkit-scrollbar { height: 8px; }
.table-container::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
.table-container::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
.table-container::-webkit-scrollbar-thumb:hover { background: #c1c1c1; }

/* Scroll indicator */
.scroll-indicator {
  background: rgba(34, 45, 82, 0.08);
  border: 1px solid rgba(34, 45, 82, 0.15);
  border-radius: 6px;
  padding: 0.5rem;
  font-size: 0.8rem;
}
.scroll-indicator i { color: var(--navy); }

/* Admin card */
.admin-card {
  border: 1px solid var(--cream);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: #faf8f5;
}
.admin-card h6 { margin-bottom: 0.5rem; color: var(--navy); }

/* Modal header override */
.modal-header {
  background: var(--navy);
  color: var(--white);
}
.modal-header .btn-close {
  filter: brightness(0) invert(1);
  opacity: 0.7;
}
.modal-header .btn-close:hover { opacity: 1; }
.modal-title { font-weight: 700; }

/* ── RESPONSIVE ──────────────────────────────────── */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
  touch-action: pan-x;
}
.table-responsive::-webkit-scrollbar { height: 8px; }
.table-responsive::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
.table-responsive::-webkit-scrollbar-thumb:hover { background: #c1c1c1; }

@media (hover: none) and (pointer: coarse) {
  .table th, .table td { min-height: 44px; }
  .btn { min-height: 44px; }
  .form-control, .form-select { min-height: 44px; }
  .col-close { min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
}

@media (max-width: 768px) {
  .main-header .header-brand { display: none; }
  .main-header .nav-link { padding: 0 0.6rem; font-size: 0.78rem; }
  .main-header .nav-link i { display: none; }
}

/* Более заметный бегунок и трек слайдера стратегии */
#strategy-risk-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: pointer;
}
#strategy-risk-range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: #cbd5e1;
}
#strategy-risk-range::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: #cbd5e1;
}
#strategy-risk-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-color, #222D52);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary-color, #222D52);
  margin-top: -7px;
  cursor: pointer;
}
#strategy-risk-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-color, #222D52);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary-color, #222D52);
  cursor: pointer;
}

/* Компактная таблица счетов для роли admin */
.accounts-table-admin {
  font-size: 0.78rem;
}
.accounts-table-admin th,
.accounts-table-admin td {
  padding: 0.3rem 0.4rem;
  white-space: nowrap;
}
.accounts-table-admin .col-truncate {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
