/* Basic layout */
* { box-sizing: border-box; }
body { margin: 0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji"; color: #111827; background: #f3f4f6; }

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: #ffffff; border-bottom: 1px solid #e5e7eb;
  position: sticky; top: 0; z-index: 10;
}
h1 { font-size: 20px; margin: 0; }
.btn { padding: 10px 16px; border-radius: 10px; background: #2563eb; color: #fff; border: none; cursor: pointer; font-size: 15px; font-weight: 500; }
.btn:hover { opacity: .95; }
.btn-secondary { background: #6b7280; }

.main { padding: 16px; max-width: 1200px; margin: 0 auto; }
.trip-picker { margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }

/* Groups grid */
.groups-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
@media (max-width: 1000px) {
  .groups-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .groups-grid { grid-template-columns: 1fr; }
}

/* Group card */
.group-card {
  background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 4px 10px rgba(0,0,0,.06);
  position: relative;
}
.group-colorbar {
  height: 44px;
  background: linear-gradient(90deg, #7c3aed, #4f46e5);
  position: relative;
}
.group-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px 16px;
  min-height: 64px;
}
.group-header-left { min-width: 0; }
.group-title { margin: 0 0 6px 0; font-size: 20px; font-weight: 700; }
.group-subtitle { font-size: 0.95rem; color: #6b7280; display: flex; gap: 10px; flex-wrap: wrap; }

.coach-thumb {
  width: 40px; height: 40px; border-radius: 9999px; object-fit: cover;
  flex: 0 0 40px; box-shadow: 0 0 0 2px #fff; background: #e5e7eb;
}
@media (max-width: 420px) { .coach-thumb { display: none; } }

.students-list {
  padding: 10px 16px 16px 16px;
  display: flex; flex-direction: column; gap: 8px;
  max-height: 500px; overflow: auto;
}

.student-pill {
  background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 10px 12px; font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.student-pill:hover {
  background: #f3f4f6;
  border-color: #2563eb;
  transform: translateX(2px);
}

.student-pill.has-medical {
  border-color: #e5e7eb;
  background: #f9fafb;
}

.student-name {
  flex: 1;
}

.medical-indicator {
  color: #dc2626;
  font-size: 20px;
  font-weight: bold;
  line-height: 1;
  flex-shrink: 0;
}

.external-access-indicator {
  display: inline-block;
  color: #9333ea;
  font-size: 15px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 0 #9333ea);
  -webkit-text-fill-color: #9333ea;
  -webkit-text-stroke-width: 0;
}

/* Delete Group Button */
.delete-group-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(220, 38, 38, 0.9);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 10;
}

.delete-group-btn:hover {
  background: rgba(220, 38, 38, 1);
  transform: translateY(-50%) scale(1.05);
}

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 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: 16px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 32px;
  line-height: 1;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.2s;
}

.modal-close:hover {
  background: #f3f4f6;
}

/* Confirmation Modal */
.confirm-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.confirm-modal-content {
  background: white;
  border-radius: 16px;
  max-width: 400px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.confirm-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.confirm-modal-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fef2f2;
  color: #dc2626;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.confirm-modal-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.confirm-modal-body {
  margin-bottom: 24px;
  color: #6b7280;
  line-height: 1.5;
}

.confirm-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.btn-danger {
  background: #dc2626;
}

.btn-danger:hover {
  background: #b91c1c;
  opacity: 1;
}

/* Tabs */
.modal-tabs {
  display: flex;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

.tab-btn {
  flex: 1;
  padding: 14px;
  background: none;
  border: none;
  font-size: 15px;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: #2563eb;
}

.tab-btn.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  background: white;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(90vh - 200px);
}

.tab-content {
  display: none;
}

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

.modal-body h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 600;
  color: #374151;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.edit-btn {
  background: #f3f4f6;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  color: #374151;
}

.edit-btn:hover {
  background: #e5e7eb;
}

.modal-body p {
  margin: 0 0 12px 0;
  line-height: 1.6;
}

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

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #374151;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.medical-alert {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 12px;
  color: #991b1b;
  font-weight: 500;
  margin-top: 16px;
}

.medical-notes-section {
  margin-top: 24px;
}

.medical-header {
  color: #991b1b;
  margin-bottom: 12px;
}

/* Goals */
.goals-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.goal-item {
  border-radius: 12px;
  padding: 14px;
  border: 2px solid;
}

.goal-item.completed {
  background: #f0fdf4;
  border-color: #86efac;
}

.goal-item.open {
  background: #fffbeb;
  border-color: #fde047;
}

.goal-item.open.clickable {
  cursor: pointer;
  transition: all 0.2s ease;
}

.goal-item.open.clickable:hover {
  background: #fef3c7;
  border-color: #fbbf24;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.goal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.goal-icon {
  font-size: 20px;
  line-height: 1;
}

.goal-item.completed .goal-icon {
  color: #16a34a;
}

.goal-item.open .goal-icon {
  color: #ca8a04;
}

.goal-title {
  font-weight: 600;
  font-size: 16px;
}

.goal-item.completed .goal-title {
  color: #16a34a;
}

.goal-item.open .goal-title {
  color: #92400e;
}

.goal-notes {
  font-size: 14px;
  color: #6b7280;
  font-style: italic;
  margin-top: 4px;
}

.goal-date {
  font-size: 13px;
  color: #6b7280;
  margin-top: 6px;
}

/* Notes */
.notes-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.medical-btn {
  background: #dc2626;
}

.medical-btn:hover {
  background: #b91c1c;
}

.note-form {
  background: #f9fafb;
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.note-form textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  margin-bottom: 12px;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.note-item {
  background: #fffbeb;
  border: 1px solid #fde047;
  border-radius: 10px;
  padding: 14px;
}

.note-item.medical {
  background: #fef2f2;
  border-color: #fecaca;
}

.note-text {
  margin-bottom: 8px;
  line-height: 1.5;
}

.note-date {
  font-size: 13px;
  color: #6b7280;
}

/* History */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.history-icon {
  font-size: 20px;
  line-height: 1;
}

.history-content {
  flex: 1;
}

.history-text {
  font-weight: 500;
  margin-bottom: 4px;
}

.history-coach {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 4px;
}

.history-date {
  font-size: 13px;
  color: #6b7280;
}

/* Admin Menu Styles */
.admin-menu {
  position: fixed;
  top: 60px;
  right: 20px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  z-index: 1000;
  min-width: 250px;
}

.admin-menu-header {
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-menu-header h3 {
  margin: 0;
  font-size: 16px;
}

.admin-menu-content {
  padding: 8px;
}

.admin-menu-item {
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  text-align: left;
  font-size: 15px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
  display: block;
  margin-bottom: 4px;
}

.admin-menu-item:hover {
  background: #f3f4f6;
}

/* Export Options Styles */
.export-option {
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.export-option:hover {
  border-color: #2563eb;
  background: #f9fafb;
}

.export-option label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  margin: 0;
}

.export-option input[type="radio"] {
  margin-top: 2px;
  cursor: pointer;
}

.checkbox-option {
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 12px;
}

.checkbox-option label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  margin: 0;
}

.checkbox-option input[type="checkbox"] {
  margin-top: 2px;
  cursor: pointer;
}

/* Admin menu items */
.admin-menu-item {
  width: 100%;
  padding: 14px 16px;
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  border: 2px solid #e0e7ff;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #1e293b;
  position: relative;
  overflow: hidden;
}

.admin-menu-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.admin-menu-item:hover {
  background: linear-gradient(135deg, #eff6ff, #f5f3ff);
  border-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.15), 0 0 0 1px rgba(37, 99, 235, 0.1);
}

.admin-menu-item:hover::before {
  opacity: 1;
}

.admin-menu-item:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}