:root {
  --brand: #2c3e50;
  --accent: #3498db;
  --error: #e74c3c;
  --ok: #27ae60;
  --bg: #f8f9fa;
  --border: #ddd;
  --text: #333;
  --text-light: #666;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 1rem;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

h1 {
  color: var(--brand);
  margin-bottom: 1rem;
  font-size: 1.75rem;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.app-header h1 {
  margin: 0;
  flex: 1;
}

.btn-logout {
  padding: 0.5rem 1rem;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-logout:hover {
  background: #c0392b;
}

.info-card {
  background: #e8f4f8;
  border-left: 4px solid var(--accent);
  padding: 1rem;
  margin-bottom: 1.5rem;
  border-radius: 4px;
}

.info-card p {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.info-card p:last-child {
  margin-bottom: 0;
}

.auth-warning {
  background: #fff3cd;
  border-left: 4px solid #ffc107;
  padding: 1rem;
  margin-bottom: 1.5rem;
  border-radius: 4px;
  display: none;
}

.auth-warning.show {
  display: block;
}

.auth-warning p {
  margin-bottom: 0.75rem;
  color: #856404;
}

.btn-login {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 0.5rem 1rem;
  text-decoration: none;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-login:hover {
  background: #2980b9;
}

/* ===== FORM GRID - POPRAVLJENA VERZIJA ===== */
.form-grid {
  display: grid;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }
  .form-group.full-width {
    grid-column: 1 / -1;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  min-width: 0; /* Omogućava da flex item može biti manji */
}

label {
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--brand);
  font-size: 0.9rem;
}

label .required {
  color: var(--error);
}

input, select, textarea {
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Placeholder styling - svjetliji i suptilniji */
input::placeholder,
textarea::placeholder {
  color: #adb5bd;
  opacity: 1;
  font-style: italic;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

input:read-only {
  background: #f5f5f5;
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

.field-error {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 0.3rem;
  display: none;
}

.field-error.show {
  display: block;
}

.submit-wrapper {
  position: sticky;
  bottom: 0;
  background: white;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
}

/* Form validation error iznad dugmeta */
.submit-wrapper .field-error {
  text-align: center;
  margin-bottom: 0.75rem;
  display: block;
  font-size: 0.9rem;
}

button[type="submit"] {
  width: 100%;
  padding: 0.9rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

button[type="submit"]:hover:not(:disabled) {
  background: #2980b9;
  transform: translateY(-1px);
}

button[type="submit"]:active:not(:disabled) {
  transform: translateY(0);
}

button[type="submit"]:disabled {
  background: #95a5a6;
  cursor: not-allowed;
}

button[type="submit"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

.result-message {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 4px;
  display: none;
  font-weight: 500;
}

.result-message.show {
  display: block;
}

.result-message.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.result-message.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
}

.tab-btn {
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-light);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -2px;
}

.tab-btn:hover {
  color: var(--accent);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* History section */
.history-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

.history-header h2 {
  color: var(--brand);
  font-size: 1.5rem;
  margin: 0;
}

.history-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.history-tab {
  flex: 1;
  min-width: 140px;
  padding: 0.75rem 1rem;
  background: #f0f0f0;
  color: var(--text);
  border: 2px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.history-tab:hover {
  background: #e0e0e0;
  border-color: var(--accent);
}

.history-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}

.history-info {
  background: #e8f4f8;
  border-left: 4px solid var(--accent);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  border-radius: 4px;
}

.history-info p {
  font-size: 0.9rem;
  color: var(--text-light);
  margin: 0;
}

.loading-state,
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
  display: none;
}

.loading-state.show,
.empty-state.show {
  display: block;
}

.table-wrapper {
  overflow-x: auto;
  display: none;
}

.table-wrapper.show {
  display: block;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.history-table thead {
  background: var(--brand);
  color: white;
}

.history-table th,
.history-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.history-table th {
  font-weight: 600;
  white-space: nowrap;
}

.history-table tbody tr {
  transition: background 0.2s;
}

.history-table tbody tr:hover {
  background: #f8f9fa;
}

.history-table td {
  vertical-align: middle;
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
}

.btn-icon {
  padding: 0.4rem 0.6rem;
  border: none;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.btn-edit {
  background: var(--accent);
  color: white;
}

.btn-edit:hover {
  background: #2980b9;
}

.btn-delete {
  background: var(--error);
  color: white;
}

.btn-delete:hover {
  background: #c0392b;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  overflow-y: auto;
  padding: 1rem;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  border-radius: 8px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

.modal-header h2 {
  margin: 0;
  color: var(--brand);
  font-size: 1.5rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--error);
}

#editForm {
  padding: 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.btn-primary,
.btn-secondary {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  background: #2980b9;
}

.btn-secondary {
  background: #95a5a6;
  color: white;
}

.btn-secondary:hover {
  background: #7f8c8d;
}

/* ===== NAVIGACIJA ===== */
.app-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border);
  flex-wrap: wrap;
}

.nav-link {
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  color: white;
  background: var(--brand);
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link:hover {
  background: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.nav-link.active {
  background: var(--accent);
}

/* ===== USER INFO BANNER ===== */
.user-info-banner {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.user-info-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.user-info-main {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-icon {
  font-size: 2.5rem;
  background: rgba(255, 255, 255, 0.2);
  width: 3.5rem;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.user-details {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.user-details strong {
  font-size: 1.25rem;
  font-weight: 600;
}

.user-meta {
  font-size: 0.9rem;
  opacity: 0.9;
}

.user-info-secondary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  opacity: 0.95;
}

.user-info-secondary::before {
  content: "🏫";
  font-size: 1.2rem;
}

/* ===== RADIO BUTTONS SECTION ===== */
.radio-section {
  background: #f8f9fa;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  padding: 1rem;
}

.radio-section .section-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--brand);
  font-size: 0.9rem;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: white;
  border-radius: 6px;
  border: 1px solid #dee2e6;
  transition: all 0.2s;
}

.radio-item:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.radio-item input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.radio-label {
  font-weight: 500;
  margin: 0;
  min-width: 110px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  flex-shrink: 0;
}

.radio-item select {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .history-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .history-table {
    font-size: 0.8rem;
  }

  .history-table th,
  .history-table td {
    padding: 0.5rem;
  }

  .action-buttons {
    flex-direction: column;
  }

  .modal-content {
    margin: 0;
    max-height: 100vh;
    border-radius: 0;
  }
}

@media (max-width: 600px) {
  .user-info-content {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .nav-link {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .radio-item {
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
  }
  
  .radio-item input[type="radio"] {
    flex-shrink: 0;
  }
  
  .radio-label {
    min-width: auto;
    font-size: 0.85rem;
    flex: 0 0 auto;
  }
  
  .radio-item select {
    flex: 1 1 100%;
    width: 100%;
  }
}

@media (max-width: 480px) {
  input, select, textarea {
    font-size: 16px; /* Prevent zoom on iOS */
  }
}