/* Академия ВС — базовые стили (PRD §7) */

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

:root {
  --color-bg: #FFFFFF;
  --color-card: #F5F5F5;
  --color-text: #111827;
  --color-text-muted: #6B7280;
  --color-border: #E5E7EB;
  --color-accent: #DC2626;
  --color-accent-hover: #B91C1C;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

/* Страницы авторизации */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
  background: var(--color-card);
}

.auth-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 40px 32px;
  width: 100%;
  max-width: 420px;
}

.auth-card__logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-card__logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: -0.3px;
}

.auth-card__logo p {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.auth-card__footer {
  text-align: center;
  font-size: 14px;
  color: var(--color-text-muted);
  margin-top: 20px;
}

.auth-card__footer a {
  color: var(--color-accent);
  text-decoration: none;
}

.auth-card__footer a:hover {
  text-decoration: underline;
}

/* Формы */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 16px;
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-bg);
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

.form-group input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.form-group .error {
  font-size: 13px;
  color: var(--color-accent);
  margin-top: 4px;
}

.btn {
  display: block;
  width: 100%;
  padding: 13px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}

.btn:hover {
  background: var(--color-accent-hover);
}

/* Алерты */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 20px;
}

.alert--error {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: var(--color-accent);
}

.alert--success {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  color: #15803D;
}

.alert--info {
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  color: #1D4ED8;
}

/* ===== APP LAYOUT ===== */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Шапка */
.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 56px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header__menu-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.header__menu-btn span {
  display: block;
  width: 100%;
  height: 2px;
  background: #111827;
  border-radius: 2px;
}

.header__logo {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-accent);
  text-decoration: none;
  flex: 1;
}

.header__user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header__username {
  font-size: 14px;
  color: var(--color-text-muted);
}

.header__logout {
  font-size: 14px;
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.header__logout:hover { color: var(--color-accent); }

.header__admin-link {
  font-size: 13px;
  color: var(--color-text-muted);
  text-decoration: none;
  padding: 3px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.header__admin-link:hover { color: var(--color-accent); border-color: var(--color-accent); }

.header__search {
  flex: 1;
  max-width: 320px;
}

.header__search input {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  background: var(--color-card);
  color: var(--color-text);
}
.header__search input:focus {
  outline: none;
  border-color: var(--color-accent);
  background: var(--color-bg);
}

@media (max-width: 480px) {
  .header__search { display: none; }
}

/* Body */
.app__body {
  display: flex;
  flex: 1;
  overflow: clip;
}

/* Sidebar */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  background: var(--color-bg);
}

.sidebar__inner {
  padding: 16px 0;
}

.sidebar__empty {
  padding: 16px;
  font-size: 14px;
  color: var(--color-text-muted);
}

.sidebar__overlay {
  display: none;
}

/* Main */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px;
}

/* ===== МЕНЮ ===== */

.menu-section {
  margin-bottom: 2px;
}

.menu-section__toggle {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
  padding: 9px 16px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
}

.menu-section__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.menu-section--depth-1 .menu-section__title { font-weight: 500; padding-left: 8px; }
.menu-section--depth-2 .menu-section__title { font-weight: 400; padding-left: 16px; }

.menu-section--depth-1 .menu-section__toggle { padding-left: 24px; }
.menu-section--depth-2 .menu-section__toggle { padding-left: 32px; }

.menu-section__arrow {
  font-size: 12px;
  color: var(--color-text-muted);
  transition: transform 0.15s;
  flex-shrink: 0;
  margin-top: 3px;
}

.menu-section--collapsed .menu-section__arrow {
  transform: rotate(-90deg);
}

.menu-section--collapsed .menu-section__body {
  display: none;
}

.menu-material {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 7px 16px 7px 28px;
  font-size: 14px;
  color: var(--color-text);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.1s;
}

.menu-section--depth-1 .menu-material { padding-left: 36px; }
.menu-section--depth-2 .menu-material { padding-left: 44px; }

.menu-material:hover {
  background: var(--color-card);
}

.menu-material--active {
  border-left-color: var(--color-accent);
  background: var(--color-card);
  font-weight: 500;
}

.menu-material__title {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
}

.menu-material__check {
  font-size: 12px;
  color: #15803D;
  font-weight: 700;
  flex-shrink: 0;
  margin-left: 6px;
  margin-top: 3px;
}

/* ===== ПОИСК ===== */

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
}

.search-bar input {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 16px;
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-bg);
}
.search-bar input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.search-bar button {
  padding: 11px 20px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
}
.search-bar button:hover { background: var(--color-accent-hover); }

.search-results__group {
  margin-bottom: 28px;
}

.search-results__group-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.search-result {
  display: block;
  padding: 12px 16px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--color-text);
  margin-bottom: 6px;
  transition: border-color 0.15s;
}
.search-result:hover { border-color: var(--color-accent); }

.search-result__title { font-size: 15px; font-weight: 500; }
.search-result__sub {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 2px;
}
.search-result__check {
  font-size: 12px;
  color: #15803D;
  font-weight: 700;
  margin-left: 6px;
}

.search-empty {
  color: var(--color-text-muted);
  font-size: 15px;
  padding: 16px 0;
}

/* ===== MOBILE ===== */

@media (max-width: 768px) {
  .header__menu-btn { display: flex; }

  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
    box-shadow: 2px 0 12px rgba(0,0,0,.1);
  }

  .sidebar--open {
    transform: translateX(0);
  }

  .sidebar__overlay {
    display: block;
    position: fixed;
    inset: 56px 0 0 0;
    background: rgba(0,0,0,.3);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }

  .sidebar--open ~ .sidebar__overlay,
  .sidebar__overlay--visible {
    opacity: 1;
    pointer-events: auto;
  }

  .main { padding: 20px 16px; }
}

/* ===== ГЛАВНАЯ ===== */

.home-hero {
  max-width: 600px;
}

.home-hero__title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 12px;
}

.home-hero__desc {
  font-size: 16px;
  color: var(--color-text-muted);
  margin-bottom: 28px;
  line-height: 1.6;
}

.home-hero__progress {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 28px;
}

.progress-label {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.progress-bar {
  height: 8px;
  background: var(--color-border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar__fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 4px;
  transition: width 0.3s;
}

.progress-count {
  font-size: 13px;
  color: var(--color-text-muted);
}

.btn--inline {
  display: inline-block;
  width: auto;
  padding: 13px 32px;
  text-decoration: none;
}

.btn--secondary {
  background: var(--color-card);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn--secondary:hover {
  background: #E5E7EB;
}

/* ===== СТРАНИЦА МАТЕРИАЛА ===== */

.material-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
  padding: 0;
}

.material-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  gap: 16px;
}

.material-header__title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn--done {
  white-space: nowrap;
  width: auto;
  padding: 9px 20px;
  font-size: 14px;
}

.btn--done-already {
  background: #15803D;
}
.btn--done-already:hover { background: #166534; }

.material-iframe {
  flex: 1;
  width: 100%;
  border: none;
}

@media (max-width: 768px) {
  .material-page { height: calc(100vh - 56px); }
  .material-header { padding: 10px 16px; }
  .material-header__title { font-size: 14px; }
}


/* ===== КАСТОМНАЯ АДМИНКА ===== */

.admin-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  padding: 0 16px;
}

.admin-nav__link {
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
}
.admin-nav__link:hover { background: var(--color-card); color: var(--color-text); }
.admin-nav__link--active { background: var(--color-card); color: var(--color-text); }

.ap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.ap-title {
  font-size: 22px;
  font-weight: 700;
}

.ap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.ap-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--color-border);
  font-size: 13px;
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ap-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.ap-table tr:last-child td { border-bottom: none; }
.ap-table tr:hover td { background: var(--color-card); }

.ap-table__actions {
  white-space: nowrap;
  display: flex;
  gap: 12px;
}

.ap-table__actions a {
  font-size: 13px;
  color: var(--color-accent);
  text-decoration: none;
}
.ap-table__actions a:hover { text-decoration: underline; }

.ap-link--danger { color: var(--color-accent) !important; }
.ap-link--muted {
  font-size: 14px;
  color: var(--color-text-muted);
  text-decoration: none;
}
.ap-link--muted:hover { color: var(--color-text); }

.ap-form { max-width: 560px; }

.ap-select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 16px;
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-appearance: none;
}
.ap-select:focus { outline: none; border-color: var(--color-accent); }

.ap-form__actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 28px;
}

.alert--success { background: #F0FDF4; border-color: #BBF7D0; color: #15803D; }
.alert--error   { background: #FEF2F2; border-color: #FECACA; color: var(--color-accent); }

/* ===== ДЕРЕВО ДОСТУПОВ ===== */

.access-tree {
  max-width: 640px;
}

.access-section {
  margin-bottom: 4px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.access-section--depth-1 { margin-left: 20px; }
.access-section--depth-2 { margin-left: 40px; }

.access-section__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--color-card);
  cursor: default;
}

.access-section__toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--color-text-muted);
  padding: 0 2px;
  line-height: 1;
}

.access-section--collapsed .access-section__body {
  display: none;
}

.access-section__title {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
}

.access-section__actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-section-access {
  padding: 4px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.1s;
}

.btn-section-enable {
  background: #DCFCE7;
  border-color: #BBF7D0;
  color: #15803D;
}
.btn-section-enable:hover { background: #BBF7D0; }

.btn-section-disable {
  background: #FEF2F2;
  border-color: #FECACA;
  color: var(--color-accent);
}
.btn-section-disable:hover { background: #FECACA; }

.btn-section-access:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.access-section__body {
  padding: 6px 0;
}

.access-material {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px 7px 28px;
  cursor: pointer;
  transition: background 0.1s;
}
.access-material:hover { background: var(--color-card); }

.access-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--color-accent);
  flex-shrink: 0;
  cursor: pointer;
}

.access-material__title {
  font-size: 14px;
  color: var(--color-text);
}
