/* ============================================================
   СКЛАДУА — СТИЛІ
   Підключається в index.html через: <link rel="stylesheet" href="css/style.css">
   ============================================================ */

/* ============================================================
   CSS ЗМІННІ — "дизайн-токени"
   Змінюєш тут один раз — змінюється скрізь на сайті.
   ============================================================ */
:root {
  /* Кольори фону (від темнішого до світлішого) */
  --bg:      #0d1117;
  --bg2:     #161b27;
  --bg3:     #1c2235;
  --border:  #252d42;

  /* Акцентні кольори */
  --accent:  #3d8ef0;   /* синій — кнопки, посилання */
  --accent2: #2dd4a0;   /* зелений — успіх, наявність */
  --warn:    #f0b429;   /* жовтий — попередження */
  --danger:  #f0436a;   /* червоний — помилки, видалення */

  /* Текст */
  --text:    #e2e8f4;   /* основний текст */
  --muted:   #6b7594;   /* другорядний текст */

  /* Шрифти */
  --font-head: 'Unbounded', sans-serif;   /* заголовки */
  --font-body: 'Manrope', sans-serif;     /* основний текст */

  /* Інше */
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --transition: 0.15s ease;
}

/* ============================================================
   СКИДАННЯ СТИЛІВ
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { scroll-behavior: smooth; }

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

/* ============================================================
   СТОРІНКА АВТОРИЗАЦІЇ
   ============================================================ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(61,142,240,0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(45,212,160,0.04) 0%, transparent 50%);
}

.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 44px 48px;
  width: 440px;
  max-width: 95vw;
  box-shadow: var(--shadow);
  animation: fadeUp 0.35s ease;
}

.auth-logo {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}

.auth-tagline {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 36px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg3);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 28px;
}

.auth-tab {
  padding: 9px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  color: var(--muted);
  border: none;
  background: none;
  transition: var(--transition);
}

.auth-tab.active {
  background: var(--bg2);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.auth-error {
  background: rgba(240,67,106,0.1);
  border: 1px solid rgba(240,67,106,0.25);
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 16px;
  display: none;
}

.auth-error.show { display: block; }

/* ============================================================
   МАКЕТ ДОДАТКУ (після логіну)
   ============================================================ */
.app {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   БОКОВА НАВІГАЦІЯ
   ============================================================ */
.sidebar {
  width: 230px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width 0.2s ease;
}

.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo h1 {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-logo span {
  font-size: 11px;
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

/* Індикатор підключення до БД */
.db-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.db-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--warn);
  flex-shrink: 0;
}

.db-dot.connected { background: var(--accent2); }
.db-dot.error     { background: var(--danger); }
.db-dot.loading   { animation: pulse 1.2s infinite; }

.nav-section { padding: 16px 12px 8px; }

.nav-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 0 12px 8px;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 9px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: var(--transition);
}

.nav-item:hover  { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(61,142,240,0.12); color: var(--accent); }
.nav-icon { font-size: 16px; width: 22px; text-align: center; flex-shrink: 0; }

/* Кнопка виходу внизу сайдбару */
.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.user-info {
  padding: 10px 12px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: default;
}

.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-email {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 130px;
}

/* ============================================================
   ГОЛОВНИЙ КОНТЕНТ
   ============================================================ */
.main {
  margin-left: 230px;
  flex: 1;
  padding: 36px 40px;
  min-height: 100vh;
}

.page { display: none; animation: fadeUp 0.2s ease; }
.page.active { display: block; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}

.page-title {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
}

.page-subtitle { font-size: 13px; color: var(--muted); margin-top: 5px; }

/* ============================================================
   КНОПКИ
   ============================================================ */
.btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: var(--transition);
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #2d7de0; transform: translateY(-1px); }

.btn-success { background: var(--accent2); color: #0d1117; }
.btn-success:hover:not(:disabled) { background: #24c490; transform: translateY(-1px); }

.btn-ghost { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.btn-danger { background: rgba(240,67,106,0.1); color: var(--danger); border: 1px solid rgba(240,67,106,0.2); }
.btn-danger:hover:not(:disabled) { background: rgba(240,67,106,0.2); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ============================================================
   КАРТКИ
   ============================================================ */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
}

/* ============================================================
   ДАШБОРД — статистика
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: default;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.stat-card.blue::after   { background: var(--accent); }
.stat-card.green::after  { background: var(--accent2); }
.stat-card.yellow::after { background: var(--warn); }
.stat-card.red::after    { background: var(--danger); }

.stat-icon  { font-size: 26px; margin-bottom: 14px; }
.stat-value { font-family: var(--font-head); font-size: 30px; font-weight: 700; line-height: 1; margin-bottom: 6px; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }

/* ============================================================
   ТАБЛИЦІ
   ============================================================ */
.table-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-toolbar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-input {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 9px 14px;
  width: 250px;
  transition: border 0.15s, box-shadow 0.15s;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61,142,240,0.1);
}

.search-input::placeholder { color: var(--muted); }

table { width: 100%; border-collapse: collapse; }

thead tr { background: var(--bg3); }

th {
  padding: 12px 18px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 14px 18px;
  font-size: 14px;
  border-bottom: 1px solid rgba(37,45,66,0.6);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: rgba(255,255,255,0.018); }

/* ============================================================
   БЕЙДЖІ
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-green  { background: rgba(45,212,160,0.1);  color: var(--accent2); }
.badge-yellow { background: rgba(240,180,41,0.1);  color: var(--warn); }
.badge-red    { background: rgba(240,67,106,0.1);  color: var(--danger); }
.badge-blue   { background: rgba(61,142,240,0.1);  color: var(--accent); }

/* ============================================================
   МОДАЛЬНІ ВІКНА
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 36px;
  width: 500px;
  max-width: 95vw;
  box-shadow: var(--shadow);
  animation: modalIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-title {
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 26px;
}

/* ============================================================
   ФОРМИ
   ============================================================ */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.form-input,
.form-select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 11px 14px;
  transition: border 0.15s, box-shadow 0.15s;
  appearance: none;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61,142,240,0.1);
}

.form-input::placeholder { color: var(--muted); }
.form-select option { background: var(--bg2); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; }

/* ============================================================
   ЗАЛИШОК — прогрес-бар
   ============================================================ */
.stock-bar { display: flex; align-items: center; gap: 10px; }
.stock-track { flex: 1; height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.stock-fill  { height: 100%; border-radius: 2px; transition: width 0.4s ease; }

/* ============================================================
   ФІЛЬТРИ
   ============================================================ */
.filter-bar { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }

.filter-btn {
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--muted);
  transition: var(--transition);
}

.filter-btn:hover  { color: var(--text); border-color: var(--muted); }
.filter-btn.active { background: rgba(61,142,240,0.15); color: var(--accent); border-color: var(--accent); }

/* ============================================================
   ПОРОЖНІЙ СТАН
   ============================================================ */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-icon  { font-size: 52px; margin-bottom: 16px; opacity: 0.35; }
.empty-state strong { font-size: 15px; color: var(--text); }
.empty-state p { font-size: 13px; margin-top: 8px; }

/* ============================================================
   TOAST ПОВІДОМЛЕННЯ
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.25s ease;
  min-width: 250px;
  max-width: 360px;
}

.toast.success { border-left: 3px solid var(--accent2); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }

/* ============================================================
   СПІННЕР
   ============================================================ */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

/* ============================================================
   СКЕЛЕТОН (завантаження)
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--border) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
  height: 32px;
  width: 60px;
}

/* ============================================================
   АНІМАЦІЇ
   ============================================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes pulse   { 0%,100% { opacity:1; } 50% { opacity:0.35; } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================================================
   АДАПТИВ
   ============================================================ */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .sidebar-logo h1,
  .sidebar-logo span,
  .db-status span,
  .nav-label,
  .nav-item span,
  .user-email { display: none; }
  .main { margin-left: 60px; padding: 20px 16px; }
  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; gap: 12px; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .modal { padding: 24px 20px; }
}
