/* ============================================================
   NOVIMAS Mieszalnia - Style główne
   Motyw: ciemny z akcentami pomarańczowo-złotymi
   ============================================================ */

:root {
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-card: #222222;
  --bg-card-hover: #2a2a2a;
  --bg-input: #2d2d2d;
  --border: #333333;
  --border-light: #444444;

  --accent: #e8820c;
  --accent-light: #f59e3a;
  --accent-dark: #c4680a;
  --accent-gold: #d4a017;
  --accent-gold-light: #e8c547;

  --text-primary: #f0f0f0;
  --text-secondary: #b0b0b0;
  --text-muted: #777777;
  --text-accent: #e8820c;

  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --shadow: 0 4px 24px rgba(0,0,0,0.5);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;

  --sidebar-w: 240px;
  --header-h: 60px;
  --transition: 0.2s ease;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-light); }

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

/* ---- Layout ---- */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
}

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

.sidebar-logo .logo-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  line-height: 1.2;
}

.sidebar-logo .logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(232, 130, 12, 0.12);
  color: var(--accent-light);
  border-left-color: var(--accent);
}

.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Header ---- */
.top-header {
  height: var(--header-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

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

/* ---- Page Content ---- */
.page-content {
  padding: 28px;
  flex: 1;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-light); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--accent); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-card); color: var(--text-primary); }

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

.btn-success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.3);
}
.btn-success:hover { background: rgba(34, 197, 94, 0.25); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ---- Stats Grid (Dashboard) ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all var(--transition);
}

.stat-card:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

.stat-icon {
  font-size: 24px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-light);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---- Tables ---- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead tr {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
}

th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

tr:last-child td { border-bottom: none; }

tbody tr {
  transition: background var(--transition);
  cursor: pointer;
}

tbody tr:hover {
  background: rgba(232, 130, 12, 0.06);
}

tbody tr:hover td { color: var(--text-primary); }

/* ---- Badges / Status ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-szkic { background: rgba(119,119,119,0.2); color: #aaa; }
.badge-w-toku { background: rgba(59,130,246,0.2); color: var(--info); }
.badge-do-zatwierdzenia { background: rgba(245,158,11,0.2); color: var(--warning); }
.badge-zatwierdzony { background: rgba(34,197,94,0.2); color: var(--success); }
.badge-archiwalny { background: rgba(239,68,68,0.15); color: var(--danger); }

.badge-robocza { background: rgba(119,119,119,0.2); color: #aaa; }
.badge-testowa { background: rgba(59,130,246,0.2); color: var(--info); }
.badge-zatwierdzona { background: rgba(34,197,94,0.2); color: var(--success); }

.badge-dostepny { background: rgba(34,197,94,0.2); color: var(--success); }
.badge-na-zamowienie { background: rgba(245,158,11,0.2); color: var(--warning); }
.badge-niedostepny { background: rgba(239,68,68,0.15); color: var(--danger); }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13.5px;
  transition: border-color var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 130, 12, 0.15);
}

.form-control::placeholder { color: var(--text-muted); }

textarea.form-control { min-height: 80px; resize: vertical; }

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23777' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

/* ---- Modal ---- */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.show { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-lg { max-width: 900px; }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 17px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 20px 24px; }

.modal-footer {
  padding: 14px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---- Progress Bar ---- */
.progress-bar-wrap {
  background: var(--bg-input);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
  margin: 4px 0;
}

.progress-bar {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  transition: width 0.4s ease;
}

.progress-bar.danger { background: linear-gradient(90deg, var(--danger), #f87171); }
.progress-bar.success { background: linear-gradient(90deg, var(--success), #4ade80); }

/* ---- Filters Row ---- */
.filters-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}

.filter-select {
  padding: 7px 28px 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23777' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
}

.search-input {
  padding: 7px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  width: 220px;
  outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

/* ---- Grid layouts ---- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* ---- Detail view ---- */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

.detail-section { margin-bottom: 20px; }

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ---- Info Grid ---- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.info-item { }
.info-item .info-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.info-item .info-value {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

/* ---- Agent AI Panel ---- */
.agent-panel {
  background: linear-gradient(135deg, rgba(232,130,12,0.08), rgba(212,160,23,0.05));
  border: 1px solid rgba(232,130,12,0.25);
  border-radius: var(--radius);
  padding: 20px;
}

.agent-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ---- AI Response ---- */
.ai-response {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}

.ai-proposal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  transition: all var(--transition);
}
.ai-proposal-card:hover { border-color: var(--accent); }
.ai-proposal-card:last-child { margin-bottom: 0; }

.ai-proposal-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-light);
  margin-bottom: 6px;
}

.ai-proposal-text {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
}

.ai-proposal-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---- Log ---- */
.log-container {
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  max-height: 250px;
  overflow-y: auto;
  color: #aaa;
}

.log-entry { margin-bottom: 4px; }
.log-time { color: #555; margin-right: 8px; }
.log-ok { color: var(--success); }
.log-err { color: var(--danger); }
.log-info { color: var(--info); }

/* ---- Loading / Spinner ---- */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(232,130,12,0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
}
.loading-overlay.show { display: flex; }
.loading-text { color: var(--accent-light); font-size: 14px; }

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13.5px;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

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

/* ---- Suma % row highlight ---- */
.sum-row td {
  background: rgba(232,130,12,0.08);
  font-weight: 700;
  color: var(--text-primary);
  border-top: 2px solid var(--accent);
}

.sum-ok { color: var(--success); }
.sum-err { color: var(--danger); }

/* ---- Breadcrumb ---- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { color: var(--text-primary); font-weight: 500; }
.breadcrumb-sep { color: var(--border-light); }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state-title { font-size: 17px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state-desc { font-size: 13.5px; margin-bottom: 20px; }

/* ---- Aromaty ---- */
.aroma-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all var(--transition);
}
.aroma-card:hover { border-color: var(--accent); background: var(--bg-card-hover); }
.aroma-card-name { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.aroma-card-meta { font-size: 12px; color: var(--text-muted); }
.aroma-card-nuty {
  font-size: 12.5px;
  color: var(--accent-light);
  margin: 6px 0;
}
.aroma-dosage {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.aroma-dosage-item {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* ---- Mobile Toggle ---- */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 22px;
  cursor: pointer;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }

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

  .main-content { margin-left: 0; }

  .menu-toggle { display: block; }

  .detail-layout { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .page-content { padding: 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .filters-row { flex-direction: column; align-items: stretch; }
  .search-input { width: 100%; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Utility ---- */
.text-accent { color: var(--accent-light); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-right { text-align: right; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 20px; }
.fw-bold { font-weight: 700; }
.fs-sm { font-size: 12px; }
.fs-lg { font-size: 16px; }
.w-100 { width: 100%; }
