/* Color Variables & Mobile-First Reset */
:root {
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --secondary-color: #0d9488;
  --secondary-hover: #0f766e;
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --danger-color: #ef4444;
  --danger-hover: #dc2626;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --radius: 12px;
  --header-height: 60px;
  --nav-height: 64px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent; /* Disable default gray tap highlights in Safari mobile */
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
}

/* App Wrapper: Mobile layout is full viewport height column */
.app-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* Header Styles */
.app-header {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 16px;
  height: var(--header-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  z-index: 100;
  flex-shrink: 0;
}

.header-logo-area h1 {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--primary-color);
  letter-spacing: -0.5px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.student-filter-wrapper select {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: #f1f5f9;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

/* Auth Buttons & Profile Widget */
.btn-auth {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.btn-auth:hover {
  background-color: #f8fafc;
  border-color: var(--text-muted);
}

.icon-google {
  flex-shrink: 0;
}

.user-profile-widget {
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--primary-color);
  object-fit: cover;
}

.user-details-popover {
  display: none;
  position: absolute;
  top: 36px;
  right: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  box-shadow: var(--shadow-md);
  width: 160px;
  z-index: 200;
  flex-direction: column;
  gap: 8px;
  animation: fadeIn 0.2s ease;
}

.user-profile-widget:hover .user-details-popover {
  display: flex;
}

.popover-username {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-main);
  word-break: break-all;
}

/* Sync Status Banner */
.sync-banner {
  background-color: #ecfdf5;
  border-bottom: 1px solid #a7f3d0;
  padding: 6px 16px;
  text-align: center;
  z-index: 90;
  flex-shrink: 0;
}

.sync-banner-text {
  font-size: 0.72rem;
  font-weight: 700;
  color: #047857;
}

/* Main Content Panel scrollable */
.app-main-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  padding-bottom: calc(var(--nav-height) + 16px); /* Extra padding so navigation doesn't block content */
}

/* Tab Panels */
.tab-panel {
  display: none;
  animation: slideUp 0.25s ease-out;
}

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

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Bottom Navigation Bar (Mobile Style) */
.app-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
  z-index: 100;
}

.nav-tab-btn {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-icon {
  font-size: 1.25rem;
  margin-bottom: 2px;
}

.nav-label {
  font-size: 0.65rem;
  font-weight: 700;
}

.nav-tab-btn.active {
  color: var(--primary-color);
}

.nav-tab-btn:hover {
  background-color: #f8fafc;
}

/* Stats Cards styling */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.stat-card.highlight {
  border-left: 4px solid var(--secondary-color);
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
}

.dashboard-activity h2 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 12px;
}

/* Activity logs listing */
.activity-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.activity-item {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  box-shadow: var(--shadow-sm);
}

.activity-details {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 80%;
}

.activity-title {
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Badges styling */
.badge {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.badge.achievement {
  background-color: #e0e7ff;
  color: #3730a3;
}

.badge.volunteer {
  background-color: #ccfbf1;
  color: #0f766e;
}

.badge.category {
  background-color: #f1f5f9;
  color: #475569;
}

.badge.student {
  background-color: #fef3c7;
  color: #92400e;
}

/* Card form styling */
.form-container-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.form-container-card h2 {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--text-main);
}

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

.form-row {
  display: flex;
  gap: 12px;
}

.form-group.col {
  flex: 1;
}

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--bg-card);
  color: var(--text-main);
  outline: none;
  transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-conditional-panel {
  background-color: #f1f5f9;
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* File zone custom design */
.file-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  background-color: var(--bg-card);
  cursor: pointer;
  transition: all 0.2s ease;
}

.file-dropzone:hover {
  border-color: var(--primary-color);
  background-color: #f5f3ff;
}

.file-dropzone span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.file-dropzone input[type="file"] {
  display: none;
}

.form-image-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 10px;
  background-color: #f1f5f9;
  border-radius: 8px;
}

.form-image-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

/* Buttons */
.btn-primary {
  width: 100%;
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-secondary {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background-color: #f8fafc;
  border-color: var(--text-muted);
}

.btn-danger {
  background-color: var(--danger-color);
  color: white;
  border: none;
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-danger:hover {
  background-color: var(--danger-hover);
}

.btn-text {
  background: none;
  border: none;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-text.danger {
  color: var(--danger-color);
}

.btn-text.danger:hover {
  text-decoration: underline;
}

/* History logs list view */
.history-controls-panel {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.history-controls-panel input {
  flex: 2;
}

.history-controls-panel select {
  flex: 1;
}

.history-records-container {
  min-height: 300px;
}

.empty-state {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

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

.log-item {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

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

.log-badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.log-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.log-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
}

.log-body {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
  white-space: pre-line;
}

.log-volunteer-details {
  background-color: #f8fafc;
  border-radius: 6px;
  padding: 10px;
  font-size: 0.78rem;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--border-color);
}

.log-image-thumbnail {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: opacity 0.2s;
}

.log-image-thumbnail:hover {
  opacity: 0.8;
}

.log-actions {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
  margin-top: 4px;
}

/* Settings tab design */
.settings-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.settings-card h2 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 6px;
}

.card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.add-student-form {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.add-student-form input {
  flex: 1;
}

.settings-student-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.student-profile-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f8fafc;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.student-profile-name {
  font-weight: 700;
  color: var(--text-main);
}

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

.action-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-row button {
  flex: 1;
}

/* Interactive Help Tooltips */
.tooltip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background-color: var(--text-muted);
  color: white;
  border-radius: 50%;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  position: relative;
  user-select: none;
  transition: all 0.2s;
  flex-shrink: 0;
}

.tooltip-btn:hover {
  background-color: var(--primary-color);
}

.tooltip-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 130%;
  right: 0;
  background-color: #0f172a;
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.72rem;
  line-height: 1.4;
  font-weight: normal;
  white-space: normal;
  width: 220px;
  z-index: 100;
  box-shadow: var(--shadow-md);
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: translateY(4px);
}

.tooltip-btn:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.tooltip-btn::before {
  content: "";
  position: absolute;
  bottom: 120%;
  right: 6px;
  border-width: 5px;
  border-style: solid;
  border-color: #0f172a transparent transparent transparent;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tooltip-btn:hover::before {
  opacity: 1;
}

.privacy-policy-card {
  border-top: 4px solid var(--primary-color);
}

.disclaimer-text {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.disclaimer-text p strong {
  color: var(--text-main);
}

/* Fullscreen image modal overlay */
.image-modal-overlay {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.95);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.image-modal-content-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90%;
  max-height: 85%;
}

.modal-img-element {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  animation: zoomIn 0.2s ease;
}

@keyframes zoomIn {
  from {transform: scale(0.92); opacity: 0;}
  to {transform: scale(1); opacity: 1;}
}

.close-modal-overlay {
  position: absolute;
  top: 15px;
  right: 20px;
  color: #ffffff;
  font-size: 32px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.2s;
}

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

.modal-caption-text {
  margin-top: 12px;
  color: #f1f5f9;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
}

/* RESPONSIVE LAYOUT (DESKTOP SPECIFIC RULES) */
@media (min-width: 768px) {
  /* Shift App Wrapper to side-by-side layout */
  .app-wrapper {
    flex-direction: row;
  }
  
  /* Convert bottom nav into a solid vertical sidebar */
  .app-bottom-nav {
    position: static;
    width: 240px;
    height: 100vh;
    flex-direction: column;
    border-top: none;
    border-right: 1px solid var(--border-color);
    box-shadow: 4px 0 6px -1px rgba(0, 0, 0, 0.03);
    padding: 24px 0;
    justify-content: flex-start;
    flex-shrink: 0;
  }
  
  .nav-tab-btn {
    flex: none;
    width: 100%;
    height: 52px;
    flex-direction: row;
    justify-content: flex-start;
    padding: 0 24px;
    gap: 12px;
  }
  
  .nav-icon {
    font-size: 1.35rem;
    margin-bottom: 0;
  }
  
  .nav-label {
    font-size: 0.85rem;
    font-weight: 600;
  }
  
  /* Structure content block to take remaining screen */
  .app-main-content {
    padding: 32px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding-bottom: 32px; /* Remove mobile nav offset padding */
  }
  
  .app-header {
    height: 70px;
    padding: 10px 32px;
    border-bottom: 1px solid var(--border-color);
  }
  
  .header-logo-area h1 {
    font-size: 1.25rem;
  }
  
  /* Grid layouts for stats columns */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
}
