/* Base reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background: #f5f5f5;
}

/* Navigation */
.nav-bar {
  background: #1a73e8;
  color: #fff;
  padding: 0.5rem 1rem;
}

.nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.2rem;
  white-space: nowrap;
}

/* Hamburger toggle — hidden on desktop */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  transition: transform 0.2s ease;
  position: relative;
}

.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: '';
  position: absolute;
  left: 0;
  width: 22px;
}

.nav-toggle-icon::before {
  top: -7px;
}

.nav-toggle-icon::after {
  top: 7px;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.nav-links a {
  color: #fff;
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.9rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.nav-links a:hover,
.nav-links a.active {
  background: rgba(255, 255, 255, 0.2);
}

/* Main app container */
#app {
  max-width: 1200px;
  margin: 1rem auto;
  padding: 0 1rem;
}

/* Responsive: mobile < 768px */
@media (max-width: 767px) {
  .nav-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 0;
    margin-top: 0.5rem;
  }

  .nav-links.nav-links--open {
    display: flex;
  }

  .nav-links li {
    width: 100%;
  }

  .nav-links a {
    display: flex;
    width: 100%;
    padding: 0.75rem 0.5rem;
    font-size: 0.9rem;
    min-height: 44px;
    border-radius: 4px;
  }

  #app {
    padding: 0 0.5rem;
  }

  /* Stack filter rows vertically on mobile */
  .form-card [style*="display: flex"][style*="flex-wrap"] {
    flex-direction: column;
  }
}

/* ===== Toast notifications ===== */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 0.75rem 1.25rem;
  border-radius: 6px;
  color: #fff;
  font-size: 0.95rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 360px;
  word-break: break-word;
}

.toast--visible {
  opacity: 1;
  transform: translateX(0);
}

.toast--error {
  background: #d32f2f;
}

.toast--success {
  background: #388e3c;
}

/* ===== Confirm dialog ===== */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9500;
}

.confirm-dialog {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.confirm-message {
  margin-bottom: 1.25rem;
  font-size: 1rem;
  line-height: 1.5;
  color: #333;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.confirm-btn {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 44px;
}

.confirm-btn--cancel {
  background: #e0e0e0;
  color: #333;
}

.confirm-btn--cancel:hover {
  background: #bdbdbd;
}

.confirm-btn--ok {
  background: #1a73e8;
  color: #fff;
}

.confirm-btn--ok:hover {
  background: #1558b0;
}

/* ===== Loading overlay ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9800;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e0e0e0;
  border-top-color: #1a73e8;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Responsive tweaks for toasts ===== */
@media (max-width: 767px) {
  .toast-container {
    top: auto;
    bottom: 1rem;
    right: 0.5rem;
    left: 0.5rem;
  }

  .toast {
    max-width: 100%;
    transform: translateY(20px);
  }

  .toast--visible {
    transform: translateY(0);
  }
}

/* ===== Login page ===== */
.login-card {
  max-width: 400px;
  margin: 4rem auto;
  padding: 2.5rem 2rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.login-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1a73e8;
  margin-bottom: 0.5rem;
}

.login-subtitle {
  color: #666;
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: #1a73e8;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
}

.login-btn:hover:not(:disabled) {
  background: #1558b0;
}

.login-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

@media (max-width: 767px) {
  .login-card {
    margin: 2rem 1rem;
    padding: 2rem 1.25rem;
  }
}

/* ===== Shared: Page headings ===== */
.page-heading {
  font-size: 1.5rem;
  font-weight: 700;
  color: #333;
  margin-bottom: 1.25rem;
}

/* ===== Shared: Data tables ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  margin-bottom: 1.5rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #e0e0e0;
  font-size: 0.9rem;
}

.data-table th {
  background: #f9f9f9;
  font-weight: 600;
  color: #555;
}

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

.data-table tbody tr:hover {
  background: #f5f8ff;
}

.data-table .actions-cell {
  white-space: nowrap;
}

/* ===== Shared: Forms ===== */
.form-card {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  margin-bottom: 1.5rem;
}

.form-card h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #333;
}

.form-group {
  margin-bottom: 0.85rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #555;
  margin-bottom: 0.25rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s;
  min-height: 44px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #1a73e8;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}

.form-group input.input-error,
.form-group select.input-error {
  border-color: #d32f2f;
}

/* ===== Shared: Inline validation errors ===== */
.field-error {
  color: #d32f2f;
  font-size: 0.8rem;
  margin-top: 0.2rem;
  min-height: 1rem;
}

/* ===== Shared: Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
  min-height: 44px;
}

.btn-primary {
  background: #1a73e8;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #1558b0;
}

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.btn-secondary:hover:not(:disabled) {
  background: #bdbdbd;
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.82rem;
  min-height: 44px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== Shared: Empty state ===== */
.empty-state {
  text-align: center;
  color: #888;
  padding: 2rem 1rem;
  font-size: 0.95rem;
}

/* ===== Responsive: tables scroll on mobile ===== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
  .data-table th,
  .data-table td {
    padding: 0.5rem;
    font-size: 0.82rem;
  }

  .form-card {
    padding: 1rem;
  }
}
