/*
 * User sidebar layout and navigation styling
 * Includes mobile responsive behavior and sidebar dropdowns
 */

/* Sidebar Layout */
.sidebar-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  background-color: var(--prof-white);
  border-right: 1px solid var(--prof-border-light);
  box-shadow: var(--prof-shadow-sm);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

/* Adjust sidebar height when impersonation footer is present */
body.has-impersonation-footer .sidebar {
  bottom: var(--impersonation-footer-height, 60px);
}

.sidebar-brand {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--prof-border-light);
  background-color: var(--prof-surface);
}

.sidebar-brand .title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--prof-primary);
  margin: 0;
  letter-spacing: -0.025em;
}

.sidebar-menu {
  padding: 1rem 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0; /* Allow flex item to shrink */
}

.sidebar-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.25rem;
  color: var(--prof-text);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  border-radius: 0;
  position: relative;
  margin-bottom: 0.25rem;
}

.sidebar-item:hover {
  background-color: var(--prof-hover-bg);
  color: var(--prof-text);
  text-decoration: none;
}

.sidebar-item.is-active {
  background-color: var(--prof-primary-light);
  color: var(--prof-primary);
  border-right: 3px solid var(--prof-primary);
}

.sidebar-item .icon {
  width: 1.25rem;
  height: 1.25rem;
  margin-right: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-item .icon svg {
  width: 1rem;
  height: 1rem;
}

.sidebar-dropdown {
  position: relative;
  margin-bottom: 0.25rem;
}

.sidebar-dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.75rem 1.25rem;
  color: var(--prof-text);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  background: transparent;
  cursor: pointer;
}

.sidebar-dropdown-toggle:hover {
  background-color: var(--prof-hover-bg);
  color: var(--prof-text);
}

.sidebar-dropdown-toggle .icon {
  width: 1.25rem;
  height: 1.25rem;
  margin-right: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-dropdown-toggle .dropdown-arrow {
  transition: transform 0.15s ease;
  font-size: 0.75rem;
  color: var(--prof-gray-400);
}

.sidebar-dropdown.is-active .dropdown-arrow {
  transform: rotate(90deg);
}

.sidebar-dropdown-menu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background-color: var(--prof-gray-50);
}

.sidebar-dropdown.is-active .sidebar-dropdown-menu {
  max-height: 500px;
}

.sidebar-dropdown-item {
  display: block;
  padding: 0.5rem 1.25rem 0.5rem 3rem;
  color: var(--prof-text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-dropdown-item:hover {
  background-color: var(--prof-hover-bg);
  color: var(--prof-text);
  text-decoration: none;
}

.sidebar-dropdown-item.is-active {
  color: var(--prof-primary);
  background-color: var(--prof-primary-light);
}

.sidebar-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--prof-border-light);
  background-color: var(--prof-surface);
}

.sidebar-footer .button {
  width: 100%;
  justify-content: flex-start;
  margin-bottom: 0.5rem;
}

.main-content {
  flex: 1;
  margin-left: 280px;
  min-height: 100vh;
  background-color: var(--prof-background);
}

.main-content .section {
  padding: 2rem 1.5rem;
}

/* 2-Column Grid Layout for Desktop */
.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  width: 100%;
  min-width: 0; /* Allows grid items to shrink below content size */
  align-items: start; /* Prevent grid items from stretching to match tallest item */
}

@media (min-width: 1024px) {
  .content-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 2.5rem;
  }
  
  .content-grid.three-columns {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  
  .content-grid.four-columns {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Ensure grid items don't overflow */
.content-grid > * {
  min-width: 0;
  overflow: hidden;
}

@media (min-width: 1216px) {
  .content-grid {
    gap: 3rem;
  }
}

/* Grid item utilities */
.grid-span-full {
  grid-column: 1 / -1;
}

@media (min-width: 1024px) {
  .grid-span-2 {
    grid-column: span 2;
  }
  
  .grid-span-3 {
    grid-column: span 3;
  }
  
  .grid-span-4 {
    grid-column: span 4;
  }
}

/* Auto-fit grid for equal-height cards */
.content-grid-auto {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  width: 100%;
}

@media (min-width: 768px) {
  .content-grid-auto {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }
}

@media (min-width: 1024px) {
  .content-grid-auto {
    gap: 2.5rem;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  }
}

/* Enhanced dashboard cards for grid layout */
.dashboard-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  width: 100%;
}

@media (min-width: 768px) {
  .dashboard-cards {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }
}

@media (min-width: 1024px) {
  .dashboard-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 2.5rem;
  }
}

@media (min-width: 1408px) {
  .dashboard-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Grid item card styling */
.grid-card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.grid-card .card-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.grid-card .card-footer {
  margin-top: auto;
  padding-top: 1rem;
}

/* Responsive adjustments for sidebar + grid */
@media (min-width: 1024px) {
  .main-content .container {
    max-width: none;
    padding: 0 2rem;
  }
}

@media (min-width: 1216px) {
  .main-content .container {
    padding: 0 3rem;
  }
}

/* Form layouts in grid */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .form-grid .field.is-full-width {
    grid-column: 1 / -1;
  }
}

/* Table responsive in grid */
.table-container {
  background-color: var(--prof-white);
  border-radius: var(--prof-border-radius);
  box-shadow: var(--prof-shadow);
  border: 1px solid var(--prof-border-light);
  overflow: hidden;
  width: 100%;
  overflow-x: auto;
}

.table-container .table {
  margin: 0;
  border: none;
  box-shadow: none;
  border-radius: 0;
  width: 100%;
  min-width: 100%;
}

/* Responsive table behavior in grid */
.content-grid .table-container {
  overflow-x: auto;
  max-width: 100%;
}

.content-grid .table {
  font-size: 0.875rem;
}

.content-grid .table th,
.content-grid .table td {
  padding: 0.5rem 0.75rem;
  white-space: nowrap;
}

/* Agenda table specific styling */
.content-grid .table td > div {
  line-height: 1.4;
}

.content-grid .table .is-size-7 {
  line-height: 1.3;
}

.content-grid .table .icon.is-small {
  width: 0.75rem;
  height: 0.75rem;
  margin-right: 0.25rem;
}

/* Mobile table adjustments */
@media (max-width: 1023px) {
  .content-grid .table {
    font-size: 0.8rem;
  }
  
  .content-grid .table th,
  .content-grid .table td {
    padding: 0.4rem 0.5rem;
  }
}

/* List layout for narrow content */
.content-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.content-list .list-item {
  background-color: var(--prof-white);
  border: 1px solid var(--prof-border-light);
  border-radius: var(--prof-border-radius);
  padding: 1.5rem;
  box-shadow: var(--prof-shadow-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.content-list .list-item:hover {
  box-shadow: var(--prof-shadow);
  transform: translateY(-1px);
}

/* Better vertical spacing in content grid */
.content-grid {
  margin-bottom: 2rem;
}

.content-grid + .content-grid {
  margin-top: 2rem;
}

/* List items in cards need better spacing */
.content-list .list-item {
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.content-list .list-item:last-child {
  margin-bottom: 0;
}

/* Mobile sidebar */
@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.is-active {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background-color: var(--prof-white);
    border-bottom: 1px solid var(--prof-border-light);
    box-shadow: var(--prof-shadow-sm);
    position: sticky;
    top: 0;
    z-index: 999;
  }
  
  .mobile-header .title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--prof-primary);
    margin: 0;
  }
  
  .sidebar-toggle {
    background: transparent;
    border: none;
    padding: 0.5rem;
    color: var(--prof-text);
    cursor: pointer;
    border-radius: var(--prof-border-radius-sm);
    transition: background-color 0.15s ease;
  }
  
  .sidebar-toggle:hover {
    background-color: var(--prof-hover-bg);
  }
  
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .sidebar-overlay.is-active {
    opacity: 1;
    visibility: visible;
  }
}

/* Desktop only */
@media (min-width: 1024px) {
  .mobile-header {
    display: none;
  }
  
  .sidebar-toggle {
    display: none;
  }
  
  .sidebar-overlay {
    display: none;
  }
}

/* Print styles */
@media print {
  .sidebar {
    display: none;
  }
  
  .main-content {
    margin-left: 0;
  }
}