/* ChaSK Admin — ChaSK/Artronic branding */
@import url('/shared/css/brand.css?v=4');

:root {
  --navy: #0b1e5e;
  --sky: #5cc8f0;
  --sky-light: #e8f6fd;
  --dark: #1a1e2e;
  --text: #2d3436;
  --text-light: #636e72;
  --border: #dfe6e9;
  --bg: #f5f7fa;
  --white: #ffffff;
  --green: #00b894;
  --red: #d63031;
  --orange: #f39c12;
  --radius: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', -apple-system, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* Busy indicator — API._busyCount > 0 postavlja body.busy.
   cursor:progress dozvoljava interakciju (async REST), samo prikazuje feedback. */
body.busy, body.busy * { cursor: progress !important; }

/* ===== LAYOUT ===== */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--navy);
  color: var(--white);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo img {
  height: 44px;
  width: auto;
}

.sidebar-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--sky);
  padding: 2px 20px 0;
}

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.08);
  color: var(--white);
}

.sidebar-nav a.active {
  background: rgba(92,200,240,0.12);
  color: var(--sky);
  border-left-color: var(--sky);
}

.sidebar-nav a .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  filter: brightness(0) invert(0.7);
}
.sidebar-nav a:hover .icon,
.sidebar-nav a.active .icon {
  filter: brightness(0) invert(1);
}
/* Tabs — inline row */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 12px;
}
.tab {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--navy); }
.tab.active { color: var(--sky); border-bottom-color: var(--sky); }
/* Action button icons */
.btn-icon { display: inline-flex; align-items: center; gap: 4px; }
.btn-icon img { width: 14px; height: 14px; filter: brightness(0) invert(0.3); }
.btn-icon:hover img { filter: brightness(0) invert(0); }
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  #print-area table { border-collapse: collapse; width: 100%; font-size: 11px; }
  #print-area th, #print-area td { border: 1px solid #ccc; padding: 4px 8px; text-align: left; }
  #print-area th { background: #f0f0f0; font-weight: 600; }
  #print-area img { display: none; }
}

/* Tenant brand logo (env CHASK_LOGIN_LOGO, default Artronic) — dno sidebara,
   vidljiv na svim admin stranicama. */
.sidebar-brand {
  padding: 16px 20px 4px;
  text-align: center;
}
.sidebar-brand img {
  height: 56px;
  width: auto;
  max-width: 100%;
  opacity: 0.9;
}

.sidebar-user {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}

.sidebar-user strong {
  color: var(--white);
  display: block;
}

.main {
  flex: 1;
  margin-left: 220px;
  padding: 0;
}

/* ===== TOPBAR ===== */

.topbar {
  background: var(--white);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--navy);
}

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

/* ===== CONTENT ===== */

.content {
  padding: 24px 28px;
}

/* ===== CARDS ===== */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
}

.card-label {
  font-size: 12px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.card-accent { border-left: 3px solid var(--sky); }
.card-green { border-left: 3px solid var(--green); }
.card-orange { border-left: 3px solid var(--orange); }
.card-red { border-left: 3px solid var(--red); }

/* ===== TABLE ===== */

.panel {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

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

.panel-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
}

.panel-body {
  padding: 0;
}

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

thead th {
  background: var(--bg);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
}

tbody tr:hover {
  background: var(--sky-light);
}

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

/* ===== BUTTONS ===== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: #0d2470; }
.btn-sky { background: var(--sky); color: var(--white); }
.btn-sky:hover { background: #3cb8e8; }
.btn-green { background: var(--green); color: var(--white); }
.btn-green:hover { background: #009e7e; }
.btn-red { background: var(--red); color: var(--white); }
.btn-red:hover { background: #c0392b; }
.btn-outline { background: none; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ===== FORMS ===== */

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  transition: border 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(92,200,240,0.15);
}

select.form-control {
  appearance: auto;
}

/* ===== BADGES ===== */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.badge-driver { background: #dfe6e9; color: var(--text); }
.badge-supervisor { background: #e8f6fd; color: #0984e3; }
.badge-manager { background: #ffeaa7; color: #d68910; }
.badge-admin { background: #fab1a0; color: #c0392b; }
.badge-active { background: #d4edda; color: #155724; }
.badge-inactive { background: #f8d7da; color: #721c24; }
.badge-open { background: #e8f6fd; color: #0984e3; }
.badge-completed { background: #d4edda; color: #155724; }
.badge-progress { background: #fff3cd; color: #856404; }
.badge-rejected { background: #f8d7da; color: #721c24; }

/* ===== MODAL ===== */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  justify-content: center;
  align-items: flex-start;
  padding-top: 80px;
}

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

.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 500px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

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

.modal-header h3 {
  font-size: 16px;
  color: var(--navy);
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-light);
}

.modal-body {
  padding: 20px;
}

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

/* ===== LOGIN ===== */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(26,35,53,0.55), rgba(26,35,53,0.45)), url('../img/login-bg.jpg') center/cover no-repeat;
}

.login-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px;
  width: 380px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.login-box img {
  width: 180px;
  margin-bottom: 8px;
}

.login-box h2 {
  font-size: 14px;
  color: var(--text-light);
  font-weight: 400;
  margin-bottom: 28px;
}

.login-box .form-group {
  text-align: left;
}

.login-box .btn {
  width: 100%;
  justify-content: center;
  padding: 10px;
  font-size: 14px;
  margin-top: 6px;
}

.login-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.login-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 10px;
  display: none;
}

.login-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-light);
  display: flex;
  justify-content: center;
  gap: 10px;
}

/* ===== UTILITY ===== */

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-light); }
.text-small { font-size: 12px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none; }

/* ===== TOOLBAR (filter bar) ===== */

.toolbar {
  padding: 14px 20px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}

.toolbar .form-control {
  width: auto;
  min-width: 160px;
}

/* ===== SEARCH ===== */

.search-box {
  position: relative;
}

.search-box input {
  width: 300px;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  background: var(--white) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="%23636e72" stroke-width="2"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>') 10px center no-repeat;
}

.search-box input:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(92,200,240,0.15);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  width: 450px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  z-index: 300;
  display: none;
}

.search-results.active { display: block; }

.search-group-label {
  padding: 6px 14px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  font-weight: 600;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.search-item {
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-item:hover { background: var(--sky-light); }

.search-item .name { font-weight: 600; }
.search-item .meta { font-size: 11px; color: var(--text-light); }

.company-selector {
  background: var(--sky-light);
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: center;
}

.company-selector label {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
}

.company-selector select {
  min-width: 250px;
}

/* ===== TOAST NOTIFIKACIJE ===== */

.toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 10000;
  display: flex; flex-direction: column; gap: 8px; max-width: 400px;
}
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  border-radius: 8px; color: #fff; font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,.15); opacity: 0;
  transform: translateX(40px); transition: opacity .3s, transform .3s;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-error   { background: #e74c3c; }
.toast-success { background: #27ae60; }
.toast-warning { background: #f39c12; }
.toast-info    { background: var(--sky); }
.toast-icon    { font-size: 16px; flex-shrink: 0; }
.toast-msg     { flex: 1; }

/* ===== SPINNER ===== */

.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 3px solid var(--border); border-top-color: var(--sky);
  border-radius: 50%; animation: spin .6s linear infinite;
  vertical-align: middle; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== RESPONSIVE TABLICE ===== */

.panel-body { overflow-x: auto; }

.sort-ind { font-size: 10px; color: var(--sky); margin-left: 2px; }

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-nav a span { display: none; }
  .sidebar-logo, .sidebar-label, .sidebar-user { display: none; }
  .main { margin-left: 60px; }
  .cards { grid-template-columns: 1fr 1fr; }
  .toolbar { flex-wrap: wrap; gap: 6px; }
  .toolbar select, .toolbar input[type="date"] { min-width: auto; width: 120px; }
  .modal { width: 95vw !important; max-height: 90vh; }
}

/* ===== PAGINATION ===== */
.pagination { display:flex; align-items:center; gap:3px; margin-top:12px; flex-wrap:wrap; }
.pg-btn { min-width:30px; height:28px; padding:0 7px; border:1px solid var(--border); background:var(--white); color:var(--text); border-radius:4px; cursor:pointer; font-size:13px; line-height:28px; text-align:center; }
.pg-btn:hover:not([disabled]) { background:var(--sky-light); border-color:var(--sky); color:var(--sky); }
.pg-btn.pg-active { background:var(--sky); color:#fff; border-color:var(--sky); font-weight:600; cursor:default; }
.pg-btn[disabled] { opacity:.38; cursor:default; }
.pg-dots { padding:0 2px; color:var(--text-light); font-size:13px; line-height:28px; }
.pg-info { margin-left:8px; font-size:12px; color:var(--text-light); white-space:nowrap; }
