/* ============================================================
   DEKATRON Elektro Portal — Modern UI
   ============================================================ */

:root {
  --sidebar-width: 255px;
  --topbar-height: 60px;

  --sidebar-bg:      #0f1923;
  --sidebar-hover:   #1a2e42;
  --sidebar-active:  #1d6fa5;
  --sidebar-border:  rgba(255,255,255,0.06);
  --sidebar-text:    #a8b9c8;
  --sidebar-text-active: #ffffff;

  --accent:          #1d6fa5;
  --accent-light:    #e8f4fd;
  --accent-dark:     #155d8a;

  --bg:              #f0f4f8;
  --card-bg:         #ffffff;
  --border:          #e2e8f0;
  --text:            #1e293b;
  --text-muted:      #64748b;

  --success:  #16a34a;
  --warning:  #d97706;
  --danger:   #dc2626;
  --info:     #0284c7;

  --radius:   10px;
  --shadow:   0 1px 3px rgba(0,0,0,0.07), 0 4px 16px rgba(0,0,0,0.05);
  --shadow-md:0 4px 6px rgba(0,0,0,0.07), 0 10px 30px rgba(0,0,0,0.08);
}

/* ============================================================
   Reset / Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; font-size: 0.9rem; color: var(--text); }

/* ============================================================
   Strona auth (login)
   ============================================================ */
.auth-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f1923 0%, #1d4060 50%, #0f1923 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   Layout aplikacji
   ============================================================ */
.app-body { display: flex; min-height: 100vh; background: var(--bg); }

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.28s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 1rem;
  flex-shrink: 0;
}

.brand-text {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.brand-sub {
  display: block;
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--sidebar-text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-close {
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.nav-section-label {
  font-size: 0.67rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(168,185,200,0.45);
  padding: 6px 10px 4px;
  margin-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}

.nav-item i { font-size: 1rem; flex-shrink: 0; }

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.nav-item.active {
  background: var(--accent);
  color: var(--sidebar-text-active);
  box-shadow: 0 2px 8px rgba(29,111,165,0.35);
}

/* Stopka sidebara */
.sidebar-footer {
  padding: 14px 14px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.user-name  { font-size: 0.82rem; font-weight: 600; color: #fff; line-height: 1.2; }
.user-role  { font-size: 0.72rem; color: var(--sidebar-text); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.user-details { min-width: 0; }

.user-actions {
  display: flex;
  gap: 6px;
}

.btn-sidebar-action {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  color: var(--sidebar-text);
  text-decoration: none;
  background: rgba(255,255,255,0.05);
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

.btn-sidebar-action:hover { background: rgba(255,255,255,0.12); color: #fff; }
.btn-sidebar-action.text-danger { color: #f87171 !important; }
.btn-sidebar-action.text-danger:hover { background: rgba(220,38,38,0.2); }

/* ============================================================
   Overlay mobile
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 999;
}

/* ============================================================
   Main wrapper
   ============================================================ */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.topbar-toggle {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}

.topbar-breadcrumb { flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* ============================================================
   Flash messages
   ============================================================ */
.flash-container { padding: 12px 24px 0; }

.flash-alert {
  border-radius: var(--radius);
  border: none;
  font-size: 0.875rem;
  box-shadow: var(--shadow);
}

/* ============================================================
   Page content
   ============================================================ */
.page-content {
  padding: 24px;
  flex: 1;
}

/* ============================================================
   Page header
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.page-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow);
}

.card-header {
  background: var(--card-bg) !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 14px 18px !important;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  border-radius: var(--radius) var(--radius) 0 0 !important;
}

.card-body { padding: 18px; }
.card-footer { background: var(--card-bg) !important; border-top: 1px solid var(--border) !important; padding: 12px 18px !important; }

/* ============================================================
   Stat cards
   ============================================================ */
.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
}

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.blue   { background: #dbeafe; color: #1d4ed8; }
.stat-icon.green  { background: #dcfce7; color: #16a34a; }
.stat-icon.orange { background: #ffedd5; color: #ea580c; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.red    { background: #fee2e2; color: #dc2626; }
.stat-icon.teal   { background: #ccfbf1; color: #0d9488; }

.stat-value { font-size: 2rem; font-weight: 800; line-height: 1; color: var(--text); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 3px; }

/* ============================================================
   Tables
   ============================================================ */
.table { font-size: 0.875rem; }

.table th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border) !important;
  padding: 10px 14px;
  white-space: nowrap;
  background: #f8fafc;
}

.table td {
  padding: 11px 14px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover td { background: #f8fafc; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  font-weight: 500;
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 6px;
}

.badge.bg-success { background: #dcfce7 !important; color: #166534 !important; }
.badge.bg-danger  { background: #fee2e2 !important; color: #991b1b !important; }
.badge.bg-warning { background: #fef9c3 !important; color: #854d0e !important; }
.badge.bg-info    { background: #dbeafe !important; color: #1e40af !important; }
.badge.bg-secondary { background: #f1f5f9 !important; color: #475569 !important; }
.badge.bg-primary { background: #dbeafe !important; color: #1e40af !important; }
.badge.bg-light   { background: #f8fafc !important; color: var(--text) !important; }

/* ============================================================
   Buttons
   ============================================================ */
.btn { border-radius: 8px; font-size: 0.875rem; font-weight: 500; padding: 7px 16px; transition: all 0.15s; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; border-radius: 6px; }
.btn-xs { padding: 3px 8px; font-size: 0.75rem; border-radius: 5px; }

.btn-primary { background: var(--accent) !important; border-color: var(--accent) !important; }
.btn-primary:hover { background: var(--accent-dark) !important; border-color: var(--accent-dark) !important; box-shadow: 0 3px 10px rgba(29,111,165,0.3); }

/* ============================================================
   Forms
   ============================================================ */
.form-control, .form-select {
  border-radius: 8px;
  border: 1.5px solid var(--border);
  font-size: 0.875rem;
  padding: 8px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29,111,165,0.12);
}

.form-label { font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.form-text  { font-size: 0.77rem; }

.input-group-text {
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: 8px 0 0 8px;
  color: var(--text-muted);
}

/* ============================================================
   List groups
   ============================================================ */
.list-group-item {
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 12px 18px;
  font-size: 0.875rem;
}

.list-group-item:last-child { border-bottom: none; }

/* ============================================================
   Status colors na wierszach tabeli
   ============================================================ */
tr.row-overdue td { background: rgba(220,38,38,0.04) !important; }
tr.row-warning  td { background: rgba(217,119,6,0.04) !important; }

/* ============================================================
   Strona logowania
   ============================================================ */
.login-card {
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.login-logo {
  width: 56px; height: 56px;
  background: var(--accent);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 1.6rem;
  margin: 0 auto 16px;
  box-shadow: 0 4px 14px rgba(29,111,165,0.5);
}

.login-card .form-control {
  background: rgba(255,255,255,0.07);
  border: 1.5px solid rgba(255,255,255,0.12);
  color: #fff;
}

.login-card .form-control::placeholder { color: rgba(255,255,255,0.35); }
.login-card .form-control:focus {
  background: rgba(255,255,255,0.1);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(29,111,165,0.25);
}

.login-card .form-label { color: rgba(255,255,255,0.7); }
.login-card .input-group-text { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.12); color: rgba(255,255,255,0.5); }
.login-card h2 { color: #fff; }
.login-card p  { color: rgba(255,255,255,0.55); }
.login-card .form-check-label { color: rgba(255,255,255,0.6); font-size: 0.82rem; }

/* ============================================================
   QR code
   ============================================================ */
.qr-box {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: inline-block;
}

/* ============================================================
   Status badge pills
   ============================================================ */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}
.status-pill.ok       { background: #dcfce7; color: #166534; }
.status-pill.attention{ background: #fef9c3; color: #854d0e; }
.status-pill.overdue  { background: #fee2e2; color: #991b1b; }
.status-pill.unknown  { background: #f1f5f9; color: #475569; }
.status-pill::before  { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ============================================================
   Alert cards (dashboard)
   ============================================================ */
.alert-card {
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: none;
  font-size: 0.875rem;
}

.alert-card.danger  { background: #fee2e2; color: #991b1b; }
.alert-card.warning { background: #fef9c3; color: #854d0e; }
.alert-card .alert-icon { font-size: 1.4rem; flex-shrink: 0; }

/* ============================================================
   Attachment preview cards
   ============================================================ */
.att-card { border-radius: 10px; overflow: hidden; border: 1px solid var(--border); transition: box-shadow 0.15s; }
.att-card:hover { box-shadow: var(--shadow-md); }
.att-card .att-preview { height: 160px; background: #f8fafc; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.att-card .att-preview iframe { width: 100%; height: 100%; border: none; pointer-events: none; }
.att-card .att-preview img   { width: 100%; height: 100%; object-fit: cover; }
.att-card .att-preview .att-icon { font-size: 3rem; color: var(--text-muted); }
.att-card .att-footer { padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.att-card .att-name   { font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   Drag & drop upload
   ============================================================ */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.drop-zone i { font-size: 2rem; color: var(--text-muted); }
.drop-zone p { font-size: 0.85rem; color: var(--text-muted); margin: 8px 0 0; }
.drop-zone input[type=file] { display: none; }

/* ============================================================
   Pagination
   ============================================================ */
.page-link { border-radius: 6px !important; margin: 0 2px; border: 1px solid var(--border); font-size: 0.82rem; color: var(--text); }
.page-item.active .page-link { background: var(--accent); border-color: var(--accent); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(0,0,0,0.3);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .sidebar-overlay.show {
    display: block;
  }
  .page-content { padding: 16px; }
}

@media (max-width: 575.98px) {
  .stat-value { font-size: 1.6rem; }
  .page-title { font-size: 1.1rem; }
  .card-body  { padding: 14px; }
}

/* ============================================================
   Scrollbar stylizacja
   ============================================================ */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
