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

:root {
  --primary: #1e293b;
  --primary-dark: #0f172a;
  --accent: #c0392b;
  --accent-dark: #a93226;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
}

/* Layout */
.app-header {
  background: var(--primary);
  color: white;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header h1 { font-size: 18px; font-weight: 600; white-space: nowrap; }
.header-logo { height: 36px; border-radius: 50%; background: white; }
.app-header .user-info { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.app-header .user-info span { opacity: 0.9; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* Watermark logo on home page */
.page-watermark {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  height: 300px;
  background: url('/img/logo.jpg') center/contain no-repeat;
  opacity: 0.06;
  pointer-events: none;
  z-index: 0;
}

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 24px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-header h2 { font-size: 20px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
  color: white;
}
.btn-primary { background: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-success { background: var(--success); }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: var(--gray-500); }
.btn-secondary:hover { background: var(--gray-700); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-100); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--gray-700);
}
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color 0.2s;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.1);
}
textarea.form-control { min-height: 120px; resize: vertical; }
select.form-control { cursor: pointer; }

/* Tables */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-200);
  font-size: 14px;
}
th {
  font-weight: 600;
  color: var(--gray-500);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
tr:hover td { background: var(--gray-50); }

/* Training cards */
.training-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.training-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 20px;
  transition: box-shadow 0.2s;
  cursor: pointer;
}
.training-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.training-card h3 { font-size: 18px; margin-bottom: 8px; color: var(--accent); }
.training-card p { color: var(--gray-500); font-size: 14px; margin-bottom: 12px; }
.training-card .meta { display: flex; gap: 16px; font-size: 13px; color: var(--gray-500); }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* Chapter sidebar */
.training-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
}
.chapter-nav {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 16px;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.chapter-nav h3 { font-size: 14px; color: var(--gray-500); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.chapter-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--gray-700);
  transition: background 0.2s;
  margin-bottom: 2px;
}
.chapter-link:hover { background: var(--gray-100); }
.chapter-link.active { background: #fde8e8; color: var(--accent); font-weight: 500; }
.chapter-link .check { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--gray-300); flex-shrink: 0; }
.chapter-link .check.done { background: var(--success); border-color: var(--success); position: relative; }
.chapter-link .check.done::after { content: ''; position: absolute; top: 3px; left: 5px; width: 5px; height: 8px; border: solid white; border-width: 0 2px 2px 0; transform: rotate(45deg); }

.chapter-content {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 32px;
}
.chapter-content h2 { font-size: 24px; margin-bottom: 16px; }
.chapter-content .text { font-size: 15px; line-height: 1.8; white-space: pre-wrap; }

/* Propis content (HTML from uploaded documents) */
.propis-content { font-size: 15px; line-height: 1.8; }
.propis-content h2 { font-size: 20px; font-weight: 700; margin: 24px 0 12px; color: var(--primary-dark); border-bottom: 2px solid var(--gray-200); padding-bottom: 8px; }
.propis-content h3 { font-size: 17px; font-weight: 600; margin: 20px 0 8px; color: var(--gray-900); }
.propis-content h4 { font-size: 15px; font-weight: 600; margin: 16px 0 8px; color: var(--gray-700); text-transform: uppercase; letter-spacing: 0.3px; }
.propis-content p { margin-bottom: 8px; }
.propis-content ul, .propis-content ol { margin: 8px 0 8px 24px; }
.propis-content li { margin-bottom: 4px; }
.propis-content table { margin: 12px 0; }
.propis-content strong, .propis-content b { font-weight: 600; }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.upload-zone:hover { border-color: var(--accent); background: #fef2f2; }
.upload-zone.drag-over { border-color: var(--accent); background: #fde8e8; }
.upload-icon { font-size: 48px; margin-bottom: 12px; }

/* Quiz */
.quiz-progress {
  background: var(--gray-200);
  border-radius: 4px;
  height: 8px;
  margin-bottom: 24px;
}
.quiz-progress-bar {
  background: var(--accent);
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}
.quiz-question { margin-bottom: 24px; }
.quiz-question h3 { font-size: 18px; margin-bottom: 16px; }
.quiz-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  background: white;
  font-size: 15px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all 0.2s;
}
.quiz-option:hover { border-color: var(--accent); background: #fef2f2; }
.quiz-option.selected { border-color: var(--accent); background: #fde8e8; }
.quiz-option.correct { border-color: var(--success); background: #dcfce7; }
.quiz-option.wrong { border-color: var(--danger); background: #fee2e2; }

/* Results */
.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 32px;
  font-weight: 700;
}
.score-pass { background: #dcfce7; color: #166534; }
.score-fail { background: #fee2e2; color: #991b1b; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #334155 100%);
}
.login-box {
  background: white;
  border-radius: 12px;
  padding: 40px;
  width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo { display: block; margin: 0 auto 16px; height: 90px; }
.login-box h1 { text-align: center; margin-bottom: 8px; color: var(--primary); font-size: 20px; line-height: 1.3; }
.login-box .subtitle { text-align: center; color: var(--gray-500); margin-bottom: 32px; font-size: 14px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 24px;
}
.tab {
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.tab:hover { color: var(--gray-700); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Nav links */
.nav-links { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 14px;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.nav-link:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-link.active { background: rgba(255,255,255,0.2); color: white; }

/* Alert */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal {
  background: white;
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal h2 { margin-bottom: 16px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}

/* Responsive */
@media (max-width: 768px) {
  .training-layout { grid-template-columns: 1fr; }
  .chapter-nav { position: static; max-height: none; }
  .training-grid { grid-template-columns: 1fr; }
  .container { padding: 16px; }
}

/* Utility */
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }

/* Reports: Summary cards */
.summary-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.summary-card { background: white; border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,0.1); padding: 20px; text-align: center; }
.summary-card .number { font-size: 32px; font-weight: 700; }
.summary-card .label { font-size: 14px; color: var(--gray-500); margin-top: 4px; }
.summary-card.card-success .number { color: var(--success); }
.summary-card.card-warning .number { color: #d97706; }
.summary-card.card-muted .number { color: var(--gray-500); }

/* Reports: Tabs */
.report-tabs { display: flex; gap: 0; margin-bottom: 24px; border-bottom: 2px solid var(--gray-200); }
.report-tab { padding: 10px 20px; cursor: pointer; font-weight: 500; color: var(--gray-500); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.report-tab:hover { color: var(--text); }
.report-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Reports: Filter bar */
.filter-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: 14px; }
.filter-bar input { min-width: 200px; }

/* Reports: User accordion */
.user-row { background: white; border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 8px; overflow: hidden; }
.user-row-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; cursor: pointer; transition: background 0.2s; }
.user-row-header:hover { background: var(--gray-50); }
.user-row-details { display: none; padding: 0 16px 16px; border-top: 1px solid var(--gray-200); }
.user-row.open .user-row-details { display: block; }
.user-row .chevron { transition: transform 0.2s; font-size: 12px; color: var(--gray-500); }
.user-row.open .chevron { transform: rotate(180deg); }

/* Reports: New badges */
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-muted { background: var(--gray-100); color: var(--gray-500); }

/* License activation */
.license-notice {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  margin-bottom: 24px;
}
.license-notice.license-expired {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}
.license-notice .license-icon { font-size: 32px; margin-bottom: 8px; }
.license-notice p { font-size: 14px; color: inherit; }

/* License badge in header */
.license-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
}
.license-badge.license-warning {
  background: rgba(245,158,11,0.3);
  color: #fef3c7;
}

/* Server address on login page */
.server-address-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 10px 16px;
  text-align: center;
  margin-bottom: 20px;
  font-size: 14px;
  color: #1e40af;
}

/* Settings page */
.settings-section { margin-bottom: 24px; }
.settings-section h3 { font-size: 16px; margin-bottom: 8px; }

/* Chapter editor */
#editor-container { border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: hidden; }
.jodit-wysiwyg { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 15px; line-height: 1.8; padding: 24px !important; }
.jodit-wysiwyg h2 { font-size: 20px; font-weight: 700; margin: 24px 0 12px; color: var(--primary-dark); border-bottom: 2px solid var(--gray-200); padding-bottom: 8px; }
.jodit-wysiwyg h3 { font-size: 17px; font-weight: 600; margin: 20px 0 8px; }
.jodit-wysiwyg h4 { font-size: 15px; font-weight: 600; margin: 16px 0 8px; text-transform: uppercase; }
.jodit-wysiwyg img { max-width: 100%; height: auto; border-radius: var(--radius); margin: 12px 0; }

@media (max-width: 768px) {
  .summary-cards { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar input { min-width: auto; }
}

/* ==================== obuke-online dodaci ==================== */
.org-name { color: rgba(255,255,255,0.85); font-size: 14px; padding-left: 16px; border-left: 1px solid rgba(255,255,255,0.2); }
.section-title { font-size: 16px; color: var(--gray-700); margin: 24px 0 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; }
.muted { color: var(--gray-500); }
.text-muted { color: var(--gray-500); }
.text-center { text-align: center; }
.hidden { display: none; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-4 { gap: 16px; }
.form-hint { display: block; margin-top: 4px; font-size: 12px; color: var(--gray-500); }
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 12px; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e293b, #334155); }
.login-box { background: white; padding: 40px; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); width: 100%; max-width: 420px; }
.login-box h1 { text-align: center; color: var(--primary-dark); margin-bottom: 4px; }
.login-box .subtitle { text-align: center; color: var(--gray-500); margin-bottom: 24px; }

/* Chapter list (training detail page) */
.chapter-list { list-style: none; padding: 0; }
.chapter-row { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--gray-100); cursor: pointer; transition: background 0.1s; }
.chapter-row:hover { background: var(--gray-50); }
.chapter-row.completed { background: #f0fdf4; }
.chapter-row .status { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--gray-200); color: var(--gray-700); font-weight: bold; flex-shrink: 0; }
.chapter-row.completed .status { background: var(--success); color: white; }
.chapter-row .chapter-title { flex: 1; font-weight: 500; }
.chapter-row .chapter-meta { color: var(--gray-500); font-size: 13px; }

/* Quiz */
.progress-bar { height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; margin-bottom: 16px; }
.progress-bar .progress { height: 100%; background: var(--success); transition: width 0.2s; }
.options { display: flex; flex-direction: column; gap: 8px; }
.option { display: flex; align-items: flex-start; gap: 8px; padding: 12px 16px; border: 2px solid var(--gray-200); border-radius: var(--radius); cursor: pointer; transition: all 0.1s; }
.option:hover { border-color: var(--accent); background: #fff5f5; }
.option.selected { border-color: var(--accent); background: #fef2f2; }
.option input[type=radio] { margin-top: 4px; }
.quiz-nav { display: flex; justify-content: space-between; margin-top: 24px; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead { background: var(--gray-50); }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--gray-100); font-size: 14px; }
.data-table th { font-weight: 600; color: var(--gray-700); text-transform: uppercase; font-size: 12px; letter-spacing: 0.3px; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card { background: white; padding: 24px; border-radius: var(--radius); border: 1px solid var(--gray-200); text-align: center; }
.stat-card .stat-num { font-size: 36px; font-weight: bold; color: var(--gray-700); margin-bottom: 4px; }
.stat-card.stat-success .stat-num { color: var(--success); }
.stat-card.stat-warning .stat-num { color: #d97706; }
.stat-card.stat-muted .stat-num { color: var(--gray-400); }

/* Modal (override existing if needed) */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-content { background: white; border-radius: 12px; padding: 24px; max-width: 600px; width: 100%; max-height: 80vh; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.checkbox-list { display: flex; flex-direction: column; gap: 8px; max-height: 400px; overflow-y: auto; }
.checkbox-row { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: var(--radius); }
.checkbox-row:hover { background: var(--gray-50); }
.checkbox-row input { margin: 0; }
.checkbox-row span { flex: 1; }

/* Header brand link (klikljivi naslov) */
.header-brand { color: inherit; text-decoration: none; }
.header-brand:hover { opacity: 0.85; }

/* Odjava dugme - bijelo na tamnom headeru */
.btn-logout {
  background: transparent;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 4px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.btn-logout:hover { background: rgba(255, 255, 255, 0.1); border-color: white; }

/* Trainings/admin modal (shared, koristi i landing) */
.trainings-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.trainings-modal {
  background: white;
  border-radius: 12px;
  max-width: 1100px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.trainings-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.trainings-modal-header h3 { font-size: 22px; margin: 0; }
.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--gray-500);
  padding: 0 8px;
}
.modal-close:hover { color: var(--primary); }
.trainings-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.trainings-modal-body textarea {
  resize: vertical;
  min-height: 80px;
}

/* Alert variants */
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
