/* === RockHaven Forms - Global Styles === */
:root {
  --primary: #2c3e50;
  --primary-light: #34495e;
  --accent: #3498db;
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #e74c3c;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-light: #666;
  --border: #ddd;
  --radius: 6px;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* === Layout === */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  transition: transform 0.3s;
}

.sidebar-header {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header img {
  width: 40px;
  height: auto;
}

.sidebar-header .org-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.sidebar-nav a .icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

.sidebar-nav .nav-section {
  padding: 16px 20px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.4);
}

/* Nav categories */
.nav-cat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.85);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.nav-cat:hover { background: rgba(255,255,255,0.08); }

.nav-cat-icon { font-size: 18px; width: 22px; text-align: center; }

.nav-cat-arrow {
  margin-left: auto;
  font-size: 11px;
  transition: transform 0.2s;
  opacity: 0.5;
}

.nav-cat.open .nav-cat-arrow { transform: rotate(180deg); }

.nav-cat-items {
  display: none;
  background: rgba(0,0,0,0.2);
  padding: 4px 0;
}

.nav-cat.open + .nav-cat-items { display: block; }

.nav-cat-items a {
  padding: 7px 20px 7px 36px !important;
  font-size: 13px !important;
  color: rgba(255,255,255,0.65) !important;
}

.nav-cat-items a:hover,
.nav-cat-items a.active {
  color: #fff !important;
  background: rgba(255,255,255,0.1);
}

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 8px 16px;
}

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

.sidebar-footer a { color: rgba(255,255,255,0.7); text-decoration: none; }
.sidebar-footer a:hover { color: #fff; }

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 24px;
  min-height: 100vh;
}

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

.page-header h1 {
  font-size: 22px;
  color: var(--primary);
}

/* === Cards === */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 20px;
  margin-bottom: 20px;
}

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

.card-header h2 {
  font-size: 16px;
  color: var(--primary);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #2980b9; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #219a52; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d68910; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-secondary { background: #ecf0f1; color: var(--text); }
.btn-secondary:hover { background: #d5dbdb; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 24px; font-size: 15px; }

/* === Forms === */
.form-group {
  margin-bottom: 14px;
}

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

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
  background: #fff;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

/* === Tables === */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:hover td { background: #f8f9fa; }

/* === Badges === */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-draft { background: #fef3cd; color: #856404; }
.badge-submitted { background: #d4edda; color: #155724; }
.badge-archived { background: #e2e3e5; color: #383d41; }
.badge-child { background: #d1ecf1; color: #0c5460; }
.badge-foster-parent { background: #d4edda; color: #155724; }
.badge-social-worker { background: #cce5ff; color: #004085; }
.badge-cyw { background: #e2d5f1; color: #4a235a; }
.badge-director { background: #f8d7da; color: #721c24; }

/* === Status dots === */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-active { background: var(--success); }
.status-inactive { background: #bbb; }

/* === Search / Filter Bar === */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

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

.search-input {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input input {
  padding-left: 36px;
}

.search-input::before {
  content: '\u{1F50D}';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.4;
}

/* === Modal === */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  justify-content: center;
  align-items: flex-start;
  padding-top: 80px;
  overflow-y: auto;
}

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

.modal {
  background: var(--card);
  border-radius: 8px;
  width: 560px;
  max-width: 95vw;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  margin-bottom: 40px;
}

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

.modal-header h2 { font-size: 16px; }

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

.modal-body { padding: 20px; }

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

/* === Toast === */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--primary);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 300;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  max-width: 400px;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

/* === Login Page === */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

.login-card {
  background: var(--card);
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  width: 380px;
  max-width: 95vw;
  text-align: center;
}

.login-card img {
  width: 120px;
  margin-bottom: 16px;
}

.login-card h1 {
  font-size: 18px;
  color: var(--primary);
  margin-bottom: 24px;
}

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

.login-card .btn {
  width: 100%;
  justify-content: center;
  padding: 10px;
  font-size: 15px;
  margin-top: 8px;
}

.login-error {
  background: #fce4ec;
  color: var(--danger);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}

/* === Empty state === */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state h3 { margin-bottom: 8px; color: var(--text); }
.empty-state p { margin-bottom: 16px; }

/* === Mobile === */
.menu-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  width: 40px;
  height: 40px;
  font-size: 20px;
  cursor: pointer;
}

@media (max-width: 768px) {
  .menu-toggle { display: block; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 12px; padding-top: 56px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header h1 { font-size: 18px; }
  .filter-bar { flex-direction: column; }
  .filter-bar .form-control { width: 100%; min-width: 0; }
  .search-input { min-width: 0; width: 100%; }
  .modal { width: 95vw; }
  .card { padding: 12px; }

  /* Tables: make them scroll horizontally or stack */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 500px; }

  /* Buttons */
  .btn { padding: 10px 14px; font-size: 14px; }
  .btn-sm { padding: 8px 12px; }

  /* Entity cards on people page */
  .entity-card { padding: 10px; }
  .entity-name { font-size: 14px; }
  .entity-meta { font-size: 11px; word-break: break-word; }

  /* Stats grid */
  .stats-grid { grid-template-columns: 1fr 1fr !important; }
}

@media print {
  .sidebar, .menu-toggle, .no-print { display: none !important; }
  .main-content { margin-left: 0; padding: 0; }
  .card { box-shadow: none; }
}
