/* Общие стили */
:root {
  --primary: #4a6cf7;
  --primary-rgb: 74, 108, 247; /* RGB values for #4a6cf7 */
  --primary-hover: #3a57d9;
  --primary-light: #eef2ff;
  --secondary: #6c757d;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  --info: #17a2b8;
  --dark: #343a40;
  --light: #f8f9fa;
  --body-bg: #f7f9fc;
  --sidebar-bg: #ffffff;
  --card-bg: #ffffff;
  --border-color: #e9ecef;
  --text-color: #495057;
  --text-muted: #6c757d;
  --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  --radius: 0.375rem;
  --transition: all 0.3s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: var(--body-bg);
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-hover);
}

h1, h2, h3, h4, h5, h6 {
  margin-bottom: 1rem;
  font-weight: 600;
  line-height: 1.2;
}

h2 {
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
  color: var(--dark);
}

h3 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--dark);
}

input, select, textarea, button {
  font-family: inherit;
}

hr {
  margin: 1.5rem 0;
  border: 0;
  border-top: 1px solid var(--border-color);
}

/* Контейнеры и разметка */
.main {
  max-width: 1300px;
  padding: 0 1rem;
    margin-bottom: 5rem;
}

.card {
  background-color: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Навигация */
.tab-nav {
  display: flex;
  background-color: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.tab-link {
  padding: 1rem 1.5rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-color);
  transition: var(--transition);
  border-bottom: 2px solid transparent;
  text-align: center;
  flex: 1;
}

.tab-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background-color: var(--primary-light);
}

.tab-link:hover:not(.active) {
  background-color: var(--light);
}

.tab {
  display: none;
}

.tab.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Формы */
input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: var(--transition);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.2);
}

textarea {
  min-height: 150px;
  resize: vertical;
}

/* Кнопки */
button,
.btn {
  display: inline-block;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  user-select: none;
  border: 1px solid transparent;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  line-height: 1.5;
  border-radius: var(--radius);
  transition: var(--transition);
  cursor: pointer;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
}

button:focus,
.btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.2);
}

.btn-primary {
  color: #fff;
  background-color: var(--primary);
  border-color: var(--primary);
}

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

.btn-secondary {
  color: #fff;
  background-color: var(--secondary);
  border-color: var(--secondary);
}

.btn-secondary:hover {
  background-color: #5a6268;
  border-color: #545b62;
}

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

.btn-danger:hover {
  background-color: #c82333;
  border-color: #bd2130;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

/* Стили для страницы входа */
.admin-login {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #4a6cf7 0%, #3a57d9 100%);
}

.admin-login__form {
  width: 100%;
  max-width: 400px;
  background-color: var(--card-bg);
  border-radius: var(--radius);
  padding: 2.5rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.admin-login__form h2 {
  color: var(--dark);
  margin-bottom: 2rem;
}

.admin-login__form input {
  margin-bottom: 1.5rem;
}

.admin-login__form button {
  width: 100%;
  background-color: var(--primary);
  color: white;
  border: none;
  padding: 1rem;
  font-size: 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

.admin-login__form button:hover {
  background-color: var(--primary-hover);
}

/* Компоненты для админки */
.header {
  background-color: var(--card-bg);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  border-radius: var(--radius);
}

.header-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--dark);
  margin: 0;
}

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

.logout-link {
  color: var(--danger);
  font-weight: 500;
  margin-left: 1rem;
}

/* Стили для реферальных ссылок */
.reflink,
.custom-link {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: center;
}

.reflink input,
.custom-link input {
  margin-bottom: 0;
}

.remove-reflink,
.remove-custom-link {
  background-color: var(--danger);
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  margin: 0;
}

.remove-reflink:hover,
.remove-custom-link:hover {
  background-color: #c82333;
}

#add-reflink,
#add-custom-link {
  background-color: var(--success);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  margin-bottom: 1.5rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

#add-reflink:hover,
#add-custom-link:hover {
  background-color: #218838;
}

/* Уведомления */
#success-message {
  position: fixed;
  top: 20px;
  right: 20px;
  background-color: var(--success);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-20px);
  transition: var(--transition);
  z-index: 1000;
}

#success-message.show {
  opacity: 1;
  transform: translateY(0);
}

/* Фиксированная кнопка сохранения */
.save-button {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: var(--card-bg);
  padding: 1rem;
  box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
  text-align: center;
  z-index: 999;
}

.save-button button {
  margin: 0;
  background-color: var(--primary);
  color: white;
  padding: 0.75rem 2rem;
}

/* Адаптивность */
@media (max-width: 768px) {
  .reflink,
  .custom-link {
    flex-direction: column;
  }

  .tab-nav {
    flex-wrap: wrap;
  }

  .tab-link {
    padding: 0.75rem 1rem;
  }
}

/* Стили для базы знаний */
.kb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.kb-search {
  margin-bottom: 1.5rem;
}

.kb-search input {
  padding-left: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236c757d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.75rem center;
}

.kb-articles-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.kb-article-item {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.kb-article-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.kb-article-title {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-weight: 600;
  color: var(--dark);
  font-size: 1.1rem;
}

.kb-article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.kb-article-date {
  color: var(--text-muted);
}

.kb-article-category-tag {
  display: inline-block;
  background-color: var(--primary-light);
  color: var(--primary);
  padding: 0.25rem 0.75rem;
  border-radius: 50px;
  font-size: 0.875rem;
  font-weight: 500;
}

.kb-article-excerpt {
  color: var(--text-color);
  font-size: 0.9375rem;
  line-height: 1.5;
  margin-bottom: 1.25rem;
  /* Limit to 3 lines with ellipsis */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-grow: 1;
}

.kb-article-actions {
  display: flex;
  margin-top: auto;
}

.kb-view-article {
  padding: 1.5rem;
  background-color: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.kb-view-title {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--dark);
}

.kb-view-category {
  display: inline-block;
  background-color: var(--primary-light);
  color: var(--primary);
  padding: 0.25rem 0.75rem;
  border-radius: 50px;
  font-size: 0.875rem;
  font-weight: 500;
  margin-right: 1rem;
}

.kb-view-date {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.kb-article-content {
  margin-top: 2rem;
  line-height: 1.7;
  font-size: 1.0625rem;
}

.kb-article-content h1,
.kb-article-content h2,
.kb-article-content h3 {
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.kb-article-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 1.5rem 0;
}

.kb-article-content pre {
  background-color: var(--light);
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.9rem;
  margin: 1.5rem 0;
}

.kb-article-content blockquote {
  border-left: 4px solid var(--primary);
  padding-left: 1rem;
  font-style: italic;
  margin: 1.5rem 0;
  color: var(--text-muted);
}

.kb-article-content ul,
.kb-article-content ol {
  margin: 1rem 0 1rem 1.5rem;
}

.no-articles {
  text-align: center;
  padding: 3rem;
  background-color: var(--light);
  border-radius: var(--radius);
  grid-column: 1 / -1;
}

.kb-edit-view form {
  display: grid;
  gap: 1.25rem;
}

.category-select-container {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.category-select-container select {
  flex: 1;
  margin-bottom: 0;
}

.category-dialog {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.category-dialog.show {
  display: flex;
}

.category-dialog-content {
  background-color: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 90%;
  max-width: 500px;
  box-shadow: var(--shadow);
}

.category-dialog-title {
  margin-top: 0;
  margin-bottom: 1.5rem;
}

.category-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Стили для фильтрации категорий */
.kb-categories-filter {
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.kb-category-filter-btn {
  background-color: var(--light);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  padding: 0.375rem 0.875rem;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.kb-category-filter-btn:hover {
  background-color: var(--primary-light);
  border-color: var(--primary);
}

.kb-category-filter-btn.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: white;
}
