/* Docked sidebar state (Desktop) */
@media (min-width: 769px) {
  .sidebar {
    transition: width 0.3s ease, padding 0.3s ease;
  }
  .main-content {
    transition: margin-left 0.3s ease;
  }
  .brand, .nav-item, .user-profile > div:nth-child(2) {
    transition: all 0.2s ease;
  }

  #app-wrapper.project-docked .sidebar {
    width: 80px;
    padding: 2rem 0.5rem;
    align-items: center;
  }
  #app-wrapper.project-docked .brand {
    font-size: 0;
    margin-bottom: 2rem;
    justify-content: center;
  }
  #app-wrapper.project-docked .brand img {
    margin: 0;
  }
  #app-wrapper.project-docked .nav-item {
    font-size: 0;
    justify-content: center;
    padding: 1rem;
  }
  #app-wrapper.project-docked .nav-item i {
    font-size: 1.4rem;
    margin: 0;
  }
  #app-wrapper.project-docked .user-profile {
    padding: 0.5rem;
    justify-content: center;
    background: transparent;
    border-color: transparent;
  }
  #app-wrapper.project-docked .user-profile > div:nth-child(2) {
    display: none;
  }
  #app-wrapper.project-docked .main-content {
    margin-left: 80px;
  }
}

/* Responsive / Mobile & Tablet Design */
@media (max-width: 768px) {
  body, #app-wrapper {
    flex-direction: column;
  }
  
  /* Ekte toppmeny (App-stil) */
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.5rem 1rem;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border-right: none;
    border-bottom: 1px solid var(--border);
    z-index: 2000;
  }

  .brand {
    margin-bottom: 0;
    font-size: 1.1rem;
    flex: unset;
  }
  
  .brand img {
    width: 24px;
    height: 24px;
  }

  .user-profile {
    padding: 0;
    background: transparent;
    border: none;
    order: 2;
  }
  
  .user-profile > div:nth-child(2) {
    display: none; /* Skjul brukernavn på liten skjerm */
  }
  
  /* Hamburger Menu Button */
  .mobile-menu-btn {
    display: flex !important;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-main);
    cursor: pointer;
    order: 3;
    margin-left: 1rem;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
  }

  .nav-menu {
    display: none; /* Skjult som standard på mobil */
    width: 100%;
    order: 4; /* Legger menyen nederst når utvidet */
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-around;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    margin-right: 0;
  }
  
  .nav-menu.show {
    display: flex;
  }

  .nav-item {
    flex-direction: column;
    padding: 0.5rem;
    font-size: 0.75rem; /* Viser liten tekst */
    gap: 0.3rem;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    width: 22%; /* Sørg for at 4 ikoner passer pent */
  }

  .nav-item i {
    font-size: 1.2rem;
    margin: 0;
  }

  /* Hovedinnhold justeringer */
  .main-content {
    margin-left: 0;
    padding: 0.8rem;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden; /* Forhindre horisontal scroll */
  }

  .header-title h1 {
    font-size: 1.3rem;
  }

  .project-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
  }
  
  .tab {
    white-space: nowrap;
    font-size: 0.85rem;
    padding: 0.5rem 0.8rem;
  }

  /* Skjemaer - Stabling på mobil */
  .form-row, .datetime-row {
    grid-template-columns: 1fr;
    flex-direction: column;
    gap: 0.8rem;
  }

  header {
    position: relative;
  }

  #view-project header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding-top: 0.5rem;
  }

  #global-user-profile {
    position: absolute !important;
    top: 0;
    right: 0;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    max-width: 60%;
  }
  #global-user-profile #user-display-name {
    display: block;
    font-size: 0.8rem;
  }

  /* Sørg for at knapper på prosjektsiden ikke sprenger bredden */
  #view-project header > div:last-child {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  #view-project header > div:last-child button {
    width: 100%;
    justify-content: center;
  }
  
  .panel-title {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .panel-title button {
    width: 100%;
    justify-content: center;
    margin-left: 0 !important;
  }

  .projects-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  /* Tidslinje-justeringer for mobil */
  .timeline-item {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
  }
  
  .timeline-time {
    width: 100%;
    text-align: left;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
  }
  
  .timeline-content {
    width: 100%;
  }

  .modal {
    width: 95%;
    max-height: 85vh;
    padding: 1.2rem;
    overflow-y: auto;
  }

  /* Item Card Responsiveness */
  .item-card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.8rem;
  }

  .item-card-title {
    flex-wrap: wrap;
    font-size: 1.05rem;
  }

  .item-card-header-actions {
    width: 100%;
    border-top: 1px dashed var(--border);
    padding-top: 0.5rem;
  }

  .item-actions-group {
    /* Give buttons more space to be clickable */
    gap: 0.5rem;
    flex-wrap: wrap;
  }
}
