/* =========================================================
   PIM UI – app.css (Light + ChatGPT-like Dark, Bootstrap-safe)
   ========================================================= */

/* =========================
   Theme variables
   ========================= */

:root {
  --font-ui: 'Inter', system-ui, -apple-system, BlinkMacSystemFont,
             'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* Light */
  --bg: #f8fafc;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;

  /* Accent (light can stay slightly indigo) */
  --primary: #4f46e5;
  --primary-hover: #4338ca;

  --shadow:
    0 1px 2px rgba(0,0,0,.04),
    0 6px 16px rgba(0,0,0,.06);

  --row-hover: rgba(15, 23, 42, 0.035);
  --soft-hover: rgba(79, 70, 229, 0.08);
  --soft-active: rgba(79, 70, 229, 0.16);

  /* focus ring tuned for light */
  --focus-ring: rgba(79, 70, 229, 0.18);
}

/* =========================
   Dark theme (ChatGPT-like)
   ========================= */

html.theme-dark,
body.theme-dark {
  /* ChatGPT-ish: deep graphite */
  --bg: #0b0f14;
  --panel: #111827;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: rgba(255, 255, 255, 0.08);

  /* ChatGPT green accent */
  --primary: #10a37f;
  --primary-hover: #0e8f6f;

  --shadow:
    0 1px 2px rgba(0,0,0,.35),
    0 10px 26px rgba(0,0,0,.35);

  --row-hover: rgba(255, 255, 255, 0.03);
  --soft-hover: rgba(16, 163, 127, 0.10);
  --soft-active: rgba(16, 163, 127, 0.18);

  /* focus ring tuned for dark */
  --focus-ring: rgba(16, 163, 127, 0.22);
}

/* =========================
   Base
   ========================= */

html, body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.text-muted { color: var(--muted) !important; }

.border,
.border-top,
.border-bottom,
.border-start,
.border-end {
  border-color: var(--border) !important;
}

/* =========================
   Navbar
   ========================= */

.app-navbar {
  background: var(--panel) !important;
}

.navbar-brand {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text) !important;
}

.navbar-text {
  color: var(--muted) !important;
}

/* =========================
   Sidebar
   ========================= */

.app-sidebar {
  background: var(--panel);
  min-height: calc(100vh - 56px);
}

.nav-link {
  color: var(--text);
  border-radius: .6rem;
  padding: .55rem .75rem;
  font-weight: 600;
  opacity: .92;
  transition: color .16s ease, background-color .16s ease, box-shadow .16s ease;
}

.nav-link:hover {
  background: var(--soft-hover);
  color: var(--text);
  opacity: 1;
}

.nav-link.active {
  background: var(--soft-active);
  color: var(--primary);
  opacity: 1;
}

.nav-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 .15rem var(--focus-ring);
}

/* ✅ Opcja 2: separacja Ustawień TYLKO na desktop (bez "schodka" na mobile)
   Dodaj klasę .nav-settings na <li class="nav-item nav-settings"> w layout/main.php
*/
@media (min-width: 768px) {
  .app-sidebar .nav-settings {
    margin-top: .75rem;
    padding-top: .75rem;
    border-top: 1px solid var(--border);
  }
}
@media (max-width: 767.98px) {
  .app-sidebar .nav-settings {
    margin-top: 0 !important;
    padding-top: 0 !important;
    border-top: 0 !important;
  }
}

/* =========================
   Headings
   ========================= */

h1, h2, h3, h4, h5 {
  font-weight: 600;
  letter-spacing: -0.015em;
}

/* =========================
   Cards
   ========================= */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: .85rem;
  box-shadow: var(--shadow);
}

.card-body { padding: 1.25rem; }

/* =========================
   Tables (Bootstrap-safe)
   ========================= */

.table-responsive {
  background: var(--panel);
  border-radius: .85rem;
}

/* Bootstrap variables override for dark */
html.theme-dark .table,
body.theme-dark .table {
  --bs-table-bg: var(--panel);
  --bs-table-color: var(--text);
  --bs-table-border-color: rgba(255,255,255,0.06);
  --bs-border-color: rgba(255,255,255,0.06);
}

.table { color: var(--text); }

.table,
.table > :not(caption) > * > * {
  background-color: var(--panel) !important;
  color: var(--text) !important;
}

/* Header */
.table th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

html.theme-dark .table thead th,
body.theme-dark .table thead th {
  border-bottom-color: rgba(255,255,255,0.08) !important;
}

/* Body row separators – light */
.table td {
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}

/* Body row separators – dark */
html.theme-dark .table > :not(caption) > * > *,
body.theme-dark .table > :not(caption) > * > * {
  border-color: rgba(255,255,255,0.05) !important;
}

/* Hover */
.table tbody tr:hover { background: var(--row-hover); }

/* =========================
   Forms
   ========================= */

.form-label {
  font-weight: 600;
  font-size: .78rem;
  color: var(--muted);
}

.form-control,
.form-select {
  background: var(--panel);
  color: var(--text);
  border-color: var(--border);
  border-radius: .6rem;
  font-size: .9rem;
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}

.form-control::placeholder { color: rgba(100,116,139,.85); }

html.theme-dark .form-control::placeholder,
body.theme-dark .form-control::placeholder {
  color: rgba(156,163,175,.75);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 .15rem var(--focus-ring);
}

/* =========================
   Buttons
   ========================= */

.btn {
  font-weight: 600;
  border-radius: .6rem;
}

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

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

/* outline secondary fits ChatGPT dark */
.btn-outline-secondary {
  border-color: var(--border);
  color: var(--text);
}

.btn-outline-secondary:hover {
  background: rgba(255,255,255,0.06);
  border-color: var(--border);
  color: var(--text);
}

html.theme-dark .btn-outline-secondary,
body.theme-dark .btn-outline-secondary {
  border-color: rgba(255,255,255,0.12);
}

/* outline danger in dark */
html.theme-dark .btn-outline-danger,
body.theme-dark .btn-outline-danger {
  border-color: rgba(248,113,113,0.45);
  color: #fecaca;
}

html.theme-dark .btn-outline-danger:hover,
body.theme-dark .btn-outline-danger:hover {
  background: rgba(248,113,113,0.12);
}

/* =========================
   Badges
   ========================= */

.badge {
  font-weight: 600;
  font-size: .68rem;
  padding: .35em .55em;
  border-radius: .45rem;
}

html.theme-dark .badge.bg-success,
body.theme-dark .badge.bg-success { background-color: rgba(16,163,127,0.22) !important; color: #d1fae5 !important; }

html.theme-dark .badge.bg-secondary,
body.theme-dark .badge.bg-secondary { background-color: rgba(156,163,175,0.18) !important; color: #e5e7eb !important; }

html.theme-dark .badge.bg-dark,
body.theme-dark .badge.bg-dark { background-color: rgba(255,255,255,0.10) !important; color: #e5e7eb !important; }

html.theme-dark .badge.bg-info,
body.theme-dark .badge.bg-info { background-color: rgba(56,189,248,0.16) !important; color: #e0f2fe !important; }

html.theme-dark .badge.bg-warning,
body.theme-dark .badge.bg-warning { background-color: rgba(245,158,11,0.16) !important; color: #fffbeb !important; }

/* =========================
   Alerts
   ========================= */

.alert {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: .75rem;
}

/* =========================
   Product images
   ========================= */
.product-image-grid {
  gap: 1rem;
}

.product-thumb-card {
  width: 150px;
  max-width: 45vw;
}

.product-thumb-wrapper {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: .75rem;
  padding: .5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.product-thumb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.form-label-sm {
  font-size: .8rem;
  color: var(--muted);
}

.table-thumb-wrapper {
  width: 58px;
  height: 58px;
  border: 1px solid var(--border);
  border-radius: .65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg);
}

.table-thumb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.table-thumb-placeholder {
  color: var(--muted);
  font-size: 1.35rem;
}

.variant-child-name {
  font-weight: 600;
}

/* =========================
   Produkt - drzewo wariantów
   ========================= */

:root {
  --product-tree-indent: 18px;
}

.product-tree-cell {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
}

.product-tree-marker {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  margin-top: .2rem;
  flex-shrink: 0;
  background: var(--border);
}

.product-tree-marker.is-parent {
  background: rgba(56, 189, 248, 0.45);
  border: 1px solid rgba(56, 189, 248, 0.45);
}

.product-tree-marker.is-variant {
  background: var(--primary);
  border: 1px solid var(--primary-hover);
}

.product-tree-marker.is-simple {
  background: var(--muted);
  border: 1px solid rgba(100,116,139,.55);
}

.product-tree-child-row td {
  background: rgba(79, 70, 229, 0.03);
}

html.theme-dark .product-tree-child-row td,
body.theme-dark .product-tree-child-row td {
  background: rgba(255, 255, 255, 0.02);
}

/* =========================
   Breadcrumbs
   ========================= */

.breadcrumb { font-size: .78rem; }

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

.breadcrumb a:hover { text-decoration: underline; }

/* =========================
   Mobile sidebar: compact + horizontal nav
   ========================= */
@media (max-width: 767.98px) {
  .app-sidebar {
    min-height: auto !important;
    padding: .5rem !important;
  }

  .app-sidebar .nav {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: .5rem !important;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    padding-bottom: .25rem;
  }

  .app-sidebar .nav-link {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding: .45rem .65rem;
  }

  /* ✅ ujednolicenie wysokości itemów w poziomym pasku */
  .app-sidebar .nav-item {
    display: inline-flex;
    align-items: center;
  }
}

/* =========================
   Logo (SVG)
   ========================= */

.app-logo {
  width: 22px;
  height: 22px;
  display: inline-block;
}

/* Auto-adapt SVG logo in dark mode (works best for black logos) */
.app-logo-auto {
  filter: none;
}

html.theme-dark .app-logo-auto,
body.theme-dark .app-logo-auto {
  filter: invert(1) brightness(0.95) contrast(0.9);
  opacity: 0.95;
}

.logo-preview {
  border: 1px dashed var(--border);
  border-radius: .9rem;
  background: var(--panel);
  padding: 14px 16px;
}

.branding-guidelines li + li {
  margin-top: .35rem;
}
