/* ═══════════════════════════════════════════════════════════════
   TachoPro 2.0 – Main stylesheet
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS variables ─────────────────────────────────────────── */
:root {
  --tp-sidebar-w:      240px;
  --tp-topbar-h:       56px;
  --tp-primary:        #0d6efd;
  --tp-primary-dark:   #0a58ca;
  --tp-sidebar-bg:     #0f172a;
  --tp-sidebar-hover:  #1e293b;
  --tp-sidebar-active: #1e40af;
  --tp-sidebar-text:   #94a3b8;
  --tp-sidebar-active-text: #fff;
  --tp-topbar-bg:      #ffffff;
  --tp-topbar-border:  #e2e8f0;
  --tp-body-bg:        #f1f5f9;
  --tp-card-bg:        #ffffff;
  --tp-card-border:    #e2e8f0;
  --tp-text:           #1e293b;
  --tp-muted:          #64748b;
  --tp-radius:         12px;
  --tp-radius-sm:      8px;
  --tp-shadow:         0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --tp-shadow-md:      0 4px 6px rgba(0,0,0,.07), 0 10px 20px rgba(0,0,0,.08);
  --tp-transition:     0.2s ease;
}

/* ── Reset & base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: .9375rem;
  color: var(--tp-text);
  background: var(--tp-body-bg);
  line-height: 1.5;
}

/* ── Layout skeleton ────────────────────────────────────────── */
.tp-layout {
  display: grid;
  grid-template-rows: var(--tp-topbar-h) 1fr;
  grid-template-columns: var(--tp-sidebar-w) 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  min-height: 100vh;
}

/* ── Top bar ────────────────────────────────────────────────── */
.tp-topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: 1030;
  height: var(--tp-topbar-h);
  background: var(--tp-topbar-bg);
  border-bottom: 1px solid var(--tp-topbar-border);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.tp-brand { color: var(--tp-text) !important; }
.tp-brand-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--tp-primary), #6366f1);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1rem;
}
.tp-brand-name { font-size: 1.05rem; }

.btn-ghost-light {
  background: transparent;
  border: none;
  color: var(--tp-muted);
}
.btn-ghost-light:hover { background: #f1f5f9; color: var(--tp-text); }

/* ── Sidebar ────────────────────────────────────────────────── */
.tp-sidebar {
  grid-area: sidebar;
  position: fixed;
  top: var(--tp-topbar-h);
  left: 0;
  width: var(--tp-sidebar-w);
  height: calc(100vh - var(--tp-topbar-h));
  background: var(--tp-sidebar-bg);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1020;
  transition: transform var(--tp-transition);
  display: flex;
  flex-direction: column;
}

.tp-nav { padding: 1rem 0; flex: 1; }

.tp-nav-separator {
  padding: .5rem 1rem .25rem;
  margin-top: .5rem;
}
.tp-nav-separator small {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
}

.tp-nav-item { position: relative; }

.tp-nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1.25rem;
  color: var(--tp-sidebar-text);
  text-decoration: none;
  border-radius: 0;
  transition: background var(--tp-transition), color var(--tp-transition);
  font-size: .9rem;
  cursor: pointer;
}
.tp-nav-link:hover {
  background: var(--tp-sidebar-hover);
  color: #e2e8f0;
}
.tp-nav-item.active .tp-nav-link {
  background: var(--tp-sidebar-active);
  color: var(--tp-sidebar-active-text);
}
.tp-nav-item.active .tp-nav-link::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: #60a5fa;
  border-radius: 0 2px 2px 0;
}
.tp-nav-link i { font-size: 1.05rem; flex-shrink: 0; }

.tp-nav-locked .tp-nav-link {
  opacity: .45;
  cursor: not-allowed;
}
.tp-nav-locked .tp-nav-link:hover { background: none; }

.tp-sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid #1e293b;
}

/* ── Sidebar overlay (mobile) ───────────────────────────────── */
.tp-sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  z-index: 1015;
  background: rgba(0,0,0,.5);
}
.tp-sidebar-overlay.show { display: block; }

/* ── Main content ───────────────────────────────────────────── */
.tp-main {
  grid-area: main;
  min-height: calc(100vh - var(--tp-topbar-h));
  padding: 0;
  margin-left: 30px;
}
.tp-content { padding: 1.75rem 1.5rem 1.75rem 0; }

.tp-page-header { }
.tp-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: .25rem;
}
.tp-page-subtitle { font-size: .9rem; }

/* ── Cards ──────────────────────────────────────────────────── */
.tp-card {
  background: var(--tp-card-bg);
  border: 1px solid var(--tp-card-border);
  border-radius: var(--tp-radius);
  box-shadow: var(--tp-shadow);
  overflow: hidden;
}
.tp-card-header {
  padding: 1rem 1.25rem .75rem;
  border-bottom: 1px solid var(--tp-card-border);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.tp-card-title {
  font-size: .95rem;
  font-weight: 600;
  margin: 0;
}
.tp-card-body { padding: 1.25rem; }
.tp-card-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--tp-card-border);
  background: #f8fafc;
}

/* ── Stat widgets ───────────────────────────────────────────── */
.tp-stat {
  background: var(--tp-card-bg);
  border: 1px solid var(--tp-card-border);
  border-radius: var(--tp-radius);
  box-shadow: var(--tp-shadow);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.tp-stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.tp-stat-icon.danger  { background:#fee2e2; color:#dc2626; }
.tp-stat-icon.warning { background:#fef9c3; color:#d97706; }
.tp-stat-icon.success { background:#d1fae5; color:#059669; }
.tp-stat-icon.primary { background:#dbeafe; color:#2563eb; }
.tp-stat-icon.secondary{ background:#f1f5f9; color:#64748b; }

.tp-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: .25rem;
}
.tp-stat-label {
  font-size: .8rem;
  color: var(--tp-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Status badges ──────────────────────────────────────────── */
.badge-overdue  { --bs-badge-bg: #dc2626; }
.badge-soon     { --bs-badge-bg: #d97706; }
.badge-ok       { --bs-badge-bg: #059669; }

/* ── Table enhancements ─────────────────────────────────────── */
.tp-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tp-table th {
  background: #f8fafc;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--tp-muted);
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--tp-card-border);
  white-space: nowrap;
}
.tp-table td {
  padding: .65rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.tp-table tbody tr:hover { background: #f8fafc; }
.tp-table tbody tr:last-child td { border-bottom: none; }

/* ── Login page ─────────────────────────────────────────────── */
.tp-login-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tp-login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 2.5rem;
}
.tp-login-logo {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, #0d6efd, #6366f1);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.75rem;
  color: #fff;
  margin: 0 auto 1.25rem;
}

/* ── Progress / loading ─────────────────────────────────────── */
.tp-loading {
  display: flex; align-items: center; justify-content: center;
  gap: .75rem; padding: 3rem;
  color: var(--tp-muted);
}

/* ── Violation badges ───────────────────────────────────────── */
.violation-error { background:#fee2e2; color:#991b1b; border-radius:6px; padding:.15rem .45rem; font-size:.8rem; }
.violation-warn  { background:#fef9c3; color:#92400e; border-radius:6px; padding:.15rem .45rem; font-size:.8rem; }
.violation-ok    { background:#d1fae5; color:#065f46; border-radius:6px; padding:.15rem .45rem; font-size:.8rem; }

/* ── Chart containers ───────────────────────────────────────── */
.tp-chart-wrap { position: relative; height: 260px; }
.tp-chart-wrap canvas { max-height: 260px; }

/* ── Setup wizard ───────────────────────────────────────────── */
.tp-setup-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.tp-setup-card {
  width: 100%;
  max-width: 600px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 2.5rem;
}

/* ── Timeline (activity chart) ──────────────────────────────── */
.tp-timeline { display: flex; height: 24px; border-radius: 4px; overflow: hidden; width: 100%; }
.tp-timeline-seg { display: inline-block; height: 100%; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1199px) {
  .tp-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .tp-sidebar {
    transform: translateX(calc(-1 * var(--tp-sidebar-w)));
  }
  .tp-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.4);
  }
  .tp-main { margin-left: 0 !important; }
}

@media (min-width: 1200px) {
  .tp-main { margin-left: 25px; }
}

/* ── Utilities ──────────────────────────────────────────────── */
.text-overdue { color: #dc2626 !important; }
.text-soon    { color: #d97706 !important; }
.text-ok      { color: #059669 !important; }
.fs-7 { font-size: .8rem; }
.fw-600 { font-weight: 600; }

.tp-empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--tp-muted);
}
.tp-empty-state i { font-size: 3rem; margin-bottom: .75rem; display: block; opacity: .4; }

/* ── Demo / Trial banner ────────────────────────────────────── */
.tp-demo-banner {
  background: linear-gradient(90deg, #fef3c7 0%, #fde68a 100%);
  border-bottom: 2px solid #f59e0b;
  color: #78350f;
  padding: .45rem 1.25rem;
  font-size: .85rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  grid-area: topbar;
  z-index: 200;
  /* Banner sits above topbar; shift topbar down */
}
.tp-demo-banner.expired {
  background: linear-gradient(90deg, #fee2e2 0%, #fca5a5 100%);
  border-bottom-color: #ef4444;
  color: #7f1d1d;
}
.tp-demo-upgrade-link {
  margin-left: auto;
  font-weight: 700;
  color: inherit;
  text-decoration: none;
  border: 1.5px solid currentColor;
  border-radius: 6px;
  padding: .1rem .65rem;
  transition: background .15s;
}
.tp-demo-upgrade-link:hover { background: rgba(0,0,0,.08); }

/* ── Demo print watermark ────────────────────────────────────── */
@media print {
  .tp-demo-banner { display: none !important; }
  body.tp-demo::after {
    content: "WERSJA DEMONSTRACYJNA";
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-35deg);
    font-size: 5rem;
    font-weight: 900;
    color: rgba(239, 68, 68, .12);
    pointer-events: none;
    z-index: 9999;
    white-space: nowrap;
  }
}

/* ── Roles badge helpers ────────────────────────────────────── */
.role-superadmin { background:#fee2e2; color:#991b1b; }
.role-admin      { background:#dbeafe; color:#1e40af; }
.role-manager    { background:#d1fae5; color:#065f46; }
.role-viewer     { background:#f1f5f9; color:#475569; }
