/* Shared responsive layout + mobile sidenav for Email Agent dashboard pages */

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.top-nav {
  display: flex;
  gap: 6px;
  align-items: center;
}

.dash-text-link {
  color: #93c5fd;
  font-weight: 600;
  text-decoration: none;
}

.dash-text-link:hover {
  text-decoration: underline;
}

.top-nav a {
  color: #cbd5e1;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.sidenav-icon {
  display: none;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
}

.sidenav-icon svg {
  display: block;
  width: 20px;
  height: 20px;
}

.top-nav a.active .sidenav-icon {
  color: #cbd5e1;
}

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

.top-nav a.active {
  background: rgba(47, 95, 143, 0.35);
  border-color: rgba(91, 143, 199, 0.45);
  color: #fff;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
  color: #fff;
  flex-shrink: 0;
}

.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 150;
}

.nav-backdrop.open {
  display: block;
}

@media (max-width: 768px) {
  .header-inner {
    padding: 12px 16px !important;
    flex-wrap: nowrap !important;
    gap: 10px;
  }

  .header-actions {
    flex-shrink: 0;
    margin-left: auto;
  }

  .header-actions .ea-theme-btn,
  .header-actions .ea-notify-btn,
  .dashboard-controls .ea-theme-btn,
  .dashboard-controls .ea-notify-btn {
    padding: 8px 10px;
    font-size: 0.78rem;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .dashboard-controls {
    margin: 0 0 14px !important;
    justify-content: stretch !important;
  }

  .dashboard-controls .refresh-btn,
  .dashboard-controls .ea-theme-btn,
  .dashboard-controls .ea-notify-btn {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
  }

  .nav-toggle {
    display: flex !important;
    flex-shrink: 0;
  }

  .brand {
    min-width: 0;
    flex: 1;
  }

  .brand-logo {
    width: 48px !important;
    height: 48px !important;
  }

  .brand-text {
    min-width: 0;
  }

  .brand-text h1 {
    font-size: 1.08rem !important;
    line-height: 1.25;
  }

  .brand-text p,
  .brand-text .subtitle,
  .brand-text .tagline {
    font-size: 0.76rem !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.page-parent #subtitle {
    display: none;
  }

  main {
    padding: 16px 16px 32px !important;
  }

  footer {
    padding: 0 16px 24px !important;
  }

  .nav-toggle {
    display: flex;
  }

  .top-nav {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(280px, 88vw);
    margin: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 72px 16px 24px;
    background: linear-gradient(180deg, #152238 0%, #1a2f4a 100%);
    border-left: 1px solid #2a3d55;
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.45);
  }

  .top-nav.open {
    transform: translateX(0);
  }

  .top-nav::before {
    content: "Menu";
    position: absolute;
    top: 26px;
    left: 16px;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #94a3b8;
  }

  .top-nav a {
    padding: 14px 16px;
    font-size: 1rem;
    border-radius: 10px;
    white-space: normal;
  }

  .top-nav .sidenav-icon,
  .student-tabs.open .student-tab .sidenav-icon,
  .filters.open .filter-btn .sidenav-icon,
  .student-picker-panel.open .student-picker-option .sidenav-icon {
    display: inline-flex;
  }

  .student-tabs.open .student-tab,
  .filters.open .filter-btn,
  .student-picker-panel.open .student-picker-option {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  body.nav-open {
    overflow: hidden;
  }

  /* Tables scroll horizontally on small screens */
  .panel > div[style*="overflow"],
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 480px;
  }

  th, td {
    padding: 10px 12px !important;
    font-size: 0.84rem !important;
  }

  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .card {
    padding: 14px 14px !important;
  }

  .card .value {
    font-size: 1.35rem !important;
  }

  .ops-grid {
    grid-template-columns: 1fr !important;
  }

  .dashboard-controls .refresh-btn {
    padding: 10px 14px !important;
    font-size: 0.84rem !important;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch !important;
  }

  .month-nav h2 {
    min-width: 0 !important;
    font-size: 1.05rem !important;
  }

  .legend {
    gap: 8px !important;
    font-size: 0.76rem !important;
  }

  .day-cell {
    min-height: 72px !important;
    padding: 4px !important;
  }

  .event-chip {
    font-size: 0.65rem !important;
    padding: 3px 4px !important;
  }

  .upload-body {
    flex-direction: column;
    align-items: stretch !important;
  }

  .upload-btn {
    width: 100%;
    text-align: center;
  }

  .file-name-hint {
    max-width: none !important;
  }

  .student-picker-bar {
    display: flex;
    margin-bottom: 12px;
  }

  .student-picker-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #2a3d55;
    border-radius: 12px;
    background: #141e2b;
    color: #eef2f7;
    font: inherit;
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
  }

  .student-picker-toggle-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
  }

  .student-picker-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: #94a3b8;
    transition: transform 0.2s ease;
  }

  .student-picker-chevron svg {
    width: 20px;
    height: 20px;
    display: block;
  }

  .student-picker-toggle[aria-expanded="true"] .student-picker-chevron {
    transform: rotate(180deg);
  }

  .student-nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 160;
  }

  .student-nav-backdrop.open {
    display: block;
  }

  .student-tabs,
  .filters {
    display: none !important;
  }

  .student-tabs.open,
  .filters.open {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 88vw);
    margin: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 72px 16px 24px;
    background: linear-gradient(180deg, #152238 0%, #1a2f4a 100%);
    border-right: 1px solid #2a3d55;
    z-index: 170;
    overflow-y: auto;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.45);
  }

  .student-tabs.open::before,
  .filters.open::before {
    content: "Students";
    position: absolute;
    top: 26px;
    left: 16px;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #94a3b8;
  }

  .filters.open::before {
    content: "Status";
  }

  .student-tabs.open .student-tab,
  .filters.open .filter-btn {
    width: 100%;
    justify-content: flex-start;
    border-radius: 10px;
    padding: 14px 16px !important;
    font-size: 1rem !important;
  }

  .student-picker-panel {
    display: none;
  }

  .student-picker-panel.open {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 88vw);
    padding: 72px 16px 24px;
    background: linear-gradient(180deg, #152238 0%, #1a2f4a 100%);
    border-right: 1px solid #2a3d55;
    z-index: 170;
    overflow-y: auto;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.45);
  }

  .student-picker-panel.open::before {
    content: "Profile";
    position: absolute;
    top: 26px;
    left: 16px;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #94a3b8;
  }

  .student-picker-option {
    width: 100%;
    text-align: left;
    padding: 14px 16px;
    border: 1px solid #2a3d55;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.15);
    color: #eef2f7;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
  }

  .student-picker-option.active {
    border-color: #5b8fc7;
    background: rgba(47, 95, 143, 0.25);
  }

  .student-picker-desktop {
    display: none !important;
  }

  body.student-nav-open,
  body.agenda-maximized,
  body.calendar-maximized {
    overflow: hidden;
  }

  .grid-2 {
    grid-template-columns: 1fr !important;
  }

  .modal {
    max-height: 90vh;
    margin: 0;
  }

  .modal-backdrop {
    padding: 12px !important;
    align-items: flex-end !important;
  }

  .modal-backdrop.open .modal {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }
}

@media (min-width: 769px) {
  .student-picker-bar {
    display: none;
  }

  .student-picker-panel {
    display: none !important;
  }
}

@media (max-width: 400px) {
  .cards {
    grid-template-columns: 1fr !important;
  }
}

/* PWA install prompt */
.ea-install-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  animation: ea-install-slide 0.25s ease-out;
}

@keyframes ea-install-slide {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ea-install-banner.hidden {
  display: none;
}

.ea-install-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.ea-install-copy {
  flex: 1;
  min-width: 0;
}

.ea-install-copy strong {
  display: block;
  font-size: 0.92rem;
  color: var(--text);
  margin-bottom: 2px;
}

.ea-install-copy span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.ea-install-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.ea-install-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.ea-install-btn.primary {
  background: var(--dmc-blue);
  color: #fff;
}

.ea-install-btn.ghost {
  background: transparent;
  color: var(--muted);
  padding: 4px 8px;
  font-weight: 600;
}

@media (min-width: 769px) {
  .ea-install-banner {
    left: auto;
    max-width: 420px;
    right: 24px;
    bottom: 24px;
  }
}
